iterable-api-client 0.2.1 → 0.3.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: 4506c996979cb9df87929946898bd6c84f7de779be90190965d962a917b9c588
4
- data.tar.gz: 9ba69e4096a6eaf62eb243eca90b0369c35d6f2fcbf7728f4a0df89aef911a4d
3
+ metadata.gz: b456f80ce650910ada263cdb96b28a5fd188dd5afcc4aa44813e0b3892d5d946
4
+ data.tar.gz: 308c15224339eb8a859cf3d9f6491907595d58da5d8bcc46c3f8223ddd356660
5
5
  SHA512:
6
- metadata.gz: 4ec86d3bc2f892914c393e8bcc01f84cb533ca32206281dd771123282fe650f48e62394905bf0c32ae0643098cf7a466fe81843c928b83e9b9e711a78fcec97e
7
- data.tar.gz: 6e8319780483c79d4f158763832ad8e84776fbd51a0a37a81c2dbb642524799ce2b4096cfdcb3a76d284214e66fb4f1d26ca7c5cacdc6c0f952732aefe9c03b8
6
+ metadata.gz: 57c4ad6a3f16d3f7ab4b490bedf27b028f24f2ae1c1de9d79815740d3398d04aeffa0b42543de150a1bec6a988f3821f6f970605beb5da9a7a7890e95fcb49a2
7
+ data.tar.gz: ae76c13bcb47302c41ca6b4a763b6dd53b6669da101b53f927500c73584facd143c0dbbedd922baacfea6806b82f52da84f2c2592f3255d6e7fed580ad152c36
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ~>G���zp+
2
- ��i���-��.���~���C">�S�.q?�M� � ������m�5R�����;�p5T'��� ]@�&d���ps�$�_=Њ�'ƅ��6Ɵ�I?]�mR��om������ݗ����k�.��K_���([xr��\����E���}{zV^F�N8���~UH`oj�L�:md���~�fxph�����!��L���{/�V�!�: P%�� ᆪr��]�� �
1
+ DR=OII�H�0>;��>҄$7�5�D��^.���͇�d3��ERl2�)�+F���x��x�p\���G5�x�`�� 9�c� �� }m�m����r�jiG�w[b��1���������l��D�t��Y]Z
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Iterable API Gem
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/iterable-api-client.svg)](https://rubygems.org/gems/iterable-api-client)
4
- [![build status](https://gitlab.com/mtchavez/iterable/badges/master/build.svg)](https://gitlab.com/mtchavez/iterable/commits/master)
4
+ [![pipeline status](https://gitlab.com/mtchavez/iterable/badges/master/pipeline.svg)](https://gitlab.com/mtchavez/iterable/-/commits/master)
5
5
  [![coverage report](https://gitlab.com/mtchavez/iterable/badges/master/coverage.svg)](https://gitlab.com/mtchavez/iterable/commits/master)
6
6
 
7
7
  Rubygem to interact with the [Iterable][iterable] API.
@@ -87,73 +87,127 @@ reponse.uri
87
87
 
88
88
  ## API Endpoints
89
89
 
90
- * [Campaigns](#campaigns)
91
- * [All](#campaigns-all)
92
- * [Create](#campaigns-create)
93
- * [Metrics](#campaigns-metrics)
94
- * [Child Campaigns](#campaigns-child)
95
- * [Channels](#channels)
96
- * [All](#channels-all)
97
- * [Commerce](#commerce)
98
- * [Track Purchase](#commerce-track-purchase)
99
- * [Update Cart](#commerce-update-cart)
100
- * [Device](#device)
101
- * [Register Device Token](#device-register-token)
102
- * [Email](#email)
103
- * [View](#email-view)
104
- * [Target](#email-target)
105
- * [Email Templates](#email-templates)
106
- * [Get](#email-templates-get)
107
- * [Update](#email-templates-update)
108
- * [Upsert](#email-templates-upsert)
109
- * [Events](#events)
110
- * [For Email](#events-for-email)
111
- * [Track](#events-track)
112
- * [Track Push Open](#events-track-push-open)
113
- * [Experiments](#experiments)
114
- * [Metrics](#experiments-metrics)
115
- * [Export](#export)
116
- * [JSON](#export-json)
117
- * [CSV](#export-csv)
118
- * [Lists](#lists)
119
- * [All](#lists-all)
120
- * [Create](#lists-create)
121
- * [Delete](#lists-delete)
122
- * [Get Users](#lists-users)
123
- * [Subscribe](#lists-subscribe)
124
- * [Unsubscribe](#lists-unsubscribe)
125
- * [Message Types](#message-types)
126
- * [All](#message-types-all)
127
- * [Metadata](#metadata)
128
- * [Get](#metadata-get)
129
- * [List Keys](#metadata-list-keys)
130
- * [Delete](#metadata-delete)
131
- * [Get Key](#metadata-get-key)
132
- * [Remove Key](#metadata-remove-key)
133
- * [Add Key](#metadata-add-key)
134
- * [Push Templates](#push-templates)
135
- * [Get](#push-templates-get)
136
- * [Update](#push-templates-update)
137
- * [Upsert](#push-templates-upsert)
138
- * [Templates](#templates)
139
- * [All](#templates-all)
140
- * [Get](#templates-get)
141
- * [Users](#users)
142
- * [Update](#users-update)
143
- * [Bulk Update](#users-bulk-update)
144
- * [Update Subscriptions](#users-update-subscriptions)
145
- * [Bulk Update Subscriptions](#users-bulk-update-subscriptions)
146
- * [For Email](#users-for-email)
147
- * [By User ID](#users-by-id)
148
- * [Get Fields](#users-get-fields)
149
- * [Update Email](#users-update-email)
150
- * [Delete](#users-delete)
151
- * [Delete By ID](#users-delete-by-id)
152
- * [Register Browser Token](#users-register-browser-token)
153
- * [Disable Device](#users-disable-device)
154
- * [Get Sent Messages](#users-get-messages)
155
- * [Workflows](#workflows)
156
- * [Trigger](#workflows-trigger)
90
+ - [Bulk Catalog Items](#bulk-catalog-items)
91
+ - [Create](#bulk-catalog-items-create)
92
+ - [Delete](#bulk-catalog-items-delete)
93
+ - [Campaigns](#campaigns)
94
+ - [All](#campaigns-all)
95
+ - [Create](#campaigns-create)
96
+ - [Metrics](#campaigns-metrics)
97
+ - [Child Campaigns](#campaigns-child)
98
+ - [Catalog Field Mappings](#catalog-field-mappings)
99
+ - [Get](#catalog-field-mappings-get)
100
+ - [Update](#catalog-field-mappings-update)
101
+ - [Catalog Items](#catalog-items)
102
+ - [All](#catalog-items-all)
103
+ - [Create](#catalog-items-create)
104
+ - [Update](#catalog-items-update)
105
+ - [Get](#catalog-items-get)
106
+ - [Delete](#catalog-items-delete)
107
+ - [Catalogs](#catalogs)
108
+ - [Create](#catalogs-create)
109
+ - [Delete](#catalogs-delete)
110
+ - [Names](#catalogs-names)
111
+ - [Channels](#channels)
112
+ - [All](#channels-all)
113
+ - [Commerce](#commerce)
114
+ - [Track Purchase](#commerce-track-purchase)
115
+ - [Update Cart](#commerce-update-cart)
116
+ - [Device](#device)
117
+ - [Register Device Token](#device-register-token)
118
+ - [Email](#email)
119
+ - [View](#email-view)
120
+ - [Target](#email-target)
121
+ - [Email Templates](#email-templates)
122
+ - [Get](#email-templates-get)
123
+ - [Update](#email-templates-update)
124
+ - [Upsert](#email-templates-upsert)
125
+ - [Events](#events)
126
+ - [For Email](#events-for-email)
127
+ - [Track](#events-track)
128
+ - [Track Push Open](#events-track-push-open)
129
+ - [Experiments](#experiments)
130
+ - [Metrics](#experiments-metrics)
131
+ - [Export](#export)
132
+ - [JSON](#export-json)
133
+ - [CSV](#export-csv)
134
+ - [In App](#in-app)
135
+ - [Messages](#in-app-messages)
136
+ - [Lists](#lists)
137
+ - [All](#lists-all)
138
+ - [Create](#lists-create)
139
+ - [Delete](#lists-delete)
140
+ - [Get Users](#lists-users)
141
+ - [Subscribe](#lists-subscribe)
142
+ - [Unsubscribe](#lists-unsubscribe)
143
+ - [Message Types](#message-types)
144
+ - [All](#message-types-all)
145
+ - [Metadata](#metadata)
146
+ - [Get](#metadata-get)
147
+ - [List Keys](#metadata-list-keys)
148
+ - [Delete](#metadata-delete)
149
+ - [Get Key](#metadata-get-key)
150
+ - [Remove Key](#metadata-remove-key)
151
+ - [Add Key](#metadata-add-key)
152
+ - [Push Templates](#push-templates)
153
+ - [Get](#push-templates-get)
154
+ - [Update](#push-templates-update)
155
+ - [Upsert](#push-templates-upsert)
156
+ - [Templates](#templates)
157
+ - [All](#templates-all)
158
+ - [Get](#templates-get)
159
+ - [Users](#users)
160
+ - [Update](#users-update)
161
+ - [Bulk Update](#users-bulk-update)
162
+ - [Update Subscriptions](#users-update-subscriptions)
163
+ - [Bulk Update Subscriptions](#users-bulk-update-subscriptions)
164
+ - [For Email](#users-for-email)
165
+ - [By User ID](#users-by-id)
166
+ - [Get Fields](#users-get-fields)
167
+ - [Update Email](#users-update-email)
168
+ - [Delete](#users-delete)
169
+ - [Delete By ID](#users-delete-by-id)
170
+ - [Register Browser Token](#users-register-browser-token)
171
+ - [Disable Device](#users-disable-device)
172
+ - [Get Sent Messages](#users-get-messages)
173
+ - [Forget](#users-forget)
174
+ - [Workflows](#workflows)
175
+ - [Trigger](#workflows-trigger)
176
+
177
+ ### Bulk Catalog Items
178
+
179
+ **Beta access only** endpoint
180
+
181
+ #### Bulk Catalog Items Create
182
+
183
+ Endpoint: `POST /catalogs/{catalogName}/items`
184
+
185
+ ```ruby
186
+ catalog = 'my-catalog'
187
+ catalog_items = Iterable::BulkCatalogItems.new(catalog)
188
+ # Hash of item id to item values
189
+ create_items = {
190
+ '122343453' => {
191
+ name: 'item name',
192
+ status: 'open'
193
+ }
194
+ }
195
+ response = catalog_items.create(create_items, replace_uploaded_fields_only: true)
196
+ # Use replace_uploaded_fields_only as true to update fields
197
+ # of existing items. Otherwise the default is to replace
198
+ # existing items
199
+ ```
200
+
201
+ #### Bulk Catalog Items Delete
202
+
203
+ Endpoint: `DELETE /catalogs/{catalogName}/items`
204
+
205
+ ```ruby
206
+ catalog = 'my-catalog'
207
+ catalog_items = Iterable::BulkCatalogItems.new(catalog)
208
+ item_ids = ['12345', '12346', '12347']
209
+ response = catalog_items.create(item_ids)
210
+ ```
157
211
 
158
212
  ### Campaigns
159
213
 
@@ -200,6 +254,160 @@ campaigns = Iterable::Campaigns.new
200
254
  response = campaigns.recurring 'campaign-id'
201
255
  ```
