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:, media_urls:, text: nil, status_callback: nil, 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, fallback: nil, status_callback: nil, request_options: nil) ⇒ Pinnacle::Send::SendRcsResponse
Send an interactive RCS message with text, media, or cards.
-
#sms(to:, from:, text:, status_callback: nil, request_options: nil) ⇒ Pinnacle::Send::SendSmsResponse
Send an SMS message to a recipient.
Constructor Details
#initialize(request_client:) ⇒ Pinnacle::AsyncSendClient
201 202 203 |
# File 'lib/rcs/send/client.rb', line 201 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Pinnacle::AsyncRequestClient (readonly)
197 198 199 |
# File 'lib/rcs/send/client.rb', line 197 def request_client @request_client end |
Instance Method Details
#mms(to:, from:, media_urls:, text: nil, status_callback: nil, request_options: nil) ⇒ Pinnacle::Send::SendMmsResponse
Send an MMS message with media attachments.
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/rcs/send/client.rb', line 355 def mms(to:, from:, media_urls:, text: nil, status_callback: 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 || {}), to: to, from: from, text: text, mediaUrls: media_urls, statusCallback: status_callback }.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, fallback: nil, status_callback: 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.
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/rcs/send/client.rb', line 255 def rcs(from:, to:, text: nil, media_url: nil, cards: nil, quick_replies: nil, fallback: nil, status_callback: 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, fallback: fallback, statusCallback: status_callback }.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:, status_callback: nil, request_options: nil) ⇒ Pinnacle::Send::SendSmsResponse
Send an SMS message to a recipient.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/rcs/send/client.rb', line 306 def sms(to:, from:, text:, status_callback: 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 || {}), to: to, from: from, text: text, statusCallback: status_callback }.compact req.url "#{@request_client.get_url(request_options: )}/send/sms" end Pinnacle::Send::SendSmsResponse.from_json(json_object: response.body) end end |