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:) ⇒ Hashie::Mash

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:

  • (Hashie::Mash)

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.post("users", params, default_headers).body
  end
end

#delete_userHashie::Mash

Deletes the specified registered user.

Examples:

client.delete_user

Returns:

  • (Hashie::Mash)

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}", nil, user_token_headers).body
  end
end

#update_user(new_token:) ⇒ Hashie::Mash

Updates the authentication token for the specified user.

Examples:

client.update_user(new_token: "thisissecret")

Parameters:

  • new_token (String)

Returns:

  • (Hashie::Mash)

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, user_token_headers).body
    end

  @token = new_token

  response
end