Class: Pinnacle::SendClient
- Inherits:
-
Object
- Object
- Pinnacle::SendClient
- Defined in:
- lib/rcs/send/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #initialize(request_client:) ⇒ Pinnacle::SendClient 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::SendClient
19 20 21 |
# File 'lib/rcs/send/client.rb', line 19 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Pinnacle::RequestClient (readonly)
15 16 17 |
# File 'lib/rcs/send/client.rb', line 15 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.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/rcs/send/client.rb', line 169 def mms(to:, from:, media_urls:, text: nil, status_callback: nil, 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 || {}), 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 |
#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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rcs/send/client.rb', line 73 def rcs(from:, to:, text: nil, media_url: nil, cards: nil, quick_replies: nil, fallback: nil, status_callback: nil, 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 || {}), 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 |
#sms(to:, from:, text:, status_callback: nil, request_options: nil) ⇒ Pinnacle::Send::SendSmsResponse
Send an SMS message to a recipient.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/rcs/send/client.rb', line 122 def sms(to:, from:, text:, status_callback: nil, 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 || {}), 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 |