Class: Courier::Users::TenantsClient
- Inherits:
-
Object
- Object
- Courier::Users::TenantsClient
- 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::TenantsClient 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::TenantsClient
16 17 18 19 |
# File 'lib/trycourier/users/tenants/client.rb', line 16 def initialize(request_client:) # @type [RequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
12 13 14 |
# File 'lib/trycourier/users/tenants/client.rb', line 12 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.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/trycourier/users/tenants/client.rb', line 63 def add(user_id:, tenant_id:, profile:, request_options: nil) @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 |
#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.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/trycourier/users/tenants/client.rb', line 35 def add_multple(user_id:, tenants:, request_options: nil) @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 |
#list(user_id:, limit: nil, cursor: nil, request_options: nil) ⇒ Users::Tenants::ListTenantsForUserResponse
Returns a paginated list of user tenant associations.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/trycourier/users/tenants/client.rb', line 116 def list(user_id:, limit: nil, cursor: nil, request_options: nil) 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 |
#remove(user_id:, tenant_id:, request_options: nil) ⇒ Void
Removes a user from the supplied tenant.
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/trycourier/users/tenants/client.rb', line 97 def remove(user_id:, tenant_id:, request_options: nil) @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 |
#remove_all(user_id:, request_options: nil) ⇒ Void
Removes a user from any tenants they may have been associated with.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/trycourier/users/tenants/client.rb', line 80 def remove_all(user_id:, request_options: nil) @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 |