Class: Pinnacle::AsyncSendClient
- Inherits:
-
Object
- Object
- Pinnacle::AsyncSendClient
- Defined in:
- lib/rcs/send/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #initialize(request_client:) ⇒ Pinnacle::AsyncSendClient constructor
-
#mms(to:, from:, text:, media_urls:, request_options: nil) ⇒ Pinnacle::Send::SendMmsResponse
Send an MMS message with media attachments.
-
#rcs(from:, to:, text: nil, media_url: nil, cards: nil, quick_replies: nil, request_options: nil) ⇒ Pinnacle::Send::SendRcsResponse
Send an interactive RCS message with text, media, or cards.
-
#sms(to:, from:, text:, request_options: nil) ⇒ Pinnacle::Send::SendSmsResponse
Send an SMS message to a recipient.
Constructor Details
#initialize(request_client:) ⇒ Pinnacle::AsyncSendClient
181 182 183 |
# File 'lib/rcs/send/client.rb', line 181 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Pinnacle::AsyncRequestClient (readonly)
177 178 179 |
# File 'lib/rcs/send/client.rb', line 177 def request_client @request_client end |
Instance Method Details
#mms(to:, from:, text:, media_urls:, request_options: nil) ⇒ Pinnacle::Send::SendMmsResponse
Send an MMS message with media attachments.
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/rcs/send/client.rb', line 317 def mms(to:, from:, text:, media_urls:, 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 || {}), to: to, from: from, text: text, mediaUrls: media_urls }.compact req.url "#{@request_client.get_url(request_options: )}/send/mms" end Pinnacle::Send::SendMmsResponse.from_json(json_object: response.body) end end |
#rcs(from:, to:, text: nil, media_url: nil, cards: nil, quick_replies: nil, request_options: nil) ⇒ Pinnacle::Send::SendRcsResponse
Send an interactive RCS message with text, media, or cards. Each message can
only contain either text, media, or card(s).
Quick replies can also be added to the message.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/rcs/send/client.rb', line 229 def rcs(from:, to:, text: nil, media_url: nil, cards: nil, quick_replies: 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 || {}), from: from, to: to, text: text, mediaUrl: media_url, cards: cards, quickReplies: quick_replies }.compact req.url "#{@request_client.get_url(request_options: )}/send/rcs" end Pinnacle::Send::SendRcsResponse.from_json(json_object: response.body) end end |
#sms(to:, from:, text:, request_options: nil) ⇒ Pinnacle::Send::SendSmsResponse
Send an SMS message to a recipient.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/rcs/send/client.rb', line 275 def sms(to:, from:, text:, 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 || {}), to: to, from: from, text: text }.compact req.url "#{@request_client.get_url(request_options: )}/send/sms" end Pinnacle::Send::SendSmsResponse.from_json(json_object: response.body) end end |