202
256
 
257
+ ### Catalogs
258
+
259
+ **Beta access only** endpoint
260
+
261
+ #### Catalogs Create
262
+
263
+ Endpoint: `POST /catalogs/{catalogName}`
264
+
265
+ ```ruby
266
+ catalog = 'my-catalog'
267
+ catalogs = Iterable::Catalogs.new(catalog)
268
+ response = catalogs.create
269
+ ```
270
+
271
+ #### Catalogs Delete
272
+
273
+ Endpoint: `DELETE /catalogs/{catalogName}`
274
+
275
+ ```ruby
276
+ catalog = 'my-catalog'
277
+ catalogs = Iterable::Catalogs.new(catalog)
278
+ response = catalogs.delete
279
+ ```
280
+
281
+ #### Catalogs Names
282
+
283
+ Endpoint: `GET /catalogs/{catalogName}`
284
+
285
+ ```ruby
286
+ catalog = 'my-catalog'
287
+ catalogs = Iterable::Catalogs.new(catalog)
288
+ params = { page: 1, pageSize: 20 }
289
+ response = catalogs.names(params)
290
+ ```
291
+
292
+ ### Catalog Field Mappings
293
+
294
+ **Beta access only** endpoint
295
+
296
+ #### Catalog Field Mappings Get
297
+
298
+ Endpoint: `GET /catalogs/{catalogName}/fieldMappings`
299
+
300
+ ```ruby
301
+ catalog = 'my-catalog'
302
+ catalog_field_mappings = Iterable::CatalogFieldMappings.new(catalog)
303
+ response = catalog_field_mappings.field_mappings
304
+ ```
305
+
306
+ #### Catalog Field Mappings Update
307
+
308
+ Endpoint: `PUT /catalogs/{catalogName}/fieldMappings`
309
+
310
+ ```ruby
311
+ catalog = 'my-catalog'
312
+ field_mappings = [{fieldName: 'test-field', fieldType: 'string'}]
313
+ catalog_field_mappings = Iterable::CatalogFieldMappings.new(catalog)
314
+ catalog_field_mappings.update(field_mappings)
315
+ ```
316
+
317
+ ### Catalog Items
318
+
319
+ **Beta access only** endpoint
320
+
321
+ #### Catalog Items All
322
+
323
+ Endpoint: `GET /catalogs/{catalogName}/items`
324
+
325
+ ```ruby
326
+ catalog = 'my-catalog'
327
+ catalog_items = Iterable::CatalogItems.new(catalog)
328
+ response = catalog_items.all
329
+ ```
330
+
331
+ #### Catalog Items Create
332
+
333
+ Endpoint: `PUT /catalogs/{catalogName}/items/{itemId}`
334
+
335
+ ```ruby
336
+ catalog = 'my-catalog'
337
+ item_id = '1234-abcd-1234-abcd'
338
+ catalog_items = Iterable::CatalogItems.new(catalog, item_id)
339
+ item_attrs = { name: 'item name', status: 'open' }
340
+ response = catalog_items.create(item_attrs)
341
+ ```
342
+
343
+ #### Catalog Items Update
344
+
345
+ Endpoint: `PATCH /catalogs/{catalogName}/items/{itemId}`
346
+
347
+ ```ruby
348
+ catalog = 'my-catalog'
349
+ item_id = '1234-abcd-1234-abcd'
350
+ catalog_items = Iterable::CatalogItems.new(catalog, item_id)
351
+ item_attrs = { name: 'item name', status: 'open' }
352
+ response = catalog_items.update(item_attrs)
353
+ ```
354
+
355
+ #### Catalog Items Get
356
+
357
+ Endpoint: `GET /catalogs/{catalogName}/items/{itemId}`
358
+
359
+ ```ruby
360
+ catalog = 'my-catalog'
361
+ item_id = '1234-abcd-1234-abcd'
362
+ catalog_items = Iterable::CatalogItems.new(catalog, item_id)
363
+ response = catalog_items.get
364
+ ```
365
+
366
+ #### Catalog Items Delete
367
+
368
+ Endpoint: `DELETE /catalogs/{catalogName}/items/{itemId}`
369
+
370
+ ```ruby
371
+ catalog = 'my-catalog'
372
+ item_id = '1234-abcd-1234-abcd'
373
+ catalog_items = Iterable::CatalogItems.new(catalog, item_id)
374
+ response = catalog_items.delete
375
+ ```
376
+
377
+ ### Catalogs
378
+
379
+ **Beta access only** endpoint
380
+
381
+ #### Catalogs Create
382
+
383
+ Endpoint: `POST /catalogs/{catalogName}`
384
+
385
+ ```ruby
386
+ catalog = 'my-catalog'
387
+ catalog_items = Iterable::Catalogs.new(catalog)
388
+ response = catalog_items.create
389
+ ```
390
+
391
+ #### Catalogs Delete
392
+
393
+ Endpoint: `DELETE /catalogs/{catalogName}`
394
+
395
+ ```ruby
396
+ catalog = 'my-catalog'
397
+ catalog_items = Iterable::Catalogs.new(catalog)
398
+ response = catalog_items.delete
399
+ ```
400
+
401
+ #### Catalogs Names
402
+
403
+ Endpoint: `GET /catalogs/{catalogName}/names`
404
+
405
+ ```ruby
406
+ catalog = 'my-catalog'
407
+ catalog_items = Iterable::Catalogs.new(catalog)
408
+ params = { page: 1, pageSize: 20 }
409
+ response = catalog_items.names(params)
410
+ ```
203
411
 
