Class: SurgeAPI::Resources::Users
- Inherits:
-
Object
- Object
- SurgeAPI::Resources::Users
- Defined in:
- lib/surge_api/resources/users.rb
Instance Method Summary collapse
-
#create(account_id, first_name:, last_name: nil, metadata: nil, photo_url: nil, request_options: {}) ⇒ SurgeAPI::Models::User
Creates a new User object.
-
#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.
-
#delete(id, request_options: {}) ⇒ SurgeAPI::Models::User
Deletes a user.
-
#initialize(client:) ⇒ Users
constructor
private
A new instance of Users.
-
#retrieve(id, request_options: {}) ⇒ SurgeAPI::Models::User
Retrieves a User object.
-
#update(id, first_name:, last_name: nil, metadata: nil, photo_url: nil, request_options: {}) ⇒ SurgeAPI::Models::User
Updates an existing User object.
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.
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.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/surge_api/resources/users.rb', line 25 def create(account_id, params) parsed, = SurgeAPI::UserCreateParams.dump_request(params) @client.request( method: :post, path: ["accounts/%1$s/users", account_id], body: parsed, model: SurgeAPI::User, 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.
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, = SurgeAPI::UserCreateTokenParams.dump_request(params) @client.request( method: :post, path: ["users/%1$s/tokens", user_id], body: parsed, model: SurgeAPI::UserTokenResponse, 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.
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.
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.
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/surge_api/resources/users.rb', line 75 def update(id, params) parsed, = SurgeAPI::UserUpdateParams.dump_request(params) @client.request( method: :patch, path: ["users/%1$s", id], body: parsed, model: SurgeAPI::User, options: ) end |