rcs 2.0.0 → 2.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b62f856fc547382d4d1cf18aa5d06d9746cc02480ed3890318a707c2fba8794
4
- data.tar.gz: 9403e66a841948733781b0eddade27c3108cf169e13af030edfe309fea50b530
3
+ metadata.gz: 9ae139d400bbfa1ab360ba9c8330f3cdf286e7ef16772032ff9dba8be4b54f21
4
+ data.tar.gz: f2041515877561cffa19ad82eda057813788dd59f5e6423b89005197085f98ec
5
5
  SHA512:
6
- metadata.gz: 1fcb90da1af1f5cbbc8c429f225199b402f3738455295a21570169cd5a2c77464f57378e90d0bed2f297980d18bcd6c6dac92df7a842f96b8e695c4d05f14592
7
- data.tar.gz: 4553c27971714a7fbd92a07002e0e75248463a4dacb30a89a2f9eb570599795bcebba4764f6234c84832b8632b56cf7408ceebebf9cbf4438721a3c1650ac359
6
+ metadata.gz: 9923fb9be738fd30e395689c60cddd25046dbc073bdf1af1792cb2260e7e43bdd1da99d9e74a7c8fd344d3c34aba7375cdcbb1749e8d35bad1779e759f71c574
7
+ data.tar.gz: fa778ca98424e492675eb4906a908b97dabeacfa4c5fe72c0f79d88ae562e00a838b94a1cafb3902bf940a0e0697cc467d77a476b45a91d50fb86e8913938954
@@ -0,0 +1,347 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../requests"
4
+ require_relative "types/audiences_get_response"
5
+ require_relative "../types/audience_count_only"
6
+ require_relative "../types/delete_audience_response"
7
+ require "async"
8
+
9
+ module Pinnacle
10
+ class AudiencesClient
11
+ # @return [Pinnacle::RequestClient]
12
+ attr_reader :request_client
13
+
14
+ # @param request_client [Pinnacle::RequestClient]
15
+ # @return [Pinnacle::AudiencesClient]
16
+ def initialize(request_client:)
17
+ @request_client = request_client
18
+ end
19
+
20
+ # Retrieve an audience by ID with optional pagination.
21
+ #
22
+ # @param id [String] Audience ID. This identifier is a string that always begins with the prefix
23
+ # `aud_`, for example: `aud_abc123`.
24
+ # @param page [Integer] Page number. If provided with or without limit, returns paginated contacts.
25
+ # @param limit [Integer] Items per page. If provided with or without page, returns paginated contacts.
26
+ # @param request_options [Pinnacle::RequestOptions]
27
+ # @return [Pinnacle::Types::AudienceWithPagination, Pinnacle::Types::AudienceCountOnly]
28
+ # @example
29
+ # api = Pinnacle::Client.new(
30
+ # base_url: "https://api.example.com",
31
+ # environment: Pinnacle::Environment::DEFAULT,
32
+ # api_key: "YOUR_API_KEY"
33
+ # )
34
+ # api.audiences.get(id: "aud_abc123")
35
+ def get(id:, page: nil, limit: nil, request_options: nil)
36
+ response = @request_client.conn.get do |req|
37
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
38
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
39
+ req.headers = {
40
+ **(req.headers || {}),
41
+ **@request_client.get_headers,
42
+ **(request_options&.additional_headers || {})
43
+ }.compact
44
+ req.params = {
45
+ **(request_options&.additional_query_parameters || {}),
46
+ "id": id,
47
+ "page": page,
48
+ "limit": limit
49
+ }.compact
50
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
51
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
52
+ end
53
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences"
54
+ end
55
+ Pinnacle::Audiences::Types::AudiencesGetResponse.from_json(json_object: response.body)
56
+ end
57
+
58
+ # Create a new audience with optional initial contacts. Phone numbers that don't
59
+ # exist will be auto-created as contacts.
60
+ #
61
+ # @param name [String] Audience name.
62
+ # @param description [String] Audience description.
63
+ # @param contacts [Array<String>] Optional array of phone numbers (E.164 format) or contact IDs.
64
+ # @param request_options [Pinnacle::RequestOptions]
65
+ # @return [Pinnacle::Types::AudienceCountOnly]
66
+ # @example
67
+ # api = Pinnacle::Client.new(
68
+ # base_url: "https://api.example.com",
69
+ # environment: Pinnacle::Environment::DEFAULT,
70
+ # api_key: "YOUR_API_KEY"
71
+ # )
72
+ # api.audiences.create(name: "Marketing Campaign Q1", description: "Contacts for Q1 marketing push")
73
+ def create(name:, description: nil, contacts: nil, request_options: nil)
74
+ response = @request_client.conn.post do |req|
75
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
76
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
77
+ req.headers = {
78
+ **(req.headers || {}),
79
+ **@request_client.get_headers,
80
+ **(request_options&.additional_headers || {})
81
+ }.compact
82
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
83
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
84
+ end
85
+ req.body = {
86
+ **(request_options&.additional_body_parameters || {}),
87
+ name: name,
88
+ description: description,
89
+ contacts: contacts
90
+ }.compact
91
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences"
92
+ end
93
+ Pinnacle::Types::AudienceCountOnly.from_json(json_object: response.body)
94
+ end
95
+
96
+ # Permanently delete an audience and all its contact associations.
97
+ # Note: This will NOT delete the contacts themselves, only the audience and its
98
+ # memberships.
99
+ #
100
+ # @param id [String] Audience ID. This identifier is a string that always begins with the prefix
101
+ # `aud_`, for example: `aud_abc123`.
102
+ # @param request_options [Pinnacle::RequestOptions]
103
+ # @return [Pinnacle::Types::DeleteAudienceResponse]
104
+ # @example
105
+ # api = Pinnacle::Client.new(
106
+ # base_url: "https://api.example.com",
107
+ # environment: Pinnacle::Environment::DEFAULT,
108
+ # api_key: "YOUR_API_KEY"
109
+ # )
110
+ # api.audiences.delete(id: "aud_abc123")
111
+ def delete(id:, request_options: nil)
112
+ response = @request_client.conn.delete do |req|
113
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
114
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
115
+ req.headers = {
116
+ **(req.headers || {}),
117
+ **@request_client.get_headers,
118
+ **(request_options&.additional_headers || {})
119
+ }.compact
120
+ req.params = { **(request_options&.additional_query_parameters || {}), "id": id }.compact
121
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
122
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
123
+ end
124
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences"
125
+ end
126
+ Pinnacle::Types::DeleteAudienceResponse.from_json(json_object: response.body)
127
+ end
128
+
129
+ # Update audience metadata. This endpoint does NOT modify contacts.
130
+ # To add or remove contacts, use the [Add
131
+ # Contacts](/api-reference/audiences/add-contacts) or [Remove
132
+ # Contacts](/api-reference/audiences/remove-contacts) endpoints.
133
+ #
134
+ # @param id [String] Audience ID to update. This identifier is a string that always begins with the
135
+ # prefix `aud_`, for example: `aud_abc123`.
136
+ # @param name [String] New audience name.
137
+ # @param description [String] New audience description.
138
+ # @param request_options [Pinnacle::RequestOptions]
139
+ # @return [Pinnacle::Types::AudienceCountOnly]
140
+ # @example
141
+ # api = Pinnacle::Client.new(
142
+ # base_url: "https://api.example.com",
143
+ # environment: Pinnacle::Environment::DEFAULT,
144
+ # api_key: "YOUR_API_KEY"
145
+ # )
146
+ # api.audiences.update(
147
+ # id: "aud_abc123",
148
+ # name: "Updated Audience Name",
149
+ # description: "New description"
150
+ # )
151
+ def update(id:, name: nil, description: nil, request_options: nil)
152
+ response = @request_client.conn.patch do |req|
153
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
154
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
155
+ req.headers = {
156
+ **(req.headers || {}),
157
+ **@request_client.get_headers,
158
+ **(request_options&.additional_headers || {})
159
+ }.compact
160
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
161
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
162
+ end
163
+ req.body = {
164
+ **(request_options&.additional_body_parameters || {}),
165
+ id: id,
166
+ name: name,
167
+ description: description
168
+ }.compact
169
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences"
170
+ end
171
+ Pinnacle::Types::AudienceCountOnly.from_json(json_object: response.body)
172
+ end
173
+ end
174
+
175
+ class AsyncAudiencesClient
176
+ # @return [Pinnacle::AsyncRequestClient]
177
+ attr_reader :request_client
178
+
179
+ # @param request_client [Pinnacle::AsyncRequestClient]
180
+ # @return [Pinnacle::AsyncAudiencesClient]
181
+ def initialize(request_client:)
182
+ @request_client = request_client
183
+ end
184
+
185
+ # Retrieve an audience by ID with optional pagination.
186
+ #
187
+ # @param id [String] Audience ID. This identifier is a string that always begins with the prefix
188
+ # `aud_`, for example: `aud_abc123`.
189
+ # @param page [Integer] Page number. If provided with or without limit, returns paginated contacts.
190
+ # @param limit [Integer] Items per page. If provided with or without page, returns paginated contacts.
191
+ # @param request_options [Pinnacle::RequestOptions]
192
+ # @return [Pinnacle::Types::AudienceWithPagination, Pinnacle::Types::AudienceCountOnly]
193
+ # @example
194
+ # api = Pinnacle::Client.new(
195
+ # base_url: "https://api.example.com",
196
+ # environment: Pinnacle::Environment::DEFAULT,
197
+ # api_key: "YOUR_API_KEY"
198
+ # )
199
+ # api.audiences.get(id: "aud_abc123")
200
+ def get(id:, page: nil, limit: nil, request_options: nil)
201
+ Async do
202
+ response = @request_client.conn.get do |req|
203
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
204
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
205
+ req.headers = {
206
+ **(req.headers || {}),
207
+ **@request_client.get_headers,
208
+ **(request_options&.additional_headers || {})
209
+ }.compact
210
+ req.params = {
211
+ **(request_options&.additional_query_parameters || {}),
212
+ "id": id,
213
+ "page": page,
214
+ "limit": limit
215
+ }.compact
216
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
217
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
218
+ end
219
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences"
220
+ end
221
+ Pinnacle::Audiences::Types::AudiencesGetResponse.from_json(json_object: response.body)
222
+ end
223
+ end
224
+
225
+ # Create a new audience with optional initial contacts. Phone numbers that don't
226
+ # exist will be auto-created as contacts.
227
+ #
228
+ # @param name [String] Audience name.
229
+ # @param description [String] Audience description.
230
+ # @param contacts [Array<String>] Optional array of phone numbers (E.164 format) or contact IDs.
231
+ # @param request_options [Pinnacle::RequestOptions]
232
+ # @return [Pinnacle::Types::AudienceCountOnly]
233
+ # @example
234
+ # api = Pinnacle::Client.new(
235
+ # base_url: "https://api.example.com",
236
+ # environment: Pinnacle::Environment::DEFAULT,
237
+ # api_key: "YOUR_API_KEY"
238
+ # )
239
+ # api.audiences.create(name: "Marketing Campaign Q1", description: "Contacts for Q1 marketing push")
240
+ def create(name:, description: nil, contacts: nil, request_options: nil)
241
+ Async do
242
+ response = @request_client.conn.post do |req|
243
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
244
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
245
+ req.headers = {
246
+ **(req.headers || {}),
247
+ **@request_client.get_headers,
248
+ **(request_options&.additional_headers || {})
249
+ }.compact
250
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
251
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
252
+ end
253
+ req.body = {
254
+ **(request_options&.additional_body_parameters || {}),
255
+ name: name,
256
+ description: description,
257
+ contacts: contacts
258
+ }.compact
259
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences"
260
+ end
261
+ Pinnacle::Types::AudienceCountOnly.from_json(json_object: response.body)
262
+ end
263
+ end
264
+
265
+ # Permanently delete an audience and all its contact associations.
266
+ # Note: This will NOT delete the contacts themselves, only the audience and its
267
+ # memberships.
268
+ #
269
+ # @param id [String] Audience ID. This identifier is a string that always begins with the prefix
270
+ # `aud_`, for example: `aud_abc123`.
271
+ # @param request_options [Pinnacle::RequestOptions]
272
+ # @return [Pinnacle::Types::DeleteAudienceResponse]
273
+ # @example
274
+ # api = Pinnacle::Client.new(
275
+ # base_url: "https://api.example.com",
276
+ # environment: Pinnacle::Environment::DEFAULT,
277
+ # api_key: "YOUR_API_KEY"
278
+ # )
279
+ # api.audiences.delete(id: "aud_abc123")
280
+ def delete(id:, request_options: nil)
281
+ Async do
282
+ response = @request_client.conn.delete do |req|
283
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
284
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
285
+ req.headers = {
286
+ **(req.headers || {}),
287
+ **@request_client.get_headers,
288
+ **(request_options&.additional_headers || {})
289
+ }.compact
290
+ req.params = { **(request_options&.additional_query_parameters || {}), "id": id }.compact
291
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
292
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
293
+ end
294
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences"
295
+ end
296
+ Pinnacle::Types::DeleteAudienceResponse.from_json(json_object: response.body)
297
+ end
298
+ end
299
+
300
+ # Update audience metadata. This endpoint does NOT modify contacts.
301
+ # To add or remove contacts, use the [Add
302
+ # Contacts](/api-reference/audiences/add-contacts) or [Remove
303
+ # Contacts](/api-reference/audiences/remove-contacts) endpoints.
304
+ #
305
+ # @param id [String] Audience ID to update. This identifier is a string that always begins with the
306
+ # prefix `aud_`, for example: `aud_abc123`.
307
+ # @param name [String] New audience name.
308
+ # @param description [String] New audience description.
309
+ # @param request_options [Pinnacle::RequestOptions]
310
+ # @return [Pinnacle::Types::AudienceCountOnly]
311
+ # @example
312
+ # api = Pinnacle::Client.new(
313
+ # base_url: "https://api.example.com",
314
+ # environment: Pinnacle::Environment::DEFAULT,
315
+ # api_key: "YOUR_API_KEY"
316
+ # )
317
+ # api.audiences.update(
318
+ # id: "aud_abc123",
319
+ # name: "Updated Audience Name",
320
+ # description: "New description"
321
+ # )
322
+ def update(id:, name: nil, description: nil, request_options: nil)
323
+ Async do
324
+ response = @request_client.conn.patch do |req|
325
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
326
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
327
+ req.headers = {
328
+ **(req.headers || {}),
329
+ **@request_client.get_headers,
330
+ **(request_options&.additional_headers || {})
331
+ }.compact
332
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
333
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
334
+ end
335
+ req.body = {
336
+ **(request_options&.additional_body_parameters || {}),
337
+ id: id,
338
+ name: name,
339
+ description: description
340
+ }.compact
341
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences"
342
+ end
343
+ Pinnacle::Types::AudienceCountOnly.from_json(json_object: response.body)
344
+ end
345
+ end
346
+ end
347
+ end
@@ -0,0 +1,173 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../requests"
4
+ require_relative "../../types/audience_count_only"
5
+ require "async"
6
+
7
+ module Pinnacle
8
+ module Audiences
9
+ class ContactsClient
10
+ # @return [Pinnacle::RequestClient]
11
+ attr_reader :request_client
12
+
13
+ # @param request_client [Pinnacle::RequestClient]
14
+ # @return [Pinnacle::Audiences::ContactsClient]
15
+ def initialize(request_client:)
16
+ @request_client = request_client
17
+ end
18
+
19
+ # Remove contacts from an existing audience. This operation is idempotent.
20
+ # - Only removes contacts that exist in the audience
21
+ # - Contacts not in the audience are ignored
22
+ #
23
+ # @param id [String] Audience ID. This identifier is a string that always begins with the prefix
24
+ # `aud_`, for example: `aud_abc123`.
25
+ # @param contacts [Array<String>] Array of phone numbers (E.164 format) or contact IDs (minimum 1 item).
26
+ # @param request_options [Pinnacle::RequestOptions]
27
+ # @return [Pinnacle::Types::AudienceCountOnly]
28
+ # @example
29
+ # api = Pinnacle::Client.new(
30
+ # base_url: "https://api.example.com",
31
+ # environment: Pinnacle::Environment::DEFAULT,
32
+ # api_key: "YOUR_API_KEY"
33
+ # )
34
+ # api.audiences.contacts.remove(id: "aud_abc123", contacts: ["+12125551234", "co_def456"])
35
+ def remove(id:, contacts:, request_options: nil)
36
+ response = @request_client.conn.delete do |req|
37
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
38
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
39
+ req.headers = {
40
+ **(req.headers || {}),
41
+ **@request_client.get_headers,
42
+ **(request_options&.additional_headers || {})
43
+ }.compact
44
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
45
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
46
+ end
47
+ req.body = { **(request_options&.additional_body_parameters || {}), id: id, contacts: contacts }.compact
48
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences/contacts"
49
+ end
50
+ Pinnacle::Types::AudienceCountOnly.from_json(json_object: response.body)
51
+ end
52
+
53
+ # Add contacts to an existing audience. This operation is additive and idempotent.
54
+ # - Phone numbers that don't exist will be auto-created as contacts
55
+ # - Duplicate adds are ignored
56
+ # - Contacts already in the audience are ignored
57
+ #
58
+ # @param id [String] Audience ID. This identifier is a string that always begins with the prefix
59
+ # `aud_`, for example: `aud_abc123`.
60
+ # @param contacts [Array<String>] Array of phone numbers (E.164 format) or contact IDs (minimum 1 item).
61
+ # @param request_options [Pinnacle::RequestOptions]
62
+ # @return [Pinnacle::Types::AudienceCountOnly]
63
+ # @example
64
+ # api = Pinnacle::Client.new(
65
+ # base_url: "https://api.example.com",
66
+ # environment: Pinnacle::Environment::DEFAULT,
67
+ # api_key: "YOUR_API_KEY"
68
+ # )
69
+ # api.audiences.contacts.add(id: "aud_abc123", contacts: ["+12125551234", "co_def456", "+13105551234"])
70
+ def add(id:, contacts:, request_options: nil)
71
+ response = @request_client.conn.patch do |req|
72
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
73
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
74
+ req.headers = {
75
+ **(req.headers || {}),
76
+ **@request_client.get_headers,
77
+ **(request_options&.additional_headers || {})
78
+ }.compact
79
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
80
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
81
+ end
82
+ req.body = { **(request_options&.additional_body_parameters || {}), id: id, contacts: contacts }.compact
83
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences/contacts"
84
+ end
85
+ Pinnacle::Types::AudienceCountOnly.from_json(json_object: response.body)
86
+ end
87
+ end
88
+
89
+ class AsyncContactsClient
90
+ # @return [Pinnacle::AsyncRequestClient]
91
+ attr_reader :request_client
92
+
93
+ # @param request_client [Pinnacle::AsyncRequestClient]
94
+ # @return [Pinnacle::Audiences::AsyncContactsClient]
95
+ def initialize(request_client:)
96
+ @request_client = request_client
97
+ end
98
+
99
+ # Remove contacts from an existing audience. This operation is idempotent.
100
+ # - Only removes contacts that exist in the audience
101
+ # - Contacts not in the audience are ignored
102
+ #
103
+ # @param id [String] Audience ID. This identifier is a string that always begins with the prefix
104
+ # `aud_`, for example: `aud_abc123`.
105
+ # @param contacts [Array<String>] Array of phone numbers (E.164 format) or contact IDs (minimum 1 item).
106
+ # @param request_options [Pinnacle::RequestOptions]
107
+ # @return [Pinnacle::Types::AudienceCountOnly]
108
+ # @example
109
+ # api = Pinnacle::Client.new(
110
+ # base_url: "https://api.example.com",
111
+ # environment: Pinnacle::Environment::DEFAULT,
112
+ # api_key: "YOUR_API_KEY"
113
+ # )
114
+ # api.audiences.contacts.remove(id: "aud_abc123", contacts: ["+12125551234", "co_def456"])
115
+ def remove(id:, contacts:, request_options: nil)
116
+ Async do
117
+ response = @request_client.conn.delete do |req|
118
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
119
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
120
+ req.headers = {
121
+ **(req.headers || {}),
122
+ **@request_client.get_headers,
123
+ **(request_options&.additional_headers || {})
124
+ }.compact
125
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
126
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
127
+ end
128
+ req.body = { **(request_options&.additional_body_parameters || {}), id: id, contacts: contacts }.compact
129
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences/contacts"
130
+ end
131
+ Pinnacle::Types::AudienceCountOnly.from_json(json_object: response.body)
132
+ end
133
+ end
134
+
135
+ # Add contacts to an existing audience. This operation is additive and idempotent.
136
+ # - Phone numbers that don't exist will be auto-created as contacts
137
+ # - Duplicate adds are ignored
138
+ # - Contacts already in the audience are ignored
139
+ #
140
+ # @param id [String] Audience ID. This identifier is a string that always begins with the prefix
141
+ # `aud_`, for example: `aud_abc123`.
142
+ # @param contacts [Array<String>] Array of phone numbers (E.164 format) or contact IDs (minimum 1 item).
143
+ # @param request_options [Pinnacle::RequestOptions]
144
+ # @return [Pinnacle::Types::AudienceCountOnly]
145
+ # @example
146
+ # api = Pinnacle::Client.new(
147
+ # base_url: "https://api.example.com",
148
+ # environment: Pinnacle::Environment::DEFAULT,
149
+ # api_key: "YOUR_API_KEY"
150
+ # )
151
+ # api.audiences.contacts.add(id: "aud_abc123", contacts: ["+12125551234", "co_def456", "+13105551234"])
152
+ def add(id:, contacts:, request_options: nil)
153
+ Async do
154
+ response = @request_client.conn.patch do |req|
155
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
156
+ req.headers["PINNACLE-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
157
+ req.headers = {
158
+ **(req.headers || {}),
159
+ **@request_client.get_headers,
160
+ **(request_options&.additional_headers || {})
161
+ }.compact
162
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
163
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
164
+ end
165
+ req.body = { **(request_options&.additional_body_parameters || {}), id: id, contacts: contacts }.compact
166
+ req.url "#{@request_client.get_url(request_options: request_options)}/audiences/contacts"
167
+ end
168
+ Pinnacle::Types::AudienceCountOnly.from_json(json_object: response.body)
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "../../types/audience_with_pagination"
5
+ require_relative "../../types/audience_count_only"
6
+
7
+ module Pinnacle
8
+ module Audiences
9
+ module Types
10
+ class AudiencesGetResponse
11
+ # Deserialize a JSON object to an instance of AudiencesGetResponse
12
+ #
13
+ # @param json_object [String]
14
+ # @return [Pinnacle::Audiences::Types::AudiencesGetResponse]
15
+ def self.from_json(json_object:)
16
+ struct = JSON.parse(json_object, object_class: OpenStruct)
17
+ begin
18
+ Pinnacle::Types::AudienceWithPagination.validate_raw(obj: struct)
19
+ return Pinnacle::Types::AudienceWithPagination.from_json(json_object: struct) unless struct.nil?
20
+
21
+ return nil
22
+ rescue StandardError
23
+ # noop
24
+ end
25
+ begin
26
+ Pinnacle::Types::AudienceCountOnly.validate_raw(obj: struct)
27
+ return Pinnacle::Types::AudienceCountOnly.from_json(json_object: struct) unless struct.nil?
28
+
29
+ return nil
30
+ rescue StandardError
31
+ # noop
32
+ end
33
+ struct
34
+ end
35
+
36
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
37
+ # hash and check each fields type against the current object's property
38
+ # definitions.
39
+ #
40
+ # @param obj [Object]
41
+ # @return [Void]
42
+ def self.validate_raw(obj:)
43
+ begin
44
+ return Pinnacle::Types::AudienceWithPagination.validate_raw(obj: obj)
45
+ rescue StandardError
46
+ # noop
47
+ end
48
+ begin
49
+ return Pinnacle::Types::AudienceCountOnly.validate_raw(obj: obj)
50
+ rescue StandardError
51
+ # noop
52
+ end
53
+ raise("Passed value matched no type within the union, validation failed.")
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end