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:



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.

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)

  • test_mode (Boolean)

    Body param: Test mode flag - when true, the operation is simulated without side

  • idempotency_key (String)

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

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

Returns:

See Also:



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/sentdm/resources/users.rb', line 71

def invite(params = {})
  parsed, options = 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: 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.

Parameters:

Returns:

See Also:



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.

Parameters:

  • path_user_id (String)
  • test_mode (Boolean)

    Test mode flag - when true, the operation is simulated without side effects

  • body_user_id (String)

    User ID from route parameter

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

Returns:

  • (nil)

See Also:



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, options = 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: 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.

Parameters:

Returns:

See Also:



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.

Parameters:

  • path_user_id (String)

    Path param

  • role (String)

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

  • test_mode (Boolean)

    Body param: Test mode flag - when true, the operation is simulated without side

  • body_user_id (String)

    Body param: User ID from route parameter

  • idempotency_key (String)

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

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

Returns:

See Also:



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, options = 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: options
  )
end