Module: Pixela::Client::UserMethods

Included in:
Pixela::Client
Defined in:
lib/pixela/client/user_methods.rb

Instance Method Summary collapse

Instance Method Details

#create_user(agree_terms_of_service:, not_minor:) ⇒ Pixela::Response

Create a new Pixela user.

Examples:

client.create_user(agree_terms_of_service: true, not_minor: true)

Parameters:

  • agree_terms_of_service (Boolean)
  • not_minor (Boolean)

Returns:

Raises:

See Also:



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pixela/client/user_methods.rb', line 15

def create_user(agree_terms_of_service:, not_minor:)
  params = {
    token:               token,
    username:            username,
    agreeTermsOfService: to_boolean_string(agree_terms_of_service),
    notMinor:            to_boolean_string(not_minor),
  }

  with_error_handling do
    connection(request_headers: default_headers).post("users", params).body
  end
end

#delete_userPixela::Response

Deletes the specified registered user.

Examples:

client.delete_user

Returns:

Raises:

See Also:



65
66
67
68
69
# File 'lib/pixela/client/user_methods.rb', line 65

def delete_user
  with_error_handling do
    connection.delete("users/#{username}").body
  end
end

#update_user(new_token:) ⇒ Pixela::Response

Updates the authentication token for the specified user.

Examples:

client.update_user(new_token: "thisissecret")

Parameters:

  • new_token (String)

Returns:

Raises:

See Also:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pixela/client/user_methods.rb', line 40

def update_user(new_token:)
  params = {
    newToken: new_token,
  }

  response =
    with_error_handling do
      connection.put("users/#{username}", params).body
    end

  @token = new_token

  response
end