rcs 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rcs/brands/client.rb +19 -6
  3. data/lib/rcs/campaigns/dlc/client.rb +12 -12
  4. data/lib/rcs/campaigns/dlc/types/{upsert_dlc_campaign_help_keywords.rb → dlc_campaign_help_keywords.rb} +5 -5
  5. data/lib/rcs/campaigns/dlc/types/{upsert_dlc_campaign_keywords.rb → dlc_campaign_keywords.rb} +20 -20
  6. data/lib/rcs/campaigns/dlc/types/{upsert_dlc_campaign_links.rb → dlc_campaign_links.rb} +5 -5
  7. data/lib/rcs/campaigns/dlc/types/{upsert_dlc_campaign_opt_in_keywords.rb → dlc_campaign_opt_in_keywords.rb} +5 -5
  8. data/lib/rcs/campaigns/dlc/types/{upsert_dlc_campaign_opt_out_keywords.rb → dlc_campaign_opt_out_keywords.rb} +5 -5
  9. data/lib/rcs/campaigns/dlc/types/{upsert_dlc_campaign_options.rb → dlc_campaign_options.rb} +5 -5
  10. data/lib/rcs/campaigns/dlc/types/{upsert_dlc_campaign_use_case.rb → dlc_campaign_use_case.rb} +5 -5
  11. data/lib/rcs/campaigns/rcs/client.rb +144 -51
  12. data/lib/rcs/campaigns/rcs/types/{upsert_rcs_agent.rb → rcs_agent.rb} +15 -9
  13. data/lib/rcs/campaigns/rcs/types/rcs_autofill_response.rb +122 -43
  14. data/lib/rcs/campaigns/rcs/types/{upsert_rcs_opt_out.rb → rcs_campaign_help_keywords.rb} +20 -19
  15. data/lib/rcs/campaigns/rcs/types/rcs_campaign_keywords.rb +98 -0
  16. data/lib/rcs/campaigns/rcs/types/rcs_campaign_opt_in_keywords.rb +87 -0
  17. data/lib/rcs/campaigns/rcs/types/rcs_campaign_opt_out_keywords.rb +83 -0
  18. data/lib/rcs/campaigns/rcs/types/rcs_campaign_traffic.rb +76 -0
  19. data/lib/rcs/campaigns/rcs/types/{upsert_rcs_links.rb → rcs_links.rb} +5 -5
  20. data/lib/rcs/campaigns/rcs/types/{upsert_rcs_use_case.rb → rcs_use_case.rb} +7 -7
  21. data/lib/rcs/campaigns/toll_free/client.rb +53 -10
  22. data/lib/rcs/campaigns/toll_free/types/toll_free_autofill_response.rb +54 -12
  23. data/lib/rcs/campaigns/toll_free/types/toll_free_campaign_help_keywords.rb +66 -0
  24. data/lib/rcs/campaigns/toll_free/types/toll_free_campaign_keywords.rb +86 -0
  25. data/lib/rcs/campaigns/toll_free/types/toll_free_campaign_links.rb +74 -0
  26. data/lib/rcs/campaigns/toll_free/types/{upsert_toll_free_schema_opt_in.rb → toll_free_campaign_opt_in.rb} +5 -5
  27. data/lib/rcs/campaigns/toll_free/types/toll_free_campaign_opt_in_keywords.rb +78 -0
  28. data/lib/rcs/campaigns/toll_free/types/toll_free_campaign_options.rb +64 -0
  29. data/lib/rcs/campaigns/toll_free/types/{upsert_toll_free_schema_use_case.rb → toll_free_campaign_use_case.rb} +5 -5
  30. data/lib/rcs/messages/blast/client.rb +419 -0
  31. data/lib/rcs/messages/blast/types/blast_mms_options.rb +82 -0
  32. data/lib/rcs/messages/blast/types/blast_mms_response.rb +60 -0
  33. data/lib/rcs/messages/blast/types/blast_rcs_options.rb +118 -0
  34. data/lib/rcs/messages/blast/types/blast_rcs_request_options_standalone_card.rb +82 -0
  35. data/lib/rcs/messages/blast/types/blast_rcs_request_options_standalone_card_image_alignment.rb +16 -0
  36. data/lib/rcs/messages/blast/types/blast_rcs_request_options_standalone_card_orientation.rb +15 -0
  37. data/lib/rcs/messages/blast/types/blast_rcs_response.rb +60 -0
  38. data/lib/rcs/messages/blast/types/blast_sms_options.rb +70 -0
  39. data/lib/rcs/messages/blast/types/blast_sms_response.rb +60 -0
  40. data/lib/rcs/messages/mms/client.rb +6 -6
  41. data/lib/rcs/messages/mms/types/mms_send_response.rb +4 -4
  42. data/lib/rcs/messages/rcs/client.rb +7 -7
  43. data/lib/rcs/messages/rcs/types/{rcs_send_response.rb → send_rich_message_response.rb} +11 -11
  44. data/lib/rcs/messages/schedule/client.rb +103 -0
  45. data/lib/rcs/messages/sms/client.rb +6 -6
  46. data/lib/rcs/messages/sms/types/sms_send_response.rb +4 -4
  47. data/lib/rcs/types/{rcs_base.rb → base_rich_message.rb} +10 -10
  48. data/lib/rcs/types/blast_details.rb +110 -0
  49. data/lib/rcs/types/company_entity_type_enum.rb +14 -0
  50. data/lib/rcs/types/dlc_campaign_with_extended_brand_and_status.rb +30 -2
  51. data/lib/rcs/types/dlc_with_extended_brand_and_status_mno_brand_tier.rb +15 -0
  52. data/lib/rcs/types/dlc_with_extended_brand_and_status_mno_tcr_tier.rb +22 -0
  53. data/lib/rcs/types/extended_brand.rb +10 -1
  54. data/lib/rcs/types/extended_brand_with_vetting.rb +10 -1
  55. data/lib/rcs/types/extended_rcs_campaign.rb +122 -51
  56. data/lib/rcs/types/message_schedule.rb +52 -24
  57. data/lib/rcs/types/message_status_enum.rb +1 -0
  58. data/lib/rcs/types/optional_brand_info.rb +10 -1
  59. data/lib/rcs/types/rcs_campaign.rb +122 -43
  60. data/lib/rcs/types/rcs_campaign_schema_extra_keywords.rb +94 -0
  61. data/lib/rcs/types/{rcs_campaign_schema_extra_opt_out.rb → rcs_campaign_schema_extra_keywords_help.rb} +18 -17
  62. data/lib/rcs/types/rcs_campaign_schema_extra_keywords_opt_in.rb +73 -0
  63. data/lib/rcs/types/rcs_campaign_schema_extra_keywords_opt_out.rb +73 -0
  64. data/lib/rcs/types/rcs_campaign_schema_extra_traffic.rb +72 -0
  65. data/lib/rcs/types/rcs_campaign_schema_extra_use_case.rb +2 -2
  66. data/lib/rcs/types/rcs_campaign_schema_keywords.rb +94 -0
  67. data/lib/rcs/types/{rcs_campaign_schema_opt_out.rb → rcs_campaign_schema_keywords_help.rb} +18 -17
  68. data/lib/rcs/types/rcs_campaign_schema_keywords_opt_in.rb +73 -0
  69. data/lib/rcs/types/rcs_campaign_schema_keywords_opt_out.rb +73 -0
  70. data/lib/rcs/types/rcs_campaign_schema_traffic.rb +72 -0
  71. data/lib/rcs/types/rcs_campaign_schema_use_case.rb +2 -2
  72. data/lib/rcs/types/rcs_cards_content_cards_item.rb +4 -2
  73. data/lib/rcs/types/rcs_content.rb +4 -4
  74. data/lib/rcs/types/rcs_messaging_type_enum.rb +17 -0
  75. data/lib/rcs/types/rcs_validate_content.rb +8 -8
  76. data/lib/rcs/types/rcs_validation_result.rb +9 -2
  77. data/lib/rcs/types/{rcs_cards_cards_item.rb → rich_card.rb} +9 -7
  78. data/lib/rcs/types/{rcs_cards.rb → rich_cards.rb} +9 -9
  79. data/lib/rcs/types/rich_cards_message.rb +9 -9
  80. data/lib/rcs/types/rich_media_message.rb +5 -5
  81. data/lib/rcs/types/{send_rcs_card_options_standalone_card.rb → rich_standalone_card_options.rb} +9 -7
  82. data/lib/rcs/types/{rcs_text_content.rb → rich_text.rb} +5 -5
  83. data/lib/rcs/types/rich_text_message.rb +5 -5
  84. data/lib/rcs/types/schedule_cancel_result.rb +58 -0
  85. data/lib/rcs/types/scheduled_blast_details.rb +76 -0
  86. data/lib/rcs/types/scheduled_blast_response_config.rb +89 -0
  87. data/lib/rcs/types/{scheduled_messaage.rb → scheduled_message.rb} +5 -5
  88. data/lib/rcs/types/{send_rcs_card_options.rb → send_rich_cards_options.rb} +18 -14
  89. data/lib/rcs/types/{options.rb → send_rich_message_options.rb} +5 -5
  90. data/lib/rcs/types/{sent_rcs_details.rb → sent_rich_message.rb} +5 -5
  91. data/lib/rcs/types/toll_free_campaign.rb +54 -12
  92. data/lib/rcs/types/toll_free_campaign_schema_keywords.rb +82 -0
  93. data/lib/rcs/types/toll_free_campaign_schema_keywords_help.rb +62 -0
  94. data/lib/rcs/types/toll_free_campaign_schema_keywords_opt_in.rb +74 -0
  95. data/lib/rcs/types/toll_free_campaign_schema_links.rb +70 -0
  96. data/lib/rcs/types/{upsert_toll_free_campaign_opt_in.rb → toll_free_campaign_schema_opt_in.rb} +5 -5
  97. data/lib/rcs/types/toll_free_campaign_schema_options.rb +60 -0
  98. data/lib/rcs/types/{upsert_toll_free_campaign_use_case.rb → toll_free_campaign_schema_use_case.rb} +5 -5
  99. data/lib/rcs/types/toll_free_campaign_with_extended_brand_and_status.rb +54 -12
  100. data/lib/requests.rb +2 -2
  101. data/lib/types_export.rb +66 -32
  102. metadata +70 -34
  103. data/lib/rcs/campaigns/rcs/types/upsert_rcs_opt_in.rb +0 -75
  104. data/lib/rcs/types/rcs_base_options.rb +0 -111
  105. data/lib/rcs/types/rcs_campaign_opt_in_method_enum.rb +0 -15
  106. data/lib/rcs/types/rcs_campaign_schema_extra_opt_in.rb +0 -71
  107. data/lib/rcs/types/rcs_campaign_schema_opt_in.rb +0 -71
