Class: Pinnacle::AsyncClient
- Inherits:
-
Object
- Object
- Pinnacle::AsyncClient
- Defined in:
- lib/rcs.rb
Instance Attribute Summary collapse
- #send ⇒ Pinnacle::AsyncSendClient readonly
Instance Method Summary collapse
-
#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.).
-
#get_rcs_functionality(phone_number: nil, request_options: nil) ⇒ Pinnacle::RcsFunctionalities
Retrieve the RCS functionality of a phone number.
- #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.
-
#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.
Constructor Details
#initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil) ⇒ Pinnacle::AsyncClient
270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/rcs.rb', line 270 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 ) @send = Pinnacle::AsyncSendClient.new(request_client: @async_request_client) end |
Instance Attribute Details
#send ⇒ Pinnacle::AsyncSendClient (readonly)
262 263 264 |
# File 'lib/rcs.rb', line 262 def send @send end |
Instance Method Details
#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.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/rcs.rb', line 328 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 |
#get_rcs_functionality(phone_number: nil, request_options: nil) ⇒ Pinnacle::RcsFunctionalities
Retrieve the RCS functionality of a phone number. For example checks if a phone
number can receive RCS message and if it can receive RCS carousels.
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/rcs.rb', line 296 def get_rcs_functionality(phone_number: 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 || {}), "phoneNumber": 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: )}/rcs_functionality" end Pinnacle::RcsFunctionalities.from_json(json_object: response.body) 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
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/rcs.rb', line 395 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 |
#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
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# File 'lib/rcs.rb', line 475 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 |