Class: NewDemoApiClient::AsyncCompanyClient
- Inherits:
-
Object
- Object
- NewDemoApiClient::AsyncCompanyClient
- Defined in:
- lib/test_sdk/company/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create_company(group_id:, domain:, name: nil, thumbnail: nil, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Create a new company.
-
#delete(company_id:, group_id:, archive: nil, request_options: nil) ⇒ Object
Delete a company.
-
#get(group_id:, company_id:, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Get a company by ID.
-
#get_by_domain(group_id:, domain:, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Lookup a company by domain.
- #initialize(request_client:) ⇒ NewDemoApiClient::AsyncCompanyClient constructor
-
#list(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseCompanyResponse
Get all companies for a group.
-
#update(group_id:, company_id:, name: nil, domain: nil, thumbnail: nil, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Update a company.
Constructor Details
#initialize(request_client:) ⇒ NewDemoApiClient::AsyncCompanyClient
242 243 244 |
# File 'lib/test_sdk/company/client.rb', line 242 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ NewDemoApiClient::AsyncRequestClient (readonly)
238 239 240 |
# File 'lib/test_sdk/company/client.rb', line 238 def request_client @request_client end |
Instance Method Details
#create_company(group_id:, domain:, name: nil, thumbnail: nil, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Create a new company. If a non-canonical domain is provided, it will be
normalized to a canonical form.
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/test_sdk/company/client.rb', line 296 def create_company(group_id:, domain:, name: nil, thumbnail: nil, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), name: name, domain: domain, thumbnail: thumbnail }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/company" end NewDemoApiClient::CompanyResponse.from_json(json_object: response.body) end end |
#delete(company_id:, group_id:, archive: nil, request_options: nil) ⇒ Object
Delete a company.
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/test_sdk/company/client.rb', line 453 def delete(company_id:, group_id:, archive: nil, request_options: nil) Async do response = @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "archive": archive }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{company_id}/company/#{group_id}" end parsed_json = JSON.parse(response.body) parsed_json end end |
#get(group_id:, company_id:, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Get a company by ID.
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
# File 'lib/test_sdk/company/client.rb', line 376 def get(group_id:, company_id:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/company/#{company_id}" end NewDemoApiClient::CompanyResponse.from_json(json_object: response.body) end end |
#get_by_domain(group_id:, domain:, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Lookup a company by domain.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/test_sdk/company/client.rb', line 259 def get_by_domain(group_id:, domain:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "domain": domain }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/company" end NewDemoApiClient::CompanyResponse.from_json(json_object: response.body) end end |
#list(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseCompanyResponse
Get all companies for a group.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/test_sdk/company/client.rb', line 337 def list(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "sort_by": sort_by, "sort_order": sort_order, "page": page, "page_size": page_size }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/company/all" end NewDemoApiClient::PaginatedResponseCompanyResponse.from_json(json_object: response.body) end end |
#update(group_id:, company_id:, name: nil, domain: nil, thumbnail: nil, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Update a company.
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/test_sdk/company/client.rb', line 414 def update(group_id:, company_id:, name: nil, domain: nil, thumbnail: nil, request_options: nil) Async do response = @request_client.conn.put do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), name: name, domain: domain, thumbnail: thumbnail }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/company/#{company_id}" end NewDemoApiClient::CompanyResponse.from_json(json_object: response.body) end end |