@@ -0,0 +1,419 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../requests"
4
+ require_relative "../../types/sms_content"
5
+ require_relative "types/blast_sms_options"
6
+ require_relative "types/blast_sms_response"
7
+ require_relative "../../types/mms_content"
8
+ require_relative "types/blast_mms_options"
9
+ require_relative "types/blast_mms_response"
10
+ require_relative "../../types/rcs_validate_content"
11
+ require_relative "types/blast_rcs_options"
12
+ require_relative "types/blast_rcs_response"
13
+ require "async"
14
+
15
+ module Pinnacle
16
+ module Messages
17
+ class BlastClient
18
+ # @return [Pinnacle::RequestClient]
19
+ attr_reader :request_client
20
+
21
+ # @param request_client [Pinnacle::RequestClient]
22
+ # @return [Pinnacle::Messages::BlastClient]
23
+ def initialize(request_client:)
24
+ @request_client = request_client
25
+ end
26
+
27
+ # Send an SMS message to all contacts in an audience. <br>
28
+ # Messages are distributed evenly across the provided sender phone numbers. <br>
29
+ # Use the optional `schedule` parameter in `options` to schedule the blast for
30
+ # future delivery. When scheduled, the response will contain a `scheduleId`
31
+ # instead of blast details.
32
+ #
33
+ # @param audience_id [String] The audience ID to send the blast to. This identifier is a string that always
34
+ # begins with the prefix `aud_`, for example: `aud_abc123`. <br>
35
+ # You can create an audience via [the
36
+ # dashboard](https://app.pinnacle.sh/dashboard/audiences) or
37
+ # [API](/api-reference/audiences/create).
38
+ # @param senders [Array<String>] Array of phone numbers to send from in E.164 format. <br>
39
+ # Messages will be distributed evenly across these senders.
40
+ # > **Note:** Sandbox numbers cannot be used for blasts.
41
+ # @param message [Hash] Request of type Pinnacle::Types::SmsContent, as a Hash
42
+ # * :text (String)
43
+ # @param options [Hash] Additional settings to customize SMS blast delivery.Request of type Pinnacle::Messages::Blast::Types::BlastSmsOptions, as a Hash
44
+ # * :schedule (Hash)
45
+ # * :send_at (String)
46
+ # * :recurrence (String)
47
+ # * :timezone (String)
48
+ # * :end_date (String)
49
+ # @param request_options [Pinnacle::RequestOptions]
50
+ # @return [Pinnacle::Types::BlastDetails, Pinnacle::Types::ScheduledBlastDetails]
51
+ # @example
52
+ # api = Pinnacle::Client.new(
53
+ # base_url: "https://api.example.com",
54
+ # environment: Pinnacle::Environment::DEFAULT,
55
+ # api_key: "YOUR_API_KEY"
56
+ # )
57
+ # api.messages.blast.sms(
58
+ # audience_id: "aud_abc123",
59
+ # senders: ["+14155164736", "+14155164737"],
60
+ # message: { text: "Hello from Pinnacle!" }
61
+ # )
62
+ def sms(audience_id:, senders:, message:, options: nil, request_options: nil)
63
+ response = @request_client.conn.post do |req|
64
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
65
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
66
+ req.headers = {
67
+ **(req.headers || {}),
68
+ **@request_client.get_headers,
69
+ **(request_options&.additional_headers || {})
70
+ }.compact
71
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
72
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
73
+ end
74
+ req.body = {
75
+ **(request_options&.additional_body_parameters || {}),
76
+ audienceId: audience_id,
77
+ senders: senders,
78
+ message: message,
79
+ options: options
80
+ }.compact
81
+ req.url "#{@request_client.get_url(request_options: request_options)}/messages/blast/sms"
82
+ end
83
+ Pinnacle::Messages::Blast::Types::BlastSmsResponse.from_json(json_object: response.body)
84
+ end
85
+
86
+ # Send an MMS message to all contacts in an audience. <br>
87
+ # Messages are distributed evenly across the provided sender phone numbers. <br>
88
+ # Use the optional `schedule` parameter in `options` to schedule the blast for
89
+ # future delivery. When scheduled, the response will contain a `scheduleId`
90
+ # instead of blast details.
91
+ #
92
+ # @param audience_id [String] The audience ID to send the blast to. This identifier is a string that always
93
+ # begins with the prefix `aud_`, for example: `aud_abc123`. <br>
94
+ # You can create an audience via [the
95
+ # dashboard](https://app.pinnacle.sh/dashboard/audiences) or
96
+ # [API](/api-reference/audiences/create).
97
+ # @param senders [Array<String>] Array of phone numbers to send from in E.164 format. <br>
98
+ # Messages will be distributed evenly across these senders.
99
+ # > **Note:** Sandbox numbers cannot be used for blasts.
100
+ # @param message [Hash] Request of type Pinnacle::Types::MmsContent, as a Hash
101
+ # * :media_urls (Array<String>)
102
+ # * :text (String)
103
+ # @param options [Hash] Additional settings to customize MMS blast delivery.Request of type Pinnacle::Messages::Blast::Types::BlastMmsOptions, as a Hash
104
+ # * :validate (Boolean)
105
+ # * :schedule (Hash)
106
+ # * :send_at (String)
107
+ # * :recurrence (String)
108
+ # * :timezone (String)
109
+ # * :end_date (String)
110
+ # @param request_options [Pinnacle::RequestOptions]
111
+ # @return [Pinnacle::Types::BlastDetails, Pinnacle::Types::ScheduledBlastDetails]
112
+ # @example
113
+ # api = Pinnacle::Client.new(
114
+ # base_url: "https://api.example.com",
115
+ # environment: Pinnacle::Environment::DEFAULT,
116
+ # api_key: "YOUR_API_KEY"
117
+ # )
118
+ # api.messages.blast.mms(
119
+ # audience_id: "aud_abc123",
120
+ # senders: ["+14155164736", "+14155164737"],
121
+ # message: { media_urls: ["https://fastly.picsum.photos/id/941/300/300.jpg"], text: "Check out this image!" },
122
+ # options: { validate: true }
123
+ # )
124
+ def mms(audience_id:, senders:, message:, options: nil, request_options: nil)
125
+ response = @request_client.conn.post do |req|
126
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
127
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
128
+ req.headers = {
129
+ **(req.headers || {}),
130
+ **@request_client.get_headers,
131
+ **(request_options&.additional_headers || {})
132
+ }.compact
133
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
134
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
135
+ end
136
+ req.body = {
137
+ **(request_options&.additional_body_parameters || {}),
138
+ audienceId: audience_id,
139
+ senders: senders,
140
+ message: message,
141
+ options: options
142
+ }.compact
143
+ req.url "#{@request_client.get_url(request_options: request_options)}/messages/blast/mms"
144
+ end
145
+ Pinnacle::Messages::Blast::Types::BlastMmsResponse.from_json(json_object: response.body)
146
+ end
147
+
148
+ # Send an RCS message to all contacts in an audience. <br>
149
+ # Messages are distributed evenly across the provided RCS agents for load
150
+ # balancing. Requires active RCS agents and recipient devices that support RCS
151
+ # Business Messaging. <br>
152
+ # Use the optional `schedule` parameter in `options` to schedule the blast for
153
+ # future delivery. When scheduled, the response will contain a `scheduleId`
154
+ # instead of blast details.
155
+ #
156
+ # @param audience_id [String] The audience ID to send the blast to. This identifier is a string that always
157
+ # begins with the prefix `aud_`, for example: `aud_abc123`. <br>
158
+ # You can create an audience via [the
159
+ # dashboard](https://app.pinnacle.sh/dashboard/audiences) or
160
+ # [API](/api-reference/audiences/create).
161
+ # @param senders [Array<String>] Array of RCS agent IDs to send from. Each must be prefixed with `agent_`. <br>
162
+ # Messages will be evenly distributed across these agents.
163
+ # > **Note:** Test agents cannot be used for blasts.
164
+ # @param message [Pinnacle::Types::RichText, Pinnacle::Types::RcsValidateContentMedia, Pinnacle::Types::RichCards]
165
+ # @param options [Hash] Configure how your RCS blast is sent and tracked.Request of type Pinnacle::Messages::Blast::Types::BlastRcsOptions, as a Hash
166
+ # * :transcode (Boolean)
167
+ # * :validate (Boolean)
168
+ # * :standalone_card (Hash)
169
+ # * :orientation (Pinnacle::Messages::Blast::Types::BlastRcsRequestOptionsStandaloneCardOrientation)
170
+ # * :image_alignment (Pinnacle::Messages::Blast::Types::BlastRcsRequestOptionsStandaloneCardImageAlignment)
171
+ # * :schedule (Hash)
172
+ # * :send_at (String)
173
+ # * :recurrence (String)
174
+ # * :timezone (String)
175
+ # * :end_date (String)
176
+ # @param request_options [Pinnacle::RequestOptions]
177
+ # @return [Pinnacle::Types::BlastDetails, Pinnacle::Types::ScheduledBlastDetails]
178
+ # @example
179
+ # api = Pinnacle::Client.new(
180
+ # base_url: "https://api.example.com",
181
+ # environment: Pinnacle::Environment::DEFAULT,
182
+ # api_key: "YOUR_API_KEY"
183
+ # )
184
+ # api.messages.blast.rcs(
185
+ # audience_id: "aud_abc123",
186
+ # senders: ["agent_pinnacle", "agent_pinnacle2"],
187
+ # message: { quick_replies: , text: "Hello from Pinnacle RCS!" },
188
+ # options: { transcode: true, validate: true }
189
+ # )
190
+ def rcs(audience_id:, senders:, message:, options: nil, request_options: nil)
191
+ response = @request_client.conn.post do |req|
192
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
193
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
194
+ req.headers = {
195
+ **(req.headers || {}),
196
+ **@request_client.get_headers,
197
+ **(request_options&.additional_headers || {})
198
+ }.compact
199
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
200
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
201
+ end
202
+ req.body = {
203
+ **(request_options&.additional_body_parameters || {}),
204
+ audienceId: audience_id,
205
+ senders: senders,
206
+ message: message,
207
+ options: options
208
+ }.compact
209
+ req.url "#{@request_client.get_url(request_options: request_options)}/messages/blast/rcs"
210
+ end
211
+ Pinnacle::Messages::Blast::Types::BlastRcsResponse.from_json(json_object: response.body)
212
+ end
213
+ end
214
+
215
+ class AsyncBlastClient
216
+ # @return [Pinnacle::AsyncRequestClient]
217
+ attr_reader :request_client
218
+
219
+ # @param request_client [Pinnacle::AsyncRequestClient]
220
+ # @return [Pinnacle::Messages::AsyncBlastClient]
221
+ def initialize(request_client:)
222
+ @request_client = request_client
223
+ end
224
+
225
+ # Send an SMS message to all contacts in an audience. <br>
226
+ # Messages are distributed evenly across the provided sender phone numbers. <br>
227
+ # Use the optional `schedule` parameter in `options` to schedule the blast for
228
+ # future delivery. When scheduled, the response will contain a `scheduleId`
229
+ # instead of blast details.
230
+ #
231
+ # @param audience_id [String] The audience ID to send the blast to. This identifier is a string that always
232
+ # begins with the prefix `aud_`, for example: `aud_abc123`. <br>
233
+ # You can create an audience via [the
234
+ # dashboard](https://app.pinnacle.sh/dashboard/audiences) or
235
+ # [API](/api-reference/audiences/create).
236
+ # @param senders [Array<String>] Array of phone numbers to send from in E.164 format. <br>
237
+ # Messages will be distributed evenly across these senders.
238
+ # > **Note:** Sandbox numbers cannot be used for blasts.
239
+ # @param message [Hash] Request of type Pinnacle::Types::SmsContent, as a Hash
240
+ # * :text (String)
241
+ # @param options [Hash] Additional settings to customize SMS blast delivery.Request of type Pinnacle::Messages::Blast::Types::BlastSmsOptions, as a Hash
242
+ # * :schedule (Hash)
243
+ # * :send_at (String)
244
+ # * :recurrence (String)
245
+ # * :timezone (String)
246
+ # * :end_date (String)
247
+ # @param request_options [Pinnacle::RequestOptions]
248
+ # @return [Pinnacle::Types::BlastDetails, Pinnacle::Types::ScheduledBlastDetails]
249
+ # @example
250
+ # api = Pinnacle::Client.new(
251
+ # base_url: "https://api.example.com",
252
+ # environment: Pinnacle::Environment::DEFAULT,
253
+ # api_key: "YOUR_API_KEY"
254
+ # )
255
+ # api.messages.blast.sms(
256
+ # audience_id: "aud_abc123",
257
+ # senders: ["+14155164736", "+14155164737"],
258
+ # message: { text: "Hello from Pinnacle!" }
259
+ # )
260
+ def sms(audience_id:, senders:, message:, options: nil, request_options: nil)
261
+ Async do
262
+ response = @request_client.conn.post do |req|
263
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
264
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
265
+ req.headers = {
266
+ **(req.headers || {}),
267
+ **@request_client.get_headers,
268
+ **(request_options&.additional_headers || {})
269
+ }.compact
270
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
271
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
272
+ end
273
+ req.body = {
274
+ **(request_options&.additional_body_parameters || {}),
275
+ audienceId: audience_id,
276
+ senders: senders,
277
+ message: message,
278
+ options: options
279
+ }.compact
280
+ req.url "#{@request_client.get_url(request_options: request_options)}/messages/blast/sms"
281
+ end
282
+ Pinnacle::Messages::Blast::Types::BlastSmsResponse.from_json(json_object: response.body)
283
+ end
284
+ end
285
+
286
+ # Send an MMS message to all contacts in an audience. <br>
287
+ # Messages are distributed evenly across the provided sender phone numbers. <br>
288
+ # Use the optional `schedule` parameter in `options` to schedule the blast for
289
+ # future delivery. When scheduled, the response will contain a `scheduleId`
290
+ # instead of blast details.
291
+ #
292
+ # @param audience_id [String] The audience ID to send the blast to. This identifier is a string that always
293
+ # begins with the prefix `aud_`, for example: `aud_abc123`. <br>
294
+ # You can create an audience via [the
295
+ # dashboard](https://app.pinnacle.sh/dashboard/audiences) or
296
+ # [API](/api-reference/audiences/create).
297
+ # @param senders [Array<String>] Array of phone numbers to send from in E.164 format. <br>
298
+ # Messages will be distributed evenly across these senders.
299
+ # > **Note:** Sandbox numbers cannot be used for blasts.
300
+ # @param message [Hash] Request of type Pinnacle::Types::MmsContent, as a Hash
301
+ # * :media_urls (Array<String>)
302
+ # * :text (String)
303
+ # @param options [Hash] Additional settings to customize MMS blast delivery.Request of type Pinnacle::Messages::Blast::Types::BlastMmsOptions, as a Hash
304
+ # * :validate (Boolean)
305
+ # * :schedule (Hash)
306
+ # * :send_at (String)
307
+ # * :recurrence (String)
308
+ # * :timezone (String)
309
+ # * :end_date (String)
310
+ # @param request_options [Pinnacle::RequestOptions]
311
+ # @return [Pinnacle::Types::BlastDetails, Pinnacle::Types::ScheduledBlastDetails]
312
+ # @example
313
+ # api = Pinnacle::Client.new(
314
+ # base_url: "https://api.example.com",
315
+ # environment: Pinnacle::Environment::DEFAULT,
316
+ # api_key: "YOUR_API_KEY"
317
+ # )
318
+ # api.messages.blast.mms(
319
+ # audience_id: "aud_abc123",
320
+ # senders: ["+14155164736", "+14155164737"],
321
+ # message: { media_urls: ["https://fastly.picsum.photos/id/941/300/300.jpg"], text: "Check out this image!" },
322
+ # options: { validate: true }
323
+ # )
324
+ def mms(audience_id:, senders:, message:, options: nil, request_options: nil)
325
+ Async do
326
+ response = @request_client.conn.post do |req|
327
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
328
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
329
+ req.headers = {
330
+ **(req.headers || {}),
331
+ **@request_client.get_headers,
332
+ **(request_options&.additional_headers || {})
333
+ }.compact
334
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
335
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
336
+ end
337
+ req.body = {
338
+ **(request_options&.additional_body_parameters || {}),
339
+ audienceId: audience_id,
340
+ senders: senders,
341
+ message: message,
342
+ options: options
343
+ }.compact
344
+ req.url "#{@request_client.get_url(request_options: request_options)}/messages/blast/mms"
345
+ end
346
+ Pinnacle::Messages::Blast::Types::BlastMmsResponse.from_json(json_object: response.body)
347
+ end
348
+ end
349
+
350
+ # Send an RCS message to all contacts in an audience. <br>
351
+ # Messages are distributed evenly across the provided RCS agents for load
352
+ # balancing. Requires active RCS agents and recipient devices that support RCS
353
+ # Business Messaging. <br>
354
+ # Use the optional `schedule` parameter in `options` to schedule the blast for
355
+ # future delivery. When scheduled, the response will contain a `scheduleId`
356
+ # instead of blast details.
357
+ #
358
+ # @param audience_id [String] The audience ID to send the blast to. This identifier is a string that always
359
+ # begins with the prefix `aud_`, for example: `aud_abc123`. <br>
360
+ # You can create an audience via [the
361
+ # dashboard](https://app.pinnacle.sh/dashboard/audiences) or
362
+ # [API](/api-reference/audiences/create).
363
+ # @param senders [Array<String>] Array of RCS agent IDs to send from. Each must be prefixed with `agent_`. <br>
364
+ # Messages will be evenly distributed across these agents.
365
+ # > **Note:** Test agents cannot be used for blasts.
366
+ # @param message [Pinnacle::Types::RichText, Pinnacle::Types::RcsValidateContentMedia, Pinnacle::Types::RichCards]
367
+ # @param options [Hash] Configure how your RCS blast is sent and tracked.Request of type Pinnacle::Messages::Blast::Types::BlastRcsOptions, as a Hash
368
+ # * :transcode (Boolean)
369
+ # * :validate (Boolean)
370
+ # * :standalone_card (Hash)
371
+ # * :orientation (Pinnacle::Messages::Blast::Types::BlastRcsRequestOptionsStandaloneCardOrientation)
372
+ # * :image_alignment (Pinnacle::Messages::Blast::Types::BlastRcsRequestOptionsStandaloneCardImageAlignment)
373
+ # * :schedule (Hash)
374
+ # * :send_at (String)
375
+ # * :recurrence (String)
376
+ # * :timezone (String)
377
+ # * :end_date (String)
378
+ # @param request_options [Pinnacle::RequestOptions]
379
+ # @return [Pinnacle::Types::BlastDetails, Pinnacle::Types::ScheduledBlastDetails]
380
+ # @example
381
+ # api = Pinnacle::Client.new(
382
+ # base_url: "https://api.example.com",
383
+ # environment: Pinnacle::Environment::DEFAULT,
384
+ # api_key: "YOUR_API_KEY"
385
+ # )
386
+ # api.messages.blast.rcs(
387
+ # audience_id: "aud_abc123",
388
+ # senders: ["agent_pinnacle", "agent_pinnacle2"],
389
+ # message: { quick_replies: , text: "Hello from Pinnacle RCS!" },
390
+ # options: { transcode: true, validate: true }
391
+ # )
392
+ def rcs(audience_id:, senders:, message:, options: nil, request_options: nil)
393
+ Async do
394
+ response = @request_client.conn.post do |req|
395
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
396
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
397
+ req.headers = {
398
+ **(req.headers || {}),
399
+ **@request_client.get_headers,
400
+ **(request_options&.additional_headers || {})
401
+ }.compact
402
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
403
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
404
+ end
405
+ req.body = {
406
+ **(request_options&.additional_body_parameters || {}),
407
+ audienceId: audience_id,
408
+ senders: senders,
409
+ message: message,
410
+ options: options
411
+ }.compact
412
+ req.url "#{@request_client.get_url(request_options: request_options)}/messages/blast/rcs"
413
+ end
414
+ Pinnacle::Messages::Blast::Types::BlastRcsResponse.from_json(json_object: response.body)
415
+ end
416
+ end
417
+ end
418
+ end
419
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../types/message_schedule"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module Pinnacle
8
+ module Messages
9
+ module Blast
10
+ module Types
11
+ # Additional settings to customize MMS blast delivery.
12
+ class BlastMmsOptions
13
+ # @return [Boolean] Set to true to validate the message before sending. <br>
14
+ # If validation fails, the blast is not sent.
15
+ attr_reader :validate
16
+ # @return [Pinnacle::Types::MessageSchedule]
17
+ attr_reader :schedule
18
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
19
+ attr_reader :additional_properties
20
+ # @return [Object]
21
+ attr_reader :_field_set
22
+ protected :_field_set
23
+
24
+ OMIT = Object.new
25
+
26
+ # @param validate [Boolean] Set to true to validate the message before sending. <br>
27
+ # If validation fails, the blast is not sent.
28
+ # @param schedule [Pinnacle::Types::MessageSchedule]
29
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
+ # @return [Pinnacle::Messages::Blast::Types::BlastMmsOptions]
31
+ def initialize(validate: OMIT, schedule: OMIT, additional_properties: nil)
32
+ @validate = validate if validate != OMIT
33
+ @schedule = schedule if schedule != OMIT
34
+ @additional_properties = additional_properties
35
+ @_field_set = { "validate": validate, "schedule": schedule }.reject do |_k, v|
36
+ v == OMIT
37
+ end
38
+ end
39
+
40
+ # Deserialize a JSON object to an instance of BlastMmsOptions
41
+ #
42
+ # @param json_object [String]
43
+ # @return [Pinnacle::Messages::Blast::Types::BlastMmsOptions]
44
+ def self.from_json(json_object:)
45
+ struct = JSON.parse(json_object, object_class: OpenStruct)
46
+ parsed_json = JSON.parse(json_object)
47
+ validate = parsed_json["validate"]
48
+ if parsed_json["schedule"].nil?
49
+ schedule = nil
50
+ else
51
+ schedule = parsed_json["schedule"].to_json
52
+ schedule = Pinnacle::Types::MessageSchedule.from_json(json_object: schedule)
53
+ end
54
+ new(
55
+ validate: validate,
56
+ schedule: schedule,
57
+ additional_properties: struct
58
+ )
59
+ end
60
+
61
+ # Serialize an instance of BlastMmsOptions to a JSON object
62
+ #
63
+ # @return [String]
64
+ def to_json(*_args)
65
+ @_field_set&.to_json
66
+ end
67
+
68
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
69
+ # hash and check each fields type against the current object's property
70
+ # definitions.
71
+ #
72
+ # @param obj [Object]
73
+ # @return [Void]
74
+ def self.validate_raw(obj:)
75
+ obj.validate&.is_a?(Boolean) != false || raise("Passed value for field obj.validate is not the expected type, validation failed.")
76
+ obj.schedule.nil? || Pinnacle::Types::MessageSchedule.validate_raw(obj: obj.schedule)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "../../../types/blast_details"
5
+ require_relative "../../../types/scheduled_blast_details"
6
+
7
+ module Pinnacle
8
+ module Messages
9
+ module Blast
10
+ module Types
11
+ class BlastMmsResponse
12
+ # Deserialize a JSON object to an instance of BlastMmsResponse
13
+ #
14
+ # @param json_object [String]
15
+ # @return [Pinnacle::Messages::Blast::Types::BlastMmsResponse]
16
+ def self.from_json(json_object:)
17
+ struct = JSON.parse(json_object, object_class: OpenStruct)
18
+ begin
19
+ Pinnacle::Types::BlastDetails.validate_raw(obj: struct)
20
+ return Pinnacle::Types::BlastDetails.from_json(json_object: struct) unless struct.nil?
21
+
22
+ return nil
23
+ rescue StandardError
24
+ # noop
25
+ end
26
+ begin
27
+ Pinnacle::Types::ScheduledBlastDetails.validate_raw(obj: struct)
28
+ return Pinnacle::Types::ScheduledBlastDetails.from_json(json_object: struct) unless struct.nil?
29
+
30
+ return nil
31
+ rescue StandardError
32
+ # noop
33
+ end
34
+ struct
35
+ end
36
+
37
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
38
+ # hash and check each fields type against the current object's property
39
+ # definitions.
40
+ #
41
+ # @param obj [Object]
42
+ # @return [Void]
43
+ def self.validate_raw(obj:)
44
+ begin
45
+ return Pinnacle::Types::BlastDetails.validate_raw(obj: obj)
46
+ rescue StandardError
47
+ # noop
48
+ end
49
+ begin
50
+ return Pinnacle::Types::ScheduledBlastDetails.validate_raw(obj: obj)
51
+ rescue StandardError
52
+ # noop
53
+ end
54
+ raise("Passed value matched no type within the union, validation failed.")
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "blast_rcs_request_options_standalone_card"
4
+ require_relative "../../../types/message_schedule"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module Pinnacle
9
+ module Messages
10
+ module Blast
11
+ module Types
12
+ # Configure how your RCS blast is sent and tracked.
13
+ class BlastRcsOptions
14
+ # @return [Boolean] Media files and card media will be transcoded to a supported RCS format. This
15
+ # adds a small delay to sending the message. Ignored for rich text messages.
16
+ attr_reader :transcode
17
+ # @return [Boolean] Validate your message for any unsupported files. <br>
18
+ # If failed, errors will be thrown and the blast will not be sent.
19
+ attr_reader :validate
20
+ # @return [Pinnacle::Messages::Blast::Types::BlastRcsRequestOptionsStandaloneCard] Configure standalone card layout options for enhanced visual presentation.
21
+ # > **⚠️ Important Restriction**
22
+ # >
23
+ # > This option is **only valid for single card messages**. Using it with multiple
24
+ # cards will cause the request to fail with a validation error.
25
+ attr_reader :standalone_card
26
+ # @return [Pinnacle::Types::MessageSchedule]
27
+ attr_reader :schedule
28
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
29
+ attr_reader :additional_properties
30
+ # @return [Object]
31
+ attr_reader :_field_set
32
+ protected :_field_set
33
+
34
+ OMIT = Object.new
35
+
36
+ # @param transcode [Boolean] Media files and card media will be transcoded to a supported RCS format. This
37
+ # adds a small delay to sending the message. Ignored for rich text messages.
38
+ # @param validate [Boolean] Validate your message for any unsupported files. <br>
39
+ # If failed, errors will be thrown and the blast will not be sent.
40
+ # @param standalone_card [Pinnacle::Messages::Blast::Types::BlastRcsRequestOptionsStandaloneCard] Configure standalone card layout options for enhanced visual presentation.
41
+ # > **⚠️ Important Restriction**
42
+ # >
43
+ # > This option is **only valid for single card messages**. Using it with multiple
44
+ # cards will cause the request to fail with a validation error.
45
+ # @param schedule [Pinnacle::Types::MessageSchedule]
46
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
47
+ # @return [Pinnacle::Messages::Blast::Types::BlastRcsOptions]
48
+ def initialize(transcode: OMIT, validate: OMIT, standalone_card: OMIT, schedule: OMIT,
49
+ additional_properties: nil)
50
+ @transcode = transcode if transcode != OMIT
51
+ @validate = validate if validate != OMIT
52
+ @standalone_card = standalone_card if standalone_card != OMIT
53
+ @schedule = schedule if schedule != OMIT
54
+ @additional_properties = additional_properties
55
+ @_field_set = {
56
+ "transcode": transcode,
57
+ "validate": validate,
58
+ "standalone_card": standalone_card,
59
+ "schedule": schedule
60
+ }.reject do |_k, v|
61
+ v == OMIT
62
+ end
63
+ end
64
+
65
+ # Deserialize a JSON object to an instance of BlastRcsOptions
66
+ #
67
+ # @param json_object [String]
68
+ # @return [Pinnacle::Messages::Blast::Types::BlastRcsOptions]
69
+ def self.from_json(json_object:)
70
+ struct = JSON.parse(json_object, object_class: OpenStruct)
71
+ parsed_json = JSON.parse(json_object)
72
+ transcode = parsed_json["transcode"]
73
+ validate = parsed_json["validate"]
74
+ if parsed_json["standalone_card"].nil?
75
+ standalone_card = nil
76
+ else
77
+ standalone_card = parsed_json["standalone_card"].to_json
78
+ standalone_card = Pinnacle::Messages::Blast::Types::BlastRcsRequestOptionsStandaloneCard.from_json(json_object: standalone_card)
79
+ end
80
+ if parsed_json["schedule"].nil?
81
+ schedule = nil
82
+ else
83
+ schedule = parsed_json["schedule"].to_json
84
+ schedule = Pinnacle::Types::MessageSchedule.from_json(json_object: schedule)
85
+ end
86
+ new(
87
+ transcode: transcode,
88
+ validate: validate,
89
+ standalone_card: standalone_card,
90
+ schedule: schedule,
91
+ additional_properties: struct
92
+ )
93
+ end
94
+
95
+ # Serialize an instance of BlastRcsOptions to a JSON object
96
+ #
97
+ # @return [String]
98
+ def to_json(*_args)
99
+ @_field_set&.to_json
100
+ end
101
+
102
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
103
+ # hash and check each fields type against the current object's property
104
+ # definitions.
105
+ #
106
+ # @param obj [Object]
107
+ # @return [Void]
108
+ def self.validate_raw(obj:)
109
+ obj.transcode&.is_a?(Boolean) != false || raise("Passed value for field obj.transcode is not the expected type, validation failed.")
110
+ obj.validate&.is_a?(Boolean) != false || raise("Passed value for field obj.validate is not the expected type, validation failed.")
111
+ obj.standalone_card.nil? || Pinnacle::Messages::Blast::Types::BlastRcsRequestOptionsStandaloneCard.validate_raw(obj: obj.standalone_card)
112
+ obj.schedule.nil? || Pinnacle::Types::MessageSchedule.validate_raw(obj: obj.schedule)
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end