204
412
  ### Channels
205
413
 
@@ -411,6 +619,29 @@ start_time = end_time - (60 * 60* 24 * 7) # 7 days ago
411
619
  response = exporter.export start_time, end_time
412
620
  ```
413
621
 
622
+ ### In App
623
+
624
+ #### In App Messages
625
+
626
+ Endpoint: `GET /inApp/getMessages`
627
+
628
+ ```ruby
629
+ in_app = Iterable::InApp.new
630
+
631
+ # Get messages for a user by email
632
+ email = 'user@example.com'
633
+ response = in_app.messages_for_email email, count: 10
634
+
635
+ # Get messages for a user by user_id
636
+ email = 'user@example.com'
637
+ response = in_app.messages_for_user_id 42, count: 2
638
+
639
+ # Pass in query parameters
640
+ email = 'user@example.com'
641
+ attrs = { 'platform' => 'iOS' }
642
+ response = in_app.messages_for_email: email, attrs
643
+ ```
644
+
414
645
  ### Lists
415
646
 
416
647
  #### Lists All
@@ -744,6 +975,17 @@ start_time = end_time - (60 * 60* 24 * 7) # 7 days ago
744
975
  response = users.sent_messages 'user@example.com', start_time, end_time, params
745
976
  ```
746
977
 
