Class: Pinnacle::Messages::Blast::Client
- Inherits:
-
Object
- Object
- Pinnacle::Messages::Blast::Client
- Defined in:
- lib/pinnacle/messages/blast/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#mms(request_options: {}, **params) ⇒ Pinnacle::Messages::Blast::Types::BlastMmsResponse
Send an MMS message to all contacts in an audience.
-
#rcs(request_options: {}, **params) ⇒ Pinnacle::Messages::Blast::Types::BlastRcsResponse
Send an RCS message to all contacts in an audience.
-
#sms(request_options: {}, **params) ⇒ Pinnacle::Messages::Blast::Types::BlastSmsResponse
Send an SMS message to all contacts in an audience.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/pinnacle/messages/blast/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#mms(request_options: {}, **params) ⇒ Pinnacle::Messages::Blast::Types::BlastMmsResponse
Send an MMS message to all contacts in an audience.
Messages are distributed evenly across the provided sender phone numbers.
Use the optional ‘schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pinnacle/messages/blast/client.rb', line 69 def mms(request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "messages/blast/mms", body: Pinnacle::Messages::Blast::Types::BlastMms.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Pinnacle::Messages::Blast::Types::BlastMmsResponse.load(response.body) else error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#rcs(request_options: {}, **params) ⇒ Pinnacle::Messages::Blast::Types::BlastRcsResponse
Send an RCS message to all contacts in an audience.
Messages are distributed evenly across the provided RCS agents for load balancing. Requires active RCS agents and recipient devices that support RCS Business Messaging.
Use the optional ‘schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/pinnacle/messages/blast/client.rb', line 109 def rcs(request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "messages/blast/rcs", body: Pinnacle::Messages::Blast::Types::BlastRcs.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Pinnacle::Messages::Blast::Types::BlastRcsResponse.load(response.body) else error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#sms(request_options: {}, **params) ⇒ Pinnacle::Messages::Blast::Types::BlastSmsResponse
Send an SMS message to all contacts in an audience.
Messages are distributed evenly across the provided sender phone numbers.
Use the optional ‘schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pinnacle/messages/blast/client.rb', line 30 def sms(request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "messages/blast/sms", body: Pinnacle::Messages::Blast::Types::BlastSms.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Pinnacle::Messages::Blast::Types::BlastSmsResponse.load(response.body) else error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |