Class: NewDemoApiClient::CompanyClient
- Inherits:
-
Object
- Object
- NewDemoApiClient::CompanyClient
- 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::CompanyClient 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::CompanyClient
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_client ⇒ NewDemoApiClient::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.
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..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 |
#delete(company_id:, group_id:, archive: nil, request_options: nil) ⇒ Object
Delete a company.
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..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 JSON.parse(response.body) end |
#get(group_id:, company_id:, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Get a company by ID.
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..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 |
#get_by_domain(group_id:, domain:, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Lookup a company by domain.
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..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 |
#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.
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..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 |
#update(group_id:, company_id:, name: nil, domain: nil, thumbnail: nil, request_options: nil) ⇒ NewDemoApiClient::CompanyResponse
Update a company.
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..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 |