Class: SurgeAPI::Resources::Users

Inherits:
Object
  • Object
show all
Defined in:
lib/surge_api/resources/users.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Users

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Users.

Parameters:



138
139
140
# File 'lib/surge_api/resources/users.rb', line 138

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_id, first_name:, last_name: nil, metadata: nil, photo_url: nil, request_options: {}) ⇒ SurgeAPI::Models::User

Creates a new User object.

Parameters:

  • account_id (String)

    The account for which the user should be created.

  • first_name (String)

    The user’s first name.

  • last_name (String)

    The user’s last name.

  • metadata (Hash{Symbol=>String})

    Set of key-value pairs that will be stored with the object.

  • photo_url (String)

    URL of a photo to be used as the user’s avatar.

  • request_options (SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



25
26
27
28
29
30
31
32
33
34
# File 'lib/surge_api/resources/users.rb', line 25

def create(, params)
  parsed, options = SurgeAPI::UserCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["accounts/%1$s/users", ],
    body: parsed,
    model: SurgeAPI::User,
    options: options
  )
end

#create_token(user_id, duration_seconds: nil, request_options: {}) ⇒ SurgeAPI::Models::UserTokenResponse

Provides a mechanism for having Surge create a signed token for embeds instead of signing with your own signing key.

Parameters:

  • user_id (String)

    The user for which the token represents authentication.

  • duration_seconds (Integer)

    For how many seconds the token should be accepted. Defaults to 15 minutes.

  • request_options (SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
# File 'lib/surge_api/resources/users.rb', line 124

def create_token(user_id, params = {})
  parsed, options = SurgeAPI::UserCreateTokenParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["users/%1$s/tokens", user_id],
    body: parsed,
    model: SurgeAPI::UserTokenResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ SurgeAPI::Models::User

Deletes a user.

Once a user has been deleted, they will no longer be permitted to access any of the embedded components. Attempting to access a deleted user will return a 404 Not Found error.

Parameters:

Returns:

See Also:



101
102
103
104
105
106
107
108
# File 'lib/surge_api/resources/users.rb', line 101

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["users/%1$s", id],
    model: SurgeAPI::User,
    options: params[:request_options]
  )
end

#retrieve(id, request_options: {}) ⇒ SurgeAPI::Models::User

Retrieves a User object.

Parameters:

Returns:

See Also:



47
48
49
50
51
52
53
54
# File 'lib/surge_api/resources/users.rb', line 47

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["users/%1$s", id],
    model: SurgeAPI::User,
    options: params[:request_options]
  )
end

#update(id, first_name:, last_name: nil, metadata: nil, photo_url: nil, request_options: {}) ⇒ SurgeAPI::Models::User

Updates an existing User object.

Parameters:

  • id (String)

    The ID of the user to update.

  • first_name (String)

    The user’s first name.

  • last_name (String)

    The user’s last name.

  • metadata (Hash{Symbol=>String})

    Set of key-value pairs that will be stored with the object.

  • photo_url (String)

    URL of a photo to be used as the user’s avatar.

  • request_options (SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



75
76
77
78
79
80
81
82
83
84
# File 'lib/surge_api/resources/users.rb', line 75

def update(id, params)
  parsed, options = SurgeAPI::UserUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["users/%1$s", id],
    body: parsed,
    model: SurgeAPI::User,
    options: options
  )
end