Class: Courier::AsyncTenantsClient
- Inherits:
-
Object
- Object
- Courier::AsyncTenantsClient
- 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:) ⇒ AsyncTenantsClient constructor
- #list(limit: nil, cursor: nil, request_options: nil) ⇒ Tenants::TenantListResponse
Constructor Details
#initialize(request_client:) ⇒ AsyncTenantsClient
134 135 136 137 |
# File 'lib/trycourier/tenants/client.rb', line 134 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.
130 131 132 |
# File 'lib/trycourier/tenants/client.rb', line 130 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
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/trycourier/tenants/client.rb', line 149 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) Async do 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 end |
#delete(tenant_id:, request_options: nil) ⇒ Void
217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/trycourier/tenants/client.rb', line 217 def delete(tenant_id:, request_options: nil) Async do @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 end |
#get(tenant_id:, request_options: nil) ⇒ Tenants::Tenant
176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/trycourier/tenants/client.rb', line 176 def get(tenant_id:, request_options: nil) Async do 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 end |
#get_users_by_tenant(tenant_id:, limit: nil, cursor: nil, request_options: nil) ⇒ Tenants::ListUsersForTenantResponse
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/trycourier/tenants/client.rb', line 236 def get_users_by_tenant(tenant_id:, limit: nil, cursor: nil, request_options: nil) Async do 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 end |
#list(limit: nil, cursor: nil, request_options: nil) ⇒ Tenants::TenantListResponse
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/trycourier/tenants/client.rb', line 195 def list(limit: nil, cursor: nil, request_options: nil) Async do 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 end |