Class: Pinnacle::AsyncCompanyClient
- Inherits:
-
Object
- Object
- Pinnacle::AsyncCompanyClient
- Defined in:
- lib/rcs/company/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#get(company_id: nil, company_name: nil, request_options: nil) ⇒ Array<Pinnacle::Company>
Retrieve the company’s information (i.e. approval status, company name, etc.).
- #initialize(request_client:) ⇒ Pinnacle::AsyncCompanyClient constructor
-
#register(company:, company_contact:, messaging:, point_of_contact:, optionals: nil, request_options: nil) ⇒ Pinnacle::Company::CompanyRegisterResponse
Register a company for RCS with the Pinnacle platform.
-
#update(company_id:, company: nil, company_contact: nil, messaging: nil, point_of_contact: nil, optionals: nil, request_options: nil) ⇒ Pinnacle::Company::CompanyUpdateResponse
Update a company on the Pinnacle platform.
Constructor Details
#initialize(request_client:) ⇒ Pinnacle::AsyncCompanyClient
247 248 249 |
# File 'lib/rcs/company/client.rb', line 247 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Pinnacle::AsyncRequestClient (readonly)
243 244 245 |
# File 'lib/rcs/company/client.rb', line 243 def request_client @request_client end |
Instance Method Details
#get(company_id: nil, company_name: nil, request_options: nil) ⇒ Array<Pinnacle::Company>
Retrieve the company’s information (i.e. approval status, company name, etc.).
Search by company ID or company name.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/rcs/company/client.rb', line 265 def get(company_id: nil, company_name: 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["PINNACLE-API-Key"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "companyId": company_id, "companyName": company_name }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/company" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json Pinnacle::Company.from_json(json_object: item) end end end |
#register(company:, company_contact:, messaging:, point_of_contact:, optionals: nil, request_options: nil) ⇒ Pinnacle::Company::CompanyRegisterResponse
Register a company for RCS with the Pinnacle platform
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/rcs/company/client.rb', line 347 def register(company:, company_contact:, messaging:, point_of_contact:, optionals: 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["PINNACLE-API-Key"] = .api_key unless &.api_key.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 || {}), company: company, companyContact: company_contact, messaging: messaging, pointOfContact: point_of_contact, optionals: optionals }.compact req.url "#{@request_client.get_url(request_options: )}/company/register" end Pinnacle::Company::CompanyRegisterResponse.from_json(json_object: response.body) end end |
#update(company_id:, company: nil, company_contact: nil, messaging: nil, point_of_contact: nil, optionals: nil, request_options: nil) ⇒ Pinnacle::Company::CompanyUpdateResponse
Update a company on the Pinnacle platform
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/rcs/company/client.rb', line 442 def update(company_id:, company: nil, company_contact: nil, messaging: nil, point_of_contact: nil, optionals: 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["PINNACLE-API-Key"] = .api_key unless &.api_key.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 || {}), companyId: company_id, company: company, companyContact: company_contact, messaging: messaging, pointOfContact: point_of_contact, optionals: optionals }.compact req.url "#{@request_client.get_url(request_options: )}/company/update" end Pinnacle::Company::CompanyUpdateResponse.from_json(json_object: response.body) end end |