Class: Sentdm::Resources::Users

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

Overview

Invite, update, and manage organization users and roles

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:



171
172
173
# File 'lib/sentdm/resources/users.rb', line 171

def initialize(client:)
  @client = client
end

Instance Method Details

#invite(email: nil, name: nil, role: nil, sandbox: nil, idempotency_key: nil, x_profile_id: 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.

Parameters:

  • email (String)

    Body param: User email address (required)

  • name (String)

    Body param: User full name (required)

  • role (String)

    Body param: User role: admin, billing, or developer (required)

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

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

Returns:

See Also:



88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/sentdm/resources/users.rb', line 88

def invite(params = {})
  parsed, options = Sentdm::UserInviteParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @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: options
  )
end

#list(x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::UserListResponse

Some parameter documentations has been truncated, see Models::UserListParams for more details.

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.

Parameters:

  • x_profile_id (String)

    Profile UUID to scope the request to a child profile. Only organization API keys

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

Returns:

See Also:



51
52
53
54
55
56
57
58
59
60
# File 'lib/sentdm/resources/users.rb', line 51

def list(params = {})
  parsed, options = Sentdm::UserListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "v3/users",
    headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::Models::UserListResponse,
    options: options
  )
end

#remove(user_id, body:, x_profile_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.

Parameters:

  • user_id (String)

    Path param

  • body (Sentdm::Models::UserRemoveParams::Body)

    Body param: Request to remove a user from an organization

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

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

Returns:

  • (nil)

See Also:



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/sentdm/resources/users.rb', line 120

def remove(user_id, params)
  parsed, options = Sentdm::UserRemoveParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["v3/users/%1$s", user_id],
    headers: parsed.except(:body).transform_keys(x_profile_id: "x-profile-id"),
    body: parsed[:body],
    model: NilClass,
    options: options
  )
end

#retrieve(user_id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfUser

Some parameter documentations has been truncated, see Models::UserRetrieveParams for more details.

Retrieves detailed information about a specific user in an organization or profile. Requires developer role or higher.

Parameters:

  • user_id (String)
  • x_profile_id (String)

    Profile UUID to scope the request to a child profile. Only organization API keys

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

Returns:

See Also:



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

def retrieve(user_id, params = {})
  parsed, options = Sentdm::UserRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v3/users/%1$s", user_id],
    headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::APIResponseOfUser,
    options: options
  )
end

#update_role(user_id, role: nil, sandbox: nil, idempotency_key: nil, x_profile_id: 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.

Parameters:

  • user_id (String)

    Path param

  • role (String)

    Body param: User role: admin, billing, or developer (required)

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

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

Returns:

See Also:



155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/sentdm/resources/users.rb', line 155

def update_role(user_id, params = {})
  parsed, options = Sentdm::UserUpdateRoleParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @client.request(
    method: :patch,
    path: ["v3/users/%1$s", user_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::APIResponseOfUser,
    options: options
  )
end