Class: Pinnacle::AsyncClient
- Inherits:
-
Object
- Object
- Pinnacle::AsyncClient
- Defined in:
- lib/rcs.rb
Instance Method Summary collapse
-
#check_rcs_capability(phone_number:, request_options: nil) ⇒ Pinnacle::CheckRcsCapabilityResponse
Checks if a phone number is able to receive RCS.
-
#get_account_number(request_options: nil) ⇒ Pinnacle::GetAccountNumberResponse
Retrieve the phone number associated with the account.
-
#get_company(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(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil) ⇒ Pinnacle::AsyncClient constructor
-
#register_company(company:, company_contact:, point_of_contact:, optionals: nil, request_options: nil) ⇒ Pinnacle::RegisterCompanyResponse
Register a company for RCS with the Pinnacle platform.
-
#send_message(request:, request_options: nil) ⇒ Pinnacle::SendMessageResponse
Send a SMS or RCS message to a phone number.
-
#update_company(company_id:, company: nil, company_contact: nil, point_of_contact: nil, optionals: nil, request_options: nil) ⇒ Pinnacle::UpdateCompanyResponse
Update a company on the Pinnacle platform.
-
#update_settings(webhook_url:, request_options: nil) ⇒ Pinnacle::UpdateSettingsResponse
Initializes settings related to RCS messaging, including webhook registration.
Constructor Details
#initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil) ⇒ Pinnacle::AsyncClient
356 357 358 359 360 361 362 363 364 365 |
# File 'lib/rcs.rb', line 356 def initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil) @async_request_client = Pinnacle::AsyncRequestClient.new( base_url: base_url, environment: environment, max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, api_key: api_key ) end |
Instance Method Details
#check_rcs_capability(phone_number:, request_options: nil) ⇒ Pinnacle::CheckRcsCapabilityResponse
Checks if a phone number is able to receive RCS
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
# File 'lib/rcs.rb', line 380 def check_rcs_capability(phone_number:, request_options: nil) response = @async_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 || {}), **@async_request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "phone_number": phone_number }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@async_request_client.get_url(request_options: )}/check_rcs" end Pinnacle::CheckRcsCapabilityResponse.from_json(json_object: response.body) end |
#get_account_number(request_options: nil) ⇒ Pinnacle::GetAccountNumberResponse
Retrieve the phone number associated with the account.
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'lib/rcs.rb', line 439 def get_account_number(request_options: nil) response = @async_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 || {}), **@async_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 "#{@async_request_client.get_url(request_options: )}/get_account_number" end Pinnacle::GetAccountNumberResponse.from_json(json_object: response.body) end |
#get_company(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.
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/rcs.rb', line 503 def get_company(company_id: nil, company_name: nil, request_options: nil) response = @async_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 || {}), **@async_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 "#{@async_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 |
#register_company(company:, company_contact:, point_of_contact:, optionals: nil, request_options: nil) ⇒ Pinnacle::RegisterCompanyResponse
Register a company for RCS with the Pinnacle platform
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/rcs.rb', line 570 def register_company(company:, company_contact:, point_of_contact:, optionals: nil, request_options: nil) response = @async_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 || {}), **@async_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, pointOfContact: point_of_contact, optionals: optionals }.compact req.url "#{@async_request_client.get_url(request_options: )}/company/register" end Pinnacle::RegisterCompanyResponse.from_json(json_object: response.body) end |
#send_message(request:, request_options: nil) ⇒ Pinnacle::SendMessageResponse
Send a SMS or RCS message to a phone number
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
# File 'lib/rcs.rb', line 471 def (request:, request_options: nil) response = @async_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 || {}), **@async_request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@async_request_client.get_url(request_options: )}/send" end Pinnacle::SendMessageResponse.from_json(json_object: response.body) end |
#update_company(company_id:, company: nil, company_contact: nil, point_of_contact: nil, optionals: nil, request_options: nil) ⇒ Pinnacle::UpdateCompanyResponse
Update a company on the Pinnacle platform
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 |
# File 'lib/rcs.rb', line 650 def update_company(company_id:, company: nil, company_contact: nil, point_of_contact: nil, optionals: nil, request_options: nil) response = @async_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 || {}), **@async_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, pointOfContact: point_of_contact, optionals: optionals }.compact req.url "#{@async_request_client.get_url(request_options: )}/company/update" end Pinnacle::UpdateCompanyResponse.from_json(json_object: response.body) end |
#update_settings(webhook_url:, request_options: nil) ⇒ Pinnacle::UpdateSettingsResponse
Initializes settings related to RCS messaging, including webhook registration.
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/rcs.rb', line 410 def update_settings(webhook_url:, request_options: nil) response = @async_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 || {}), **@async_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 || {}), webhook_url: webhook_url }.compact req.url "#{@async_request_client.get_url(request_options: )}/update_settings" end Pinnacle::UpdateSettingsResponse.from_json(json_object: response.body) end |