978
+ #### Users Forget
979
+
980
+ Endpoint: `POST /users/forget`
981
+
982
+ ```ruby
983
+ users = Iterable::Users.new
984
+ # Additional params to filter and query by
985
+ email = 'user@example.com'
986
+ response = users.forget email
987
+ ```
988
+
747
989
  ### Workflows
748
990
 
749
991
  #### Workflows Trigger
@@ -15,7 +15,7 @@ module Iterable
15
15
  #
16
16
  # @return [Iterable::ApiResource]
17
17
  def initialize(conf = nil)
18
- @conf = conf ? conf : default_config
18
+ @conf = conf || default_config
19
19
  end
20
20
 
21
21
  ##
@@ -0,0 +1,65 @@
1
+ module Iterable
2
+ ##
3
+ #
4
+ # Interact with /catalogs/{catalogName}/items API endpoints
5
+ # **currently in Beta only**
6
+ #
7
+ # @example Creating catalog items endpoint object
8
+ # # With default config
9
+ # catalog = Iterable::BulkCatalogItems.new "catalog-name"
10
+ # catalog.items
11
+ #
12
+ # # With custom config
13
+ # conf = Iterable::Config.new(token: 'new-token')
14
+ # catalog = Iterable::BulkCatalogItems.new("catalog-name", config)
15
+ class BulkCatalogItems < ApiResource
16
+ attr_reader :catalog
17
+
18
+ ##
19
+ #
20
+ # Initialize CatalogItems with a catalog name and item ID **currently in Beta only**
21
+ #
22
+ # @param catalog [String] The name of the catalog to interact with
23
+ # @param item_id [String] The string ID of the item to interact with
24
+ # @param conf [Iterable::Config] A config to optionally pass for requests
25
+ #
26
+ # @return [Iterable::Catalog]
27
+ def initialize(catalog, conf = nil)
28
+ @catalog = catalog
29
+ super conf
30
+ end
31
+
32
+ ##
33
+ #
34
+ # Bulk delete catalog items
35
+ #
36
+ # @param keys [Array] Array of catalog items ids to delete
37
+ #
38
+ # @return [Iterable::Response] A response object
39
+ def delete(item_ids = [])
40
+ body = { itemIds: item_ids }
41
+ Iterable.request(conf, base_path).delete(body)
42
+ end
43
+
44
+ ##
45
+ #
46
+ # Bulk create catalog items
47
+ #
48
+ # @param documents [Hash] Hash of item ID to item attributes e.g. { '123456': { name: 'foo', state: 'open' } }
49
+ # @param replace_uploaded_fields_only [Boolean] Whether to replace only the upload fields within each document,
50
+ # not each entire document. Defaults to false and will replace
51
+ # existing.
52
+ # @return [Iterable::Response] A response object
53
+ def create(items = {}, replace_uploaded_fields_only: false)
54
+ body = {
55
+ documents: items,
56
+ replaceUploadedFieldsOnly: replace_uploaded_fields_only
57
+ }
58
+ Iterable.request(conf, base_path).post(body)
59
+ end
60
+
61
+ private def base_path
62
+ "/catalogs/#{@catalog}/items"
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,61 @@
1
+ module Iterable
2
+ ##
3
+ #
4
+ # Interact with /catalogs/{catalogName}/fieldMappings API endpoints
5
+ # **currently in Beta only**
6
+ #
7
+ # @example Creating catalog field mappings endpoint object
8
+ # # With default config
9
+ # catalog = Iterable::CatalogFieldMappings.new "catalog-name"
10
+ # catalog.items
11
+ #
12
+ # # With custom config
13
+ # conf = Iterable::Config.new(token: 'new-token')
14
+ # catalog = Iterable::CatalogFieldMappings.new("catalog-name", config)
15
+ class CatalogFieldMappings < ApiResource
16
+ attr_reader :catalog
17
+ ##
18
+ #
19
+ # Initialize CatalogFieldMappings with a catalog name **currently in Beta only**
20
+ #
21
+ # @param catalog [String] The name of the catalog to interact with
22
+ # @param conf [Iterable::Config] A config to optionally pass for requests
23
+ #
24
+ # @return [Iterable::Catalog]
25
+ def initialize(catalog, conf = nil)
26
+ @catalog = catalog
27
+ super conf
28
+ end
29
+
30
+ ##
31
+ #
32
+ # Get field mappings for a catalog
33
+ #
34
+ # @return [Iterable::Response] A response object
35
+ def get
36
+ Iterable.request(conf, base_path).get
37
+ end
38
+
39
+ ##
40
+ #
41
+ # Set a catalog's field mappings (data types)
42
+ #
43
+ # @param [Array] Array of field mapping hashes e.g [{"fieldName":"exampleString","fieldType":"string"}]}
44
+ #
45
+ # @return [Iterable::Response] A response object
46
+ #
47
+ # @example Supplying field mappings
48
+ # # Fields to update with field types
49
+ # field_mappings = [{fieldName: 'test-field', fieldType: 'string'}]
50
+ # catalog = Iterable::CatalogFieldMappings.new "catalog-name"
51
+ # catalog.update_field_mappings(field_mappings)
52
+ def update(mappings_updates = [])
53
+ body = { mappingsUpdates: mappings_updates }
54
+ Iterable.request(conf, base_path).put(body)
55
+ end
56
+
57
+ private def base_path
58
+ "/catalogs/#{@catalog}/fieldMappings"
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,93 @@
1
+ module Iterable
2
+ ##
3
+ #
4
+ # Interact with /catalogs/{catalogName}/{itemID} API endpoints
5
+ # **currently in Beta only**
6
+ #
7
+ # @example Creating catalog items endpoint object
8
+ # # With default config
9
+ # catalog = Iterable::CatalogItems.new "catalog-name"
10
+ # catalog.items
11
+ #
12
+ # # With custom config
13
+ # conf = Iterable::Config.new(token: 'new-token')
14
+ # catalog = Iterable::CatalogItems.new("catalog-name", config)
15
+ class CatalogItems < ApiResource
16
+ attr_reader :catalog, :item_id
17
+
18
+ ##
19
+ #
20
+ # Initialize CatalogItems with a catalog name and item ID **currently in Beta only**
21
+ #
22
+ # @param catalog [String] The name of the catalog to interact with
23
+ # @param item_id [String] The string ID of the item to interact with
24
+ # @param conf [Iterable::Config] A config to optionally pass for requests
25
+ #
26
+ # @return [Iterable::Catalog]
27
+ def initialize(catalog, item_id = nil, conf = nil)
28
+ @catalog = catalog
29
+ @item_id = item_id
30
+ super conf
31
+ end
32
+
33
+ ##
34
+ #
35
+ # Get all items for a catalog
36
+ #
37
+ # @param params[Hash] Attribute hash for item query (page, pageSize, orderBy, sortAscending)
38
+ #
39
+ # @return [Iterable::Response] A response object
40
+ def all(params = {})
41
+ Iterable.request(conf, base_path, params).get
42
+ end
43
+
44
+ ##
45
+ #
46
+ # Create a catalog item
47
+ #
48
+ # @param item_attrs [Hash] Item attributes to save or replace with
49
+ #
50
+ # @return [Iterable::Response] A response object
51
+ def create(item_attrs = {})
52
+ body = { value: item_attrs }
53
+ Iterable.request(conf, base_path).put(body)
54
+ end
55
+ alias replace create
56
+
57
+ ##
58
+ #
59
+ # Update a catalog item
60
+ #
61
+ # @param item_attrs [Hash] Item attributes to save or update with
62
+ #
63
+ # @return [Iterable::Response] A response object
64
+ def update(item_attrs = {})
65
+ body = { update: item_attrs }
66
+ Iterable.request(conf, base_path).patch(body)
67
+ end
68
+
69
+ ##
70
+ #
71
+ # Get a specific catalog item
72
+ #
73
+ # @return [Iterable::Response] A response object
74
+ def get
75
+ Iterable.request(conf, base_path).get
76
+ end
77
+
78
+ ##
79
+ #
80
+ # Delete a catalog item
81
+ #
82
+ # @return [Iterable::Response] A response object
83
+ def delete
84
+ Iterable.request(conf, base_path).delete
85
+ end
86
+
87
+ private def base_path
88
+ path = "/catalogs/#{@catalog}/items"
89
+ path += "/#{@item_id}" if @item_id
90
+ path
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,61 @@
1
+ module Iterable
2
+ ##
3
+ #
4
+ # Interact with /catalogs/{catalogName} API endpoints
5
+ # **currently in Beta only**
6
+ #
7
+ # @example Creating catalog endpoint object
8
+ # # With default config
9
+ # catalog = Iterable::Catalogs.new "catalog-name"
10
+ # catalog.items
11
+ #
12
+ # # With custom config
13
+ # conf = Iterable::Config.new(token: 'new-token')
14
+ # catalog = Iterable::Catalogs.new("catalog-name", config)
15
+ class Catalogs < ApiResource
16
+ attr_reader :name
17
+ ##
18
+ #
19
+ # Initialize Catalogs with a catalog name **currently in Beta only**
20
+ #
21
+ # @param name [String] The name of the catalog to interact with
22
+ # @param conf [Iterable::Config] A config to optionally pass for requests
23
+ #
24
+ # @return [Iterable::Catalog]
25
+ def initialize(name, conf = nil)
26
+ @name = name
27
+ super conf
28
+ end
29
+
30
+ ##
31
+ #
32
+ # Create a catalog
33
+ #
34
+ # @return [Iterable::Response] A response object
35
+ def create
36
+ Iterable.request(conf, base_path).post
37
+ end
38
+
39
+ ##
40
+ #
41
+ # Delete a catalog
42
+ #
43
+ # @return [Iterable::Response] A response object
44
+ def delete
45
+ Iterable.request(conf, base_path).delete
46
+ end
47
+
48
+ ##
49
+ #
50
+ # Get a list of all catalog names
51
+ #
52
+ # @return [Iterable::Response] A response object
53
+ def names(params = {})
54
+ Iterable.request(conf, '/catalogs', params).get
55
+ end
56
+
57
+ private def base_path
58
+ "/catalogs/#{@name}"
59
+ end
60
+ end
61
+ end
@@ -56,13 +56,11 @@ module Iterable
56
56
  Iterable.request(conf, base_path).post(attrs)
