Class: NewDemoApiClient::AsyncCompanyClient

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/company/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ NewDemoApiClient::AsyncCompanyClient

Parameters:



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_clientNewDemoApiClient::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.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.company.create_company(group_id: 1, domain: "domain")

Parameters:

  • group_id (Integer)
  • name (String) (defaults to: nil)
  • domain (String)

    The domain of the company. Must be a valid domain or URL. The domain will be normalized to a canonical form.

  • thumbnail (String) (defaults to: nil)

    The thumbnail URL of the company

  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



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.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        name: name,
        domain: domain,
        thumbnail: thumbnail
      }.compact
      req.url "#{@request_client.get_url(request_options: 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.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.company.delete(company_id: 1, group_id: 1)

Parameters:

Returns:

  • (Object)


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.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = { **(request_options&.additional_query_parameters || {}), "archive": archive }.compact
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: 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.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.company.get(group_id: 1, company_id: 1)

Parameters:

Returns:



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.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: 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.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.company.get_by_domain(group_id: 1, domain: "domain")

Parameters:

Returns:



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.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = { **(request_options&.additional_query_parameters || {}), "domain": domain }.compact
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: 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.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.company.list(group_id: 1)

Parameters:

  • group_id (Integer)
  • sort_by (String) (defaults to: nil)
  • sort_order (String) (defaults to: nil)
  • page (Integer) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



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.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "sort_by": sort_by,
        "sort_order": sort_order,
        "page": page,
        "page_size": page_size
      }.compact
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: 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.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.company.update(group_id: 1, company_id: 1)

Parameters:

  • group_id (Integer)
  • company_id (Integer)
  • name (String) (defaults to: nil)
  • domain (String) (defaults to: nil)
  • thumbnail (String) (defaults to: nil)

    The thumbnail URL of the company

  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



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.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        name: name,
        domain: domain,
        thumbnail: thumbnail
      }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/company/#{company_id}"
    end
    NewDemoApiClient::CompanyResponse.from_json(json_object: response.body)
  end
end