Class: Pinnacle::Client
- Inherits:
-
Object
- Object
- Pinnacle::Client
- 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.
- #initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil) ⇒ Pinnacle::Client constructor
-
#send(request:, request_options: nil) ⇒ Pinnacle::SendResponse
Send a SMS or RCS message to a phone number.
-
#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::Client
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rcs.rb', line 20 def initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil) @request_client = Pinnacle::RequestClient.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
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rcs.rb', line 44 def check_rcs_capability(phone_number:, request_options: nil) 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 || {}), "phone_number": phone_number }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@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.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/rcs.rb', line 103 def get_account_number(request_options: nil) 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 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: )}/get_account_number" end Pinnacle::GetAccountNumberResponse.from_json(json_object: response.body) end |
#send(request:, request_options: nil) ⇒ Pinnacle::SendResponse
Send a SMS or RCS message to a phone number
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/rcs.rb', line 135 def send(request:, request_options: nil) 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 = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(request_options: )}/send" end Pinnacle::SendResponse.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.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rcs.rb', line 74 def update_settings(webhook_url:, request_options: nil) 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 || {}), webhook_url: webhook_url }.compact req.url "#{@request_client.get_url(request_options: )}/update_settings" end Pinnacle::UpdateSettingsResponse.from_json(json_object: response.body) end |