Class: NewDemoApiClient::CompanyClient

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::CompanyClient

Parameters:



16
17
18
# File 'lib/test_sdk/company/client.rb', line 16

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientNewDemoApiClient::RequestClient (readonly)



12
13
14
# File 'lib/test_sdk/company/client.rb', line 12

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:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/test_sdk/company/client.rb', line 68

def create_company(group_id:, domain:, name: nil, thumbnail: nil, request_options: nil)
  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

#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)


217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/test_sdk/company/client.rb', line 217

def delete(company_id:, group_id:, archive: nil, request_options: nil)
  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
  JSON.parse(response.body)
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:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/test_sdk/company/client.rb', line 144

def get(group_id:, company_id:, request_options: nil)
  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

#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:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/test_sdk/company/client.rb', line 33

def get_by_domain(group_id:, domain:, request_options: nil)
  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

#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:



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/test_sdk/company/client.rb', line 107

def list(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil)
  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

#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:



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/test_sdk/company/client.rb', line 180

def update(group_id:, company_id:, name: nil, domain: nil, thumbnail: nil, request_options: nil)
  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