Class: Courier::TenantsClient
- Inherits:
-
Object
- Object
- Courier::TenantsClient
- Defined in:
- lib/trycourier/tenants/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
- #create_or_replace(tenant_id:, name:, parent_tenant_id: nil, default_preferences: nil, properties: nil, user_profile: nil, brand_id: nil, request_options: nil) ⇒ Tenants::Tenant
- #delete(tenant_id:, request_options: nil) ⇒ Void
- #get(tenant_id:, request_options: nil) ⇒ Tenants::Tenant
- #get_users_by_tenant(tenant_id:, limit: nil, cursor: nil, request_options: nil) ⇒ Tenants::ListUsersForTenantResponse
- #initialize(request_client:) ⇒ TenantsClient constructor
- #list(limit: nil, cursor: nil, request_options: nil) ⇒ Tenants::TenantListResponse
Constructor Details
#initialize(request_client:) ⇒ TenantsClient
17 18 19 20 |
# File 'lib/trycourier/tenants/client.rb', line 17 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.
13 14 15 |
# File 'lib/trycourier/tenants/client.rb', line 13 def request_client @request_client end |
Instance Method Details
#create_or_replace(tenant_id:, name:, parent_tenant_id: nil, default_preferences: nil, properties: nil, user_profile: nil, brand_id: nil, request_options: nil) ⇒ Tenants::Tenant
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trycourier/tenants/client.rb', line 32 def create_or_replace(tenant_id:, name:, parent_tenant_id: nil, default_preferences: nil, properties: nil, user_profile: nil, brand_id: nil, request_options: nil) response = @request_client.conn.put("/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 || {}), name: name, parent_tenant_id: parent_tenant_id, default_preferences: default_preferences, properties: properties, user_profile: user_profile, brand_id: brand_id }.compact end Tenants::Tenant.from_json(json_object: response.body) end |
#delete(tenant_id:, request_options: nil) ⇒ Void
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/trycourier/tenants/client.rb', line 94 def delete(tenant_id:, request_options: nil) @request_client.conn.delete("/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 |
#get(tenant_id:, request_options: nil) ⇒ Tenants::Tenant
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/trycourier/tenants/client.rb', line 57 def get(tenant_id:, request_options: nil) response = @request_client.conn.get("/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 Tenants::Tenant.from_json(json_object: response.body) end |
#get_users_by_tenant(tenant_id:, limit: nil, cursor: nil, request_options: nil) ⇒ Tenants::ListUsersForTenantResponse
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/trycourier/tenants/client.rb', line 111 def get_users_by_tenant(tenant_id:, limit: nil, cursor: nil, request_options: nil) response = @request_client.conn.get("/tenants/#{tenant_id}/users") 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 Tenants::ListUsersForTenantResponse.from_json(json_object: response.body) end |
#list(limit: nil, cursor: nil, request_options: nil) ⇒ Tenants::TenantListResponse
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/trycourier/tenants/client.rb', line 74 def list(limit: nil, cursor: nil, request_options: nil) response = @request_client.conn.get("/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 Tenants::TenantListResponse.from_json(json_object: response.body) end |