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, 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::SendClient
18 19 20 |
# File 'lib/rcs/send/client.rb', line 18 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Pinnacle::RequestClient (readonly)
14 15 16 |
# File 'lib/rcs/send/client.rb', line 14 def request_client @request_client end |
Instance Method Details
#mms(to:, from:, media_urls:, text: nil, request_options: nil) ⇒ Pinnacle::Send::SendMmsResponse
Send an MMS message with media attachments.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/rcs/send/client.rb', line 149 def mms(to:, from:, media_urls:, text: 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 }.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, 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.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rcs/send/client.rb', line 66 def rcs(from:, to:, text: nil, media_url: nil, cards: nil, quick_replies: 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 }.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:, request_options: nil) ⇒ Pinnacle::Send::SendSmsResponse
Send an SMS message to a recipient.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/rcs/send/client.rb', line 110 def sms(to:, from:, text:, 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 }.compact req.url "#{@request_client.get_url(request_options: )}/send/sms" end Pinnacle::Send::SendSmsResponse.from_json(json_object: response.body) end |