Class: Sentdm::Resources::Users
- Inherits:
-
Object
- Object
- Sentdm::Resources::Users
- Defined in:
- lib/sentdm/resources/users.rb
Overview
Invite, update, and manage organization users and roles
Instance Method Summary collapse
-
#initialize(client:) ⇒ Users
constructor
private
A new instance of Users.
-
#invite(email: nil, name: nil, role: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfUser
Some parameter documentations has been truncated, see Models::UserInviteParams for more details.
-
#list(request_options: {}) ⇒ Sentdm::Models::UserListResponse
Retrieves all users who have access to the organization or profile identified by the API key, including their roles and status.
-
#remove(path_user_id, test_mode: nil, body_user_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::UserRemoveParams for more details.
-
#retrieve(user_id, request_options: {}) ⇒ Sentdm::Models::APIResponseOfUser
Retrieves detailed information about a specific user in an organization or profile.
-
#update_role(path_user_id, role: nil, test_mode: nil, body_user_id: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfUser
Some parameter documentations has been truncated, see Models::UserUpdateRoleParams for more details.
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.
154 155 156 |
# File 'lib/sentdm/resources/users.rb', line 154 def initialize(client:) @client = client end |
Instance Method Details
#invite(email: nil, name: nil, role: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfUser
Some parameter documentations has been truncated, see Models::UserInviteParams for more details.
Sends an invitation to a user to join the organization or profile with a specific role. Requires admin role. The user will receive an invitation email with a token to accept. Invitation tokens expire after 7 days.
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/sentdm/resources/users.rb', line 71 def invite(params = {}) parsed, = Sentdm::UserInviteParams.dump_request(params) header_params = {idempotency_key: "idempotency-key"} @client.request( method: :post, path: "v3/users", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Sentdm::APIResponseOfUser, options: ) end |
#list(request_options: {}) ⇒ Sentdm::Models::UserListResponse
Retrieves all users who have access to the organization or profile identified by the API key, including their roles and status. Shows invited users (pending acceptance) and active users. Requires developer role or higher.
38 39 40 41 42 43 44 45 |
# File 'lib/sentdm/resources/users.rb', line 38 def list(params = {}) @client.request( method: :get, path: "v3/users", model: Sentdm::Models::UserListResponse, options: params[:request_options] ) end |
#remove(path_user_id, test_mode: nil, body_user_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::UserRemoveParams for more details.
Removes a user’s access to an organization or profile. Requires admin role. You cannot remove yourself or remove the last admin.
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/sentdm/resources/users.rb', line 103 def remove(path_user_id, params = {}) parsed, = Sentdm::UserRemoveParams.dump_request(params) @client.request( method: :delete, path: ["v3/users/%1$s", path_user_id], headers: {"content-type" => "*/*"}, body: parsed, model: NilClass, options: ) end |
#retrieve(user_id, request_options: {}) ⇒ Sentdm::Models::APIResponseOfUser
Retrieves detailed information about a specific user in an organization or profile. Requires developer role or higher.
18 19 20 21 22 23 24 25 |
# File 'lib/sentdm/resources/users.rb', line 18 def retrieve(user_id, params = {}) @client.request( method: :get, path: ["v3/users/%1$s", user_id], model: Sentdm::APIResponseOfUser, options: params[:request_options] ) end |
#update_role(path_user_id, role: nil, test_mode: nil, body_user_id: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfUser
Some parameter documentations has been truncated, see Models::UserUpdateRoleParams for more details.
Updates a user’s role in the organization or profile. Requires admin role. You cannot change your own role or demote the last admin.
138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/sentdm/resources/users.rb', line 138 def update_role(path_user_id, params = {}) parsed, = Sentdm::UserUpdateRoleParams.dump_request(params) header_params = {idempotency_key: "idempotency-key"} @client.request( method: :patch, path: ["v3/users/%1$s", path_user_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Sentdm::APIResponseOfUser, options: ) end |