Class: Courier::Resources::Users::Tenants
- Inherits:
-
Object
- Object
- Courier::Resources::Users::Tenants
- Defined in:
- lib/courier/resources/users/tenants.rb,
sig/courier/resources/users/tenants.rbs
Overview
Associate a user with one or more tenants, and read or remove those associations.
Instance Method Summary collapse
-
#add_multiple(user_id, tenants:, request_options: {}) ⇒ nil
Adds a user to several tenants in one call, each optionally with a per-tenant profile that overrides their workspace profile.
-
#add_single(tenant_id, user_id:, profile: nil, request_options: {}) ⇒ nil
Adds a user to one tenant, optionally with a tenant-specific profile that overrides their workspace profile for sends in that tenant.
-
#initialize(client:) ⇒ Tenants
constructor
private
A new instance of Tenants.
-
#list(user_id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::Users::TenantListResponse
Some parameter documentations has been truncated, see Models::Users::TenantListParams for more details.
-
#remove_all(user_id, request_options: {}) ⇒ nil
Removes a user from every tenant they belong to in one call.
-
#remove_single(tenant_id, user_id:, request_options: {}) ⇒ nil
Removes a user from one tenant.
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.
148 149 150 |
# File 'lib/courier/resources/users/tenants.rb', line 148 def initialize(client:) @client = client end |
Instance Method Details
#add_multiple(user_id, tenants:, request_options: {}) ⇒ nil
Adds a user to several tenants in one call, each optionally with a per-tenant profile that overrides their workspace profile.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/courier/resources/users/tenants.rb', line 54 def add_multiple(user_id, params) parsed, = Courier::Users::TenantAddMultipleParams.dump_request(params) @client.request( method: :put, path: ["users/%1$s/tenants", user_id], body: parsed, model: NilClass, options: ) end |
#add_single(tenant_id, user_id:, profile: nil, request_options: {}) ⇒ nil
Adds a user to one tenant, optionally with a tenant-specific profile that overrides their workspace profile for sends in that tenant.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/courier/resources/users/tenants.rb', line 81 def add_single(tenant_id, params) parsed, = Courier::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: ) end |
#list(user_id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::Users::TenantListResponse
Some parameter documentations has been truncated, see Models::Users::TenantListParams for more details.
Returns the tenants a user belongs to, with cursor paging. A user can belong to many tenants, each with its own profile and preferences.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/courier/resources/users/tenants.rb', line 28 def list(user_id, params = {}) parsed, = Courier::Users::TenantListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["users/%1$s/tenants", user_id], query: query, model: Courier::Models::Users::TenantListResponse, options: ) end |
#remove_all(user_id, request_options: {}) ⇒ nil
Removes a user from every tenant they belong to in one call. Their workspace-level profile is a separate resource.
108 109 110 111 112 113 114 115 |
# File 'lib/courier/resources/users/tenants.rb', line 108 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 one tenant. Their other tenant memberships and workspace profile are managed through separate endpoints.
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/courier/resources/users/tenants.rb', line 131 def remove_single(tenant_id, params) parsed, = Courier::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: ) end |