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.
-
#list(account_id, after: nil, before: nil, request_options: {}) ⇒ SurgeAPI::Internal::Cursor<SurgeAPI::Models::User>
Some parameter documentations has been truncated, see Models::UserListParams for more details.
-
#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.
169 170 171 |
# File 'lib/surge_api/resources/users.rb', line 169 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.
155 156 157 158 159 160 161 162 163 164 |
# File 'lib/surge_api/resources/users.rb', line 155 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.
132 133 134 135 136 137 138 139 |
# File 'lib/surge_api/resources/users.rb', line 132 def delete(id, params = {}) @client.request( method: :delete, path: ["users/%1$s", id], model: SurgeAPI::User, options: params[:request_options] ) end |
#list(account_id, after: nil, before: nil, request_options: {}) ⇒ SurgeAPI::Internal::Cursor<SurgeAPI::Models::User>
Some parameter documentations has been truncated, see Models::UserListParams for more details.
List all users for an account with cursor-based pagination.
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/surge_api/resources/users.rb', line 104 def list(account_id, params = {}) parsed, = SurgeAPI::UserListParams.dump_request(params) query = SurgeAPI::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["accounts/%1$s/users", account_id], query: query, page: SurgeAPI::Internal::Cursor, model: SurgeAPI::User, 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 |