Class: Courier::Users::AsyncTenantsClient
- Inherits:
-
Object
- Object
- Courier::Users::AsyncTenantsClient
- Defined in:
- lib/trycourier/users/tenants/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
-
#add(user_id:, tenant_id:, profile:, request_options: nil) ⇒ Void
This endpoint is used to add a single tenant.
-
#add_multple(user_id:, tenants:, request_options: nil) ⇒ Void
This endpoint is used to add a user to multiple tenants in one call.
- #initialize(request_client:) ⇒ Users::AsyncTenantsClient constructor
-
#list(user_id:, limit: nil, cursor: nil, request_options: nil) ⇒ Users::Tenants::ListTenantsForUserResponse
Returns a paginated list of user tenant associations.
-
#remove(user_id:, tenant_id:, request_options: nil) ⇒ Void
Removes a user from the supplied tenant.
-
#remove_all(user_id:, request_options: nil) ⇒ Void
Removes a user from any tenants they may have been associated with.
Constructor Details
#initialize(request_client:) ⇒ Users::AsyncTenantsClient
139 140 141 142 |
# File 'lib/trycourier/users/tenants/client.rb', line 139 def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
135 136 137 |
# File 'lib/trycourier/users/tenants/client.rb', line 135 def request_client @request_client end |
Instance Method Details
#add(user_id:, tenant_id:, profile:, request_options: nil) ⇒ Void
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.
188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/trycourier/users/tenants/client.rb', line 188 def add(user_id:, tenant_id:, profile:, request_options: nil) Async do @request_client.conn.put("/users/#{user_id}/tenants/#{tenant_id}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), profile: profile }.compact end end end |
#add_multple(user_id:, tenants:, request_options: nil) ⇒ Void
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.
158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/trycourier/users/tenants/client.rb', line 158 def add_multple(user_id:, tenants:, request_options: nil) Async do @request_client.conn.put("/users/#{user_id}/tenants") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), tenants: tenants }.compact end end end |
#list(user_id:, limit: nil, cursor: nil, request_options: nil) ⇒ Users::Tenants::ListTenantsForUserResponse
Returns a paginated list of user tenant associations.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/trycourier/users/tenants/client.rb', line 247 def list(user_id:, limit: nil, cursor: nil, request_options: nil) Async do response = @request_client.conn.get("/users/#{user_id}/tenants") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "cursor": cursor }.compact end Users::Tenants::ListTenantsForUserResponse.from_json(json_object: response.body) end end |
#remove(user_id:, tenant_id:, request_options: nil) ⇒ Void
Removes a user from the supplied tenant.
226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/trycourier/users/tenants/client.rb', line 226 def remove(user_id:, tenant_id:, request_options: nil) Async do @request_client.conn.delete("/users/#{user_id}/tenants/#{tenant_id}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact end end end |
#remove_all(user_id:, request_options: nil) ⇒ Void
Removes a user from any tenants they may have been associated with.
207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/trycourier/users/tenants/client.rb', line 207 def remove_all(user_id:, request_options: nil) Async do @request_client.conn.delete("/users/#{user_id}/tenants") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact end end end |