57
57
  end
58
58
 
59
- private
60
-
61
- def base_path
59
+ private def base_path
62
60
  '/users/registerDeviceToken'
63
61
  end
64
62
 
65
- def device_data
63
+ private def device_data
66
64
  {
67
65
  token: @token,
68
66
  applicationName: @app,
@@ -103,20 +103,26 @@ module Iterable
103
103
  Iterable.request(conf, base_path, request_params(params)).get
104
104
  end
105
105
 
106
- protected
107
-
108
- def base_path
106
+ protected def base_path
109
107
  "/export/data.#{format}"
110
108
  end
111
109
 
112
- def request_params(params = {})
110
+ protected def request_params(params = {})
113
111
  default_params.merge params
114
112
  end
115
113
 
116
- def default_params
114
+ protected def only_fields?
115
+ @only_fields&.length.to_i.positive?
116
+ end
117
+
118
+ protected def omit_fields?
119
+ @omit_fields&.length.to_i.positive?
120
+ end
121
+
122
+ protected def default_params
117
123
  params = { dataTypeName: @data_type }
118
- params[:onlyFields] = @only_fields if @only_fields && @only_fields.length.positive?
119
- params[:omitFields] = @omit_fields.join(',') if @omit_fields && @omit_fields.length.positive?
124
+ params[:onlyFields] = @only_fields if only_fields?
125
+ params[:omitFields] = @omit_fields.join(',') if omit_fields?
120
126
  params[:campaignId] = @campaign_id if @campaign_id
121
127
  params
122
128
  end
@@ -0,0 +1,48 @@
1
+ module Iterable
2
+ ##
3
+ #
4
+ # Interact with /inApp API endpoints
5
+ #
6
+ # @example Creating in app endpoint object
7
+ # # With default config
8
+ # in_app = Iterable::InApp.new
9
+ #
10
+ # # With custom config
11
+ # conf = Iterable::Config.new(token: 'new-token')
12
+ # in_app = Iterable::InApp.new(config)
13
+ class InApp < ApiResource
14
+ ##
15
+ #
16
+ # Get in-app messages for a user by email
17
+ #
18
+ # @param email [String] *required* Email of user who received the message to view. Required if no user_id present.
19
+ # @param count [Integer] Number of messages to return, defaults to 1
20
+ # @param attrs [Hash] Hash of query attributes like platform, SDKVersion, etc.
21
+ #
22
+ # @return [Iterable::Response] A response object
23
+ def messages_for_email(email, count: 1, **attrs)
24
+ attrs[:email] = email
25
+ attrs[:count] = count
26
+ messages(attrs)
27
+ end
28
+
29
+ ##
30
+ #
31
+ # Get in-app messages for a user by user_id
32
+ #
33
+ # @param email [String] *required* Email of user who received the message to view. Required if no user_id present.
34
+ # @param count [Integer] Number of messages to return, defaults to 1
35
+ # @param attrs [Hash] Hash of query attributes like platform, SDKVersion, etc.
36
+ #
37
+ # @return [Iterable::Response] A response object
38
+ def messages_for_user_id(user_id, count: 1, **attrs)
39
+ attrs[:userId] = user_id
40
+ attrs[:count] = count
41
+ messages(attrs)
42
+ end
43
+
44
+ private def messages(**attrs)
45
+ Iterable.request(conf, '/inApp/getMessages', attrs).get
46
+ end
47
+ end
48
+ end
@@ -82,9 +82,7 @@ module Iterable
82
82
  Iterable.request(conf, base_path(key)).delete
83
83
  end
84
84
 
85
- private
86
-
87
- def base_path(key = nil)
85
+ private def base_path(key = nil)
88
86
  path = "/metadata/#{@name}"
89
87
  path += "/#{key}" if key
90
88
  path
@@ -34,33 +34,35 @@ module Iterable
34
34
  execute :put, body, headers
35
35
  end
36
36
 
37
- def delete(headers = {})
38
- execute :delete, {}, headers
37
+ def patch(body = {}, headers = {})
38
+ execute :patch, body, headers
39
39
  end
40
40
 
41
- private
41
+ def delete(body = {}, headers = {})
42
+ execute :delete, body, headers
43
+ end
42
44
 
43
- def execute(verb, body = {}, headers = {})
45
+ private def execute(verb, body = {}, headers = {})
44
46
  http = connection(verb, body, headers)
45
47
  setup_http(http)
46
48
  transmit http
47
49
  end
48
50
 
49
- def connection(verb, body = {}, headers = {})
51
+ private def connection(verb, body = {}, headers = {})
50
52
  conn_headers = DEFAULT_HEADERS.merge(headers)
51
53
  req = Net::HTTP.const_get(verb.to_s.capitalize, false).new(@uri, conn_headers)
52
54
  req.body = JSON.dump(body)
53
55
  req
54
56
  end
55
57
 
56
- def setup_http(http)
58
+ private def setup_http(http)
57
59
  DEFAULT_OPTIONS.dup.each do |option, value|
58
60
  setter = "#{option.to_sym}="
59
61
  http.send(setter, value) if http.respond_to?(setter)
60
62
  end
61
63
  end
62
64
 
63
- def build_uri(path, params = {})
65
+ private def build_uri(path, params = {})
64
66
  uri = @config.uri
65
67
  uri.path += path
66
68
  params['api_key'] = @config.token
@@ -68,11 +70,11 @@ module Iterable
68
70
  uri
69
71
  end
70
72
 
71
- def net_http
73
+ private def net_http
72
74
  Net::HTTP.new(@uri.hostname, @uri.port, nil, nil, nil, nil)
73
75
  end
74
76
 
75
- def transmit(req)
77
+ private def transmit(req)
76
78
  response = nil
77
79
  @net.start do |http|
78
80
  response = http.request(req, nil, &:read_body)
@@ -80,7 +82,7 @@ module Iterable
80
82
  handle_response response
81
83
  end
82
84
 
83
- def handle_response(response)
85
+ private def handle_response(response)
84
86
  redirected = response.is_a?(Net::HTTPRedirection) || response.code == '303'
85
87
  if redirected && response['location']
86
88
  Response.new Net::HTTP.get_response(uri_for_redirect(response))
@@ -89,7 +91,7 @@ module Iterable
89
91
  end
90
92
  end
91
93
 
92
- def uri_for_redirect(response)
94
+ private def uri_for_redirect(response)
93
95
  uri = @config.uri
94
96
  redirect_uri = URI(response['location'])
95
97
  uri.path = redirect_uri.path
@@ -12,7 +12,7 @@ module Iterable
12
12
  attr_reader :body
13
13
 
14
14
  # @!visibility private
15
- def initialize(resp) # @private
15
+ def initialize(resp)
16
16
  @resp = resp
17
17
  @body = parsed_body
18
18
  end
@@ -29,14 +29,12 @@ module Iterable
29
29
  end
30
30
  end
31
31
 
32
- private
33
-
34
32
  ##
35
33
  # Attempts to parse the response as JSON. Will rescue and return original
36
34
  # if unable to parse.
37
35
  #
38
36
  # @return [Hash,Array,String] A parsed JSON object or the original response body
39
- def parsed_body
37
+ private def parsed_body
40
38
  response_body = @resp.body
41
39
  MultiJson.load response_body
42
40
  rescue MultiJson::ParseError
@@ -186,5 +186,18 @@ module Iterable
186
186
  params[:endTime] = end_time.to_s if end_time
187
187
  Iterable.request(conf, '/users/getSentMessages', params).get
188
188
  end
189
+
190
+ ##
191
+ #
192
+ # Delete the specified user's data from the Iterable project and
193
+ # prevent future data collection about them.
194
+ #
195
+ # @param email [String] User email to forget
196
+ #
197
+ # @return [Iterable::Response] A response object
198
+ def forget(email)
199
+ attrs = { email: email }
200
+ Iterable.request(conf, '/users/forget').post(attrs)
201
+ end
189
202
  end
190
203
  end
data/lib/iterable.rb CHANGED
@@ -6,6 +6,10 @@ require 'multi_json'
6
6
 
7
7
  files = %w[
8
8
  api_resource
9
+ bulk_catalog_items
10
+ catalogs
11
+ catalog_field_mappings
12
+ catalog_items
9
13
  config
10
14
  response
11
15
  request
@@ -13,6 +17,7 @@ files = %w[
13
17
  campaigns
14
18
  channels
15
19
  events
20
+ in_app
16
21
  message_types
17
22
  templates
18
23
  email_templates
@@ -38,8 +43,6 @@ files.each { |path| require_relative "./iterable/#{path}" }
38
43
  module Iterable
39
44
  DATE_FORMAT = '%Y-%m-%d'.freeze
40
45
 
41
- module_function
42
-
43
46
  ##
44
47
  #
45
48
  # Configure a default [Iterable::Config] object to be used when interacting
@@ -49,7 +52,7 @@ module Iterable
49
52
  # Iterable.configure do |conf|
50
53
  # conf.token = 'secret-token'
51
54
  # end
52
- def configure
55
+ module_function def configure
53
56
  config.tap do |conf|
54
57
  yield conf
55
58
  end
@@ -58,12 +61,12 @@ module Iterable
58
61
  ##
59
62
  #
60
63
  # @return [Iterable::Config] The default config for API endpoints
61
- def config
64
+ module_function def config
62
65
  @config ||= Config.new
63
66
  end
64
67
 
65
68
  # @!visibility private
66
- def request(conf, path, params = {})
69
+ module_function def request(conf, path, params = {})
67
70
  Request.new conf, path, params
68
71
  end
69
72
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,36 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iterable-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chavez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRAwDgYDVQQDDAdjb250
13
+ MIIEeDCCAuCgAwIBAgIBATANBgkqhkiG9w0BAQsFADBBMRAwDgYDVQQDDAdjb250
14
14
  YWN0MRkwFwYKCZImiZPyLGQBGRYJZWwtY2hhdmV6MRIwEAYKCZImiZPyLGQBGRYC
15
- bWUwHhcNMTcxMDA0MTY0OTE5WhcNMTgxMDA0MTY0OTE5WjBBMRAwDgYDVQQDDAdj
15
+ bWUwHhcNMjIwNTE2MTYzNDEwWhcNMjMwNTE2MTYzNDEwWjBBMRAwDgYDVQQDDAdj
16
16
  b250YWN0MRkwFwYKCZImiZPyLGQBGRYJZWwtY2hhdmV6MRIwEAYKCZImiZPyLGQB
17
- GRYCbWUwggEiMA0GC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0CA+vGC
34
+ bP6SNtxoWX20A6bkT2pf19J77p1LNFQAtQ2uUWqoXHdhtUvmpo28/WH/WY1CGuhP
35
+ skirV2p91csPqqACuQCX2oK9r29QZtt95aAnVdsdBMA+evI2nVknO0OhYDqNA0wR
36
+ SkUCdTSDgV9CsbN/vy6DeR0eX1kP6OrntZJjKnrncbkKZnrJ5fjzKtUyj3I=
32
37
  -----END CERTIFICATE-----
33
- date: 2018-07-17 00:00:00.000000000 Z
38
+ date: 2022-05-16 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: multi_json
@@ -192,14 +197,14 @@ dependencies:
192
197
  requirements:
193
198
  - - "~>"
194
199
  - !ruby/object:Gem::Version
195
- version: 0.49.1
200
+ version: 0.89.1
196
201
  type: :development
197
202
  prerelease: false
198
203
  version_requirements: !ruby/object:Gem::Requirement
199
204
  requirements:
200
205
  - - "~>"
201
206
  - !ruby/object:Gem::Version
202
- version: 0.49.1
207
+ version: 0.89.1
203
208
  - !ruby/object:Gem::Dependency
204
209
  name: simplecov
205
210
  requirement: !ruby/object:Gem::Requirement
@@ -220,14 +225,14 @@ dependencies:
220
225
  requirements:
221
226
  - - "~>"
222
227
  - !ruby/object:Gem::Version
223
- version: 1.3.0
228
+ version: 1.4.0
224
229
  type: :development
225
230
  prerelease: false
226
231
  version_requirements: !ruby/object:Gem::Requirement
227
232
  requirements:
228
233
  - - "~>"
229
234
  - !ruby/object:Gem::Version
230
- version: 1.3.0
235
+ version: 1.4.0
231
236
  - !ruby/object:Gem::Dependency
232
237
  name: vcr
233
238
  requirement: !ruby/object:Gem::Requirement
@@ -248,14 +253,14 @@ dependencies:
248
253
  requirements:
249
254
  - - "~>"
250
255
  - !ruby/object:Gem::Version
251
- version: 3.0.1
256
+ version: 3.8.3
252
257
  type: :development
253
258
  prerelease: false
254
259
  version_requirements: !ruby/object:Gem::Requirement
255
260
  requirements:
256
261
  - - "~>"
257
262
  - !ruby/object:Gem::Version
258
- version: 3.0.1
263
+ version: 3.8.3
259
264
  - !ruby/object:Gem::Dependency
260
265
  name: yard
261
266
  requirement: !ruby/object:Gem::Requirement
@@ -282,7 +287,11 @@ files:
282
287
  - lib/iterable-api-client.rb
283
288
  - lib/iterable.rb
284
289
  - lib/iterable/api_resource.rb
290
+ - lib/iterable/bulk_catalog_items.rb
285
291
  - lib/iterable/campaigns.rb
292
+ - lib/iterable/catalog_field_mappings.rb
293
+ - lib/iterable/catalog_items.rb
294
+ - lib/iterable/catalogs.rb
286
295
  - lib/iterable/channels.rb
287
296
  - lib/iterable/commerce.rb
288
297
  - lib/iterable/config.rb
@@ -293,6 +302,7 @@ files:
293
302
  - lib/iterable/events.rb
294
303
  - lib/iterable/experiments.rb
295
304
  - lib/iterable/export.rb
305
+ - lib/iterable/in_app.rb
296
306
  - lib/iterable/json_exporter.rb
297
307
  - lib/iterable/lists.rb
298
308
  - lib/iterable/message_types.rb
@@ -309,7 +319,7 @@ homepage: http://gitlab.com/mtchavez/iterable
309
319
  licenses:
310
320
  - MIT
311
321
  metadata: {}
312
- post_install_message:
322
+ post_install_message:
313
323
  rdoc_options:
314
324
  - "--charset=UTF-8"
315
325
  - "--main=README.md"
@@ -319,16 +329,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
319
329
  requirements:
320
330
  - - ">="
321
331
  - !ruby/object:Gem::Version
322
- version: 2.3.0
332
+ version: 2.4.0
323
333
  required_rubygems_version: !ruby/object:Gem::Requirement
324
334
  requirements:
325
335
  - - ">="
326
336
  - !ruby/object:Gem::Version
327
337
  version: '0'
328
338
  requirements: []
329
- rubyforge_project:
330
- rubygems_version: 2.7.6
331
- signing_key:
339
+ rubygems_version: 3.0.3
340
+ signing_key:
332
341
  specification_version: 4
333
342
  summary: Iterable REST API Client
334
343
  test_files: []
metadata.gz.sig CHANGED
Binary file