Class: Trycourier::Resources::Users::Tenants

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tenants

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 Tenants.

Parameters:



145
146
147
# File 'lib/trycourier/resources/users/tenants.rb', line 145

def initialize(client:)
  @client = client
end

Instance Method Details

#add_multiple(user_id, tenants: , request_options: {}) ⇒ nil

This endpoint is used to add a user to multiple tenants in one call. A custom profile can also be supplied for each tenant. This profile will be merged with the user’s main profile when sending to the user with that tenant.

Parameters:

Returns:

  • (nil)

See Also:



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

def add_multiple(user_id, params)
  parsed, options = Trycourier::Users::TenantAddMultipleParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["users/%1$s/tenants", user_id],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#add_single(tenant_id, user_id: , profile: nil, request_options: {}) ⇒ nil

This endpoint is used to add a single tenant.

A custom profile can also be supplied with the tenant. This profile will be merged with the user’s main profile when sending to the user with that tenant.

Parameters:

  • tenant_id (String)

    Path param: Id of the tenant the user should be added to.

  • user_id (String)

    Path param: Id of the user to be added to the supplied tenant.

  • profile (Hash{Symbol=>Object}, nil)

    Body param:

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

Returns:

  • (nil)

See Also:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/trycourier/resources/users/tenants.rb', line 80

def add_single(tenant_id, params)
  parsed, options = Trycourier::Users::TenantAddSingleParams.dump_request(params)
  user_id =
    parsed.delete(:user_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["users/%1$s/tenants/%2$s", user_id, tenant_id],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#list(user_id, cursor: nil, limit: nil, request_options: {}) ⇒ Trycourier::Models::Users::TenantListResponse

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

Returns a paginated list of user tenant associations.

Parameters:

  • user_id (String)

    Id of the user to retrieve all associated tenants for.

  • cursor (String, nil)

    Continue the pagination with the next cursor

  • limit (Integer, nil)

    The number of accounts to return

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

Returns:

See Also:



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

def list(user_id, params = {})
  parsed, options = Trycourier::Users::TenantListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["users/%1$s/tenants", user_id],
    query: parsed,
    model: Trycourier::Models::Users::TenantListResponse,
    options: options
  )
end

#remove_all(user_id, request_options: {}) ⇒ nil

Removes a user from any tenants they may have been associated with.

Parameters:

  • user_id (String)

    Id of the user to be removed from the supplied tenant.

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

Returns:

  • (nil)

See Also:



106
107
108
109
110
111
112
113
# File 'lib/trycourier/resources/users/tenants.rb', line 106

def remove_all(user_id, params = {})
  @client.request(
    method: :delete,
    path: ["users/%1$s/tenants", user_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#remove_single(tenant_id, user_id: , request_options: {}) ⇒ nil

Removes a user from the supplied tenant.

Parameters:

  • tenant_id (String)

    Id of the tenant the user should be removed from.

  • user_id (String)

    Id of the user to be removed from the supplied tenant.

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

Returns:

  • (nil)

See Also:



128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/trycourier/resources/users/tenants.rb', line 128

def remove_single(tenant_id, params)
  parsed, options = Trycourier::Users::TenantRemoveSingleParams.dump_request(params)
  user_id =
    parsed.delete(:user_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["users/%1$s/tenants/%2$s", user_id, tenant_id],
    model: NilClass,
    options: options
  )
end