iterable-api-client 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d04be11184926b2bcffba1f777270fc08fbf83e676babb5c1e79756e33915464
4
- data.tar.gz: 07723ae603767edd511e37a3c682f0348e6a9262ca435e881fd4d86a7e77b515
3
+ metadata.gz: dec75eb2ce6297758dd87c44acd79435578c29bb16f23402d133c2e24d1f6820
4
+ data.tar.gz: 45658c86e6448f1e75948fa150de1bb6133dacefb3d237cf1edc5504ee90591b
5
5
  SHA512:
6
- metadata.gz: dc7f30727eaa45240f3a0f683e58128184397a305214e29e719ae34d0794ee04421bfb0bf496865a285f85edede66691d40e3f0e19a24652261efe38e1b6fa82
7
- data.tar.gz: a90443045373add4a10ffd3ddbfb74114e71102b6be4f9f8392af1b179a02813e9432d15c3d743499ccb7ae27a8fcbb2e548fb43ec826aff3e1b4211b29a4e27
6
+ metadata.gz: 9dc86fb5a431fddc281eefb86e0ed597b535dad112e03ef53de5027dd723015d8f1ac791d1ba93c1086aef2cd382d619dafaca348147ada3e7d091ed30afc353
7
+ data.tar.gz: 8428f4dfd4bec851b1ed30ee7161dfa7f26848f4c210046fb29f8485a002a06c016473366774720f79855179b27f3e8f57793dfcb3203db82956dcef4d50cfd4
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -81,6 +81,10 @@ response.body
81
81
  # HTTP message
82
82
  response.message
83
83
 
84
+ # Headers of response
85
+ response['Content-Type']
86
+ # => 'application/json; charset=utf-8'
87
+
84
88
  # The URI used to make the request for the response
85
89
  reponse.uri
86
90
  ```
@@ -124,6 +128,7 @@ reponse.uri
124
128
  - [Upsert](#email-templates-upsert)
125
129
  - [Events](#events)
126
130
  - [For Email](#events-for-email)
131
+ - [Bulk Track](#events-track-bulk)
127
132
  - [Track](#events-track)
128
133
  - [Track Push Open](#events-track-push-open)
129
134
  - [Experiments](#experiments)
@@ -133,6 +138,8 @@ reponse.uri
133
138
  - [CSV](#export-csv)
134
139
  - [In App](#in-app)
135
140
  - [Messages](#in-app-messages)
141
+ - [Target](#in-app-target)
142
+ - [Cancel](#in-app-cancel)
136
143
  - [Lists](#lists)
137
144
  - [All](#lists-all)
138
145
  - [Create](#lists-create)
@@ -149,6 +156,9 @@ reponse.uri
149
156
  - [Get Key](#metadata-get-key)
150
157
  - [Remove Key](#metadata-remove-key)
151
158
  - [Add Key](#metadata-add-key)
159
+ - [Push](#push)
160
+ - [Target](#push-target)
161
+ - [Cancel](#push-cancel)
152
162
  - [Push Templates](#push-templates)
153
163
  - [Get](#push-templates-get)
154
164
  - [Update](#push-templates-update)
@@ -206,7 +216,7 @@ Endpoint: `DELETE /catalogs/{catalogName}/items`
206
216
  catalog = 'my-catalog'
207
217
  catalog_items = Iterable::BulkCatalogItems.new(catalog)
208
218
  item_ids = ['12345', '12346', '12347']
209
- response = catalog_items.create(item_ids)
219
+ response = catalog_items.delete(item_ids)
210
220
  ```
211
221
 
212
222
  ### Campaigns
@@ -300,7 +310,8 @@ Endpoint: `GET /catalogs/{catalogName}/fieldMappings`
300
310
  ```ruby
301
311
  catalog = 'my-catalog'
302
312
  catalog_field_mappings = Iterable::CatalogFieldMappings.new(catalog)
303
- response = catalog_field_mappings.field_mappings
313
+ response = catalog_field_mappings.get
314
+ response.body['params']['definedMappings']
304
315
  ```
305
316
 
306
317
  #### Catalog Field Mappings Update
@@ -557,6 +568,19 @@ attrs = { campaignId: 42, dataFields: {} }
557
568
  response = events.track 'event-name', 'user@example.com', attrs
558
569
  ```
559
570
 
571
+ #### Events Track Bulk
572
+
573
+ Endpoint: `POST /events/trackBulk`
574
+
575
+ ```ruby
576
+ events = Iterable::Events.new
577
+ # Array of events to track
578
+ events_attrs = [
579
+ { email: 'user@example.com', eventName: 'event-name', campaignId: 42, dataFields: {} }
580
+ ]
581
+ response = iterable_events.track_bulk events_attrs
582
+ ```
583
+
560
584
  #### Events Track Push Open
561
585
 
562
586
  Endpoint: `GET /events/{email}`
@@ -639,7 +663,34 @@ response = in_app.messages_for_user_id 42, count: 2
639
663
  # Pass in query parameters
640
664
  email = 'user@example.com'
641
665
  attrs = { 'platform' => 'iOS' }
642
- response = in_app.messages_for_email: email, attrs
666
+ response = in_app.messages_for_email email, attrs
667
+ ```
668
+
669
+ #### In App Target
670
+
671
+ Endpoint: `POST /inApp/target`
672
+
673
+ ```ruby
674
+ in_app = Iterable::InApp.new
675
+
676
+ # Needs campaign ID and an optional email
677
+ email = 'user@example.com'
678
+ attrs = { 'campaignId' => '123456asdf' }
679
+ response = in_app.target attrs: attrs, email: email
680
+ ```
681
+
682
+ #### In App Cancel
683
+
684
+ Endpoint: `POST /push/cancel`
685
+
686
+ ```ruby
687
+ in_app = Iterable::InApp.new
688
+
689
+ # Needs campaign ID and an optional email and optional attrs for request
690
+ email = 'user@example.com'
691
+ campaign_id = '12345asdf'
692
+ attrs = {}
693
+ response = in_app.target campaign_id: campaign_id, attrs: attrs, email: email
643
694
  ```
644
695
 
645
696
  ### Lists
@@ -776,6 +827,32 @@ value = { foo: 'bar', data: 'stuffs' }
776
827
  response = metadata_table.add 'metadata-key', value
777
828
  ```
778
829
 
830
+ ### Push
831
+
832
+ #### Push Target
833
+
834
+ Endpoint: `POST /push/target`
835
+
836
+ ```ruby
837
+ push = Iterable::Push.new
838
+ campaign_id = '1234asdf'
839
+ email = 'user@example.com' # optional
840
+ attrs = {} # optional extra params for the request
841
+ response = push.target campaign_id: campaign_id, email: email, attrs: attrs
842
+ ```
843
+
844
+ #### Push Cancel
845
+
846
+ Endpoint: `POST /push/cancel`
847
+
848
+ ```ruby
849
+ push = Iterable::Push.new
850
+ campaign_id = '1234asdf'
851
+ email = 'user@example.com' # optional
852
+ attrs = {} # optional extra params for the request
853
+ response = push.cancel email: email, campaign_id: campaign_id, attrs: attrs
854
+ ```
855
+
779
856
  ### Push Templates
780
857
 
781
858
  #### Push Templates Get
@@ -854,10 +931,10 @@ Endpoint: `POST /users/bulkUpdate`
854
931
  users = Iterable::Users.new
855
932
  # Array of users to update by email with additional
856
933
  # fields if needed
857
- users = [
934
+ users_attrs = [
858
935
  { email: 'user@example.com', userID: 'custom-id' }
859
936
  ]
860
- response = users.bulk_update users
937
+ response = users.bulk_update users_attrs
861
938
  ```
862
939
 
863
940
  #### Users Update Subscriptions
@@ -18,11 +18,15 @@ module Iterable
18
18
  #
19
19
  # @param email [String] Email of user who received the message to view
20
20
  # @param message_id [String|Integer] Message id for message sent
21
+ # @param attrs [Hash] Hash of attributes to pass like dataFields with the requst
21
22
  #
22
23
  # @return [Iterable::Response] A response object
23
- def view(email, message_id)
24
- params = { email: email, messageId: message_id }
25
- Iterable.request(conf, '/email/viewInBrowser', params).get
24
+ def view(email, message_id, attrs = {})
25
+ attrs['email'] = email
26
+ attrs['messageId'] = message_id
27
+ attrs.compact!
28
+
29
+ Iterable.request(conf, '/email/viewInBrowser', attrs).get
26
30
  end
27
31
 
28
32
  ##
@@ -39,6 +39,19 @@ module Iterable
39
39
  Iterable.request(conf, '/events/track').post(attrs)
40
40
  end
41
41
 
42
+ ##
43
+ #
44
+ # Bulk Track events
45
+ #
46
+ # @param events [Array[Hash]] Array of hashes of event details
47
+ #
48
+ # @return [Iterable::Response] A response object
49
+ #
50
+ # @note Event fields can be eventName [String], email [String], dataFields [Hash], or userId [String]
51
+ def track_bulk(events = [])
52
+ Iterable.request(conf, '/events/trackBulk').post(events: events)
53
+ end
54
+
42
55
  ##
43
56
  #
44
57
  # Track an event
@@ -41,6 +41,42 @@ module Iterable
41
41
  messages(attrs)
42
42
  end
43
43
 
44
+ ##
45
+ #
46
+ # Send an In-App notification to a specific user. User Email or ID along
47
+ # with campaign ID must be provided
48
+ #
49
+ # @param email [String] (optional) User email used to identify user
50
+ # @param campaign_id [Integer] Campaign ID
51
+ # @param attrs [Hash] Additional data to update or add
52
+ #
53
+ # @return [Iterable::Response] A response object
54
+ #
55
+ def target(campaign_id:, attrs: {}, email: nil)
56
+ attrs['recipientEmail'] = email if email
57
+ attrs['campaignId'] = campaign_id
58
+ Iterable.request(conf, '/inApp/target').post(attrs)
59
+ end
60
+
61
+ ##
62
+ #
63
+ # Cancel an In App notification sent to a specific user
64
+ # Must include either an email address AND campaignId, or
65
+ # just a scheduledMessageId provided in the attrs
66
+ #
67
+ # @param email [String] User email to cancel push
68
+ # @param campaignId [Integer] campaignID used to cancel push
69
+ # @param attrs [Hash] Additional data to update or add
70
+ #
71
+ # @return [Iterable::Response] A response object
72
+ #
73
+ # @note An email or UserId is required
74
+ def cancel(campaign_id: nil, attrs: {}, email: nil)
75
+ attrs['email'] = email if email
76
+ attrs['campaignId'] = campaign_id if campaign_id
77
+ Iterable.request(conf, '/push/cancel').post(attrs)
78
+ end
79
+
44
80
  private def messages(**attrs)
45
81
  Iterable.request(conf, '/inApp/getMessages', attrs).get
46
82
  end
@@ -0,0 +1,46 @@
1
+ module Iterable
2
+ ##
3
+ #
4
+ # Interact with /push API endpoints
5
+ #
6
+ # @example Creating push endpoint object
7
+ # # With default config
8
+ # templates = Iterable::Push.new
9
+ # templates.target campaign_id: '12345'
10
+ #
11
+ class Push < ApiResource
12
+ ##
13
+ #
14
+ # Send a push notification to a specific user
15
+ #
16
+ # @param email [String] (optional) User email used to identify user
17
+ # @param campaign_id [Integer] Campaign ID
18
+ # @param attrs [Hash] Additional data to update or add
19
+ #
20
+ # @return [Iterable::Response] A response object
21
+ def target(campaign_id:, email: nil, attrs: {})
22
+ attrs['recipientEmail'] = email if email
23
+ attrs['campaignId'] = campaign_id
24
+ Iterable.request(conf, '/push/target').post(attrs)
25
+ end
26
+
27
+ ##
28
+ #
29
+ # Cancel a push notification to a specific user
30
+ # Must include either an email address AND campaignId, or
31
+ # just a scheduledMessageId provided in the attrs
32
+ #
33
+ # @param email [String] User email to cancel push
34
+ # @param campaignId [Integer] campaignID used to cancel push
35
+ # @param attrs [Hash] Additional data to update or add
36
+ #
37
+ # @return [Iterable::Response] A response object
38
+ #
39
+ # @note An email or UserId is required
40
+ def cancel(email: nil, campaign_id: nil, attrs: {})
41
+ attrs['email'] = email if email
42
+ attrs['campaignId'] = campaign_id if campaign_id
43
+ Iterable.request(conf, '/push/cancel').post(attrs)
44
+ end
45
+ end
46
+ end
@@ -7,7 +7,7 @@ module Iterable
7
7
  class Response
8
8
  extend Forwardable
9
9
 
10
- def_delegators :@resp, :code, :message, :uri
10
+ def_delegators :@resp, :code, :message, :uri, :[]
11
11
 
12
12
  attr_reader :body
13
13
 
data/lib/iterable.rb CHANGED
@@ -22,6 +22,7 @@ files = %w[
22
22
  templates
23
23
  email_templates
24
24
  push_templates
25
+ push
25
26
  users
26
27
  workflows
27
28
  metadata
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iterable-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
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
13
  MIIEeDCCAuCgAwIBAgIBATANBgkqhkiG9w0BAQsFADBBMRAwDgYDVQQDDAdjb250
14
14
  YWN0MRkwFwYKCZImiZPyLGQBGRYJZWwtY2hhdmV6MRIwEAYKCZImiZPyLGQBGRYC
15
- bWUwHhcNMjIwNTE2MTYzNDEwWhcNMjMwNTE2MTYzNDEwWjBBMRAwDgYDVQQDDAdj
15
+ bWUwHhcNMjMxMTAzMTI0NjI4WhcNMjQxMTAyMTI0NjI4WjBBMRAwDgYDVQQDDAdj
16
16
  b250YWN0MRkwFwYKCZImiZPyLGQBGRYJZWwtY2hhdmV6MRIwEAYKCZImiZPyLGQB
17
- GRYCbWUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCZc8MEuKWEAM8X
18
- WCwtJ5yVgTzIbBFWo/Rq9RDBV5QHEGtkxqi4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RFTEhZdXX0cmRTtvmVg
30
+ d47dFqaquB9Y73UB/s/bUcmbCwMAkgtSZ1wS2yHUQZEVEyZ9IVJxRp6a/dXccue3
31
+ U7nins2YnMVIgz7f5+TBv6w6IoUy7A+vcGwVCjU5cJ0E1zuuCtMnTxmgLc8RnTBS
32
+ bfpibGhHkmdDHkEGDAi+bBrx2ebptW7pQeDtaRVrEW3MKfJNes1oJJKfdxb2xtkf
33
+ n63D/wE5M63E3iHSvJVHBNPkpa942SxwN836Ce8/P8E57ylGlVdFmQ1uRIvizdki
34
+ 2FdLmUSM6E2v7Y8eKZD7hmo1Um4eI5POl0XfSaC3FAgG/QJ1P4CaGYaKjT98dOw2
35
+ JWT1CLPse7JUSW9NGp9hbZqX+FdmVho8u3BpQwtAvZB2dIiRLcaqEqxBRnt4jHCq
36
+ vGIdgu0GJEzPUTqCcDfDQUuNIvjN04ZHfnA5Q3m/I6jypQHs9LNqpo1BQzk=
37
37
  -----END CERTIFICATE-----
38
- date: 2022-06-08 00:00:00.000000000 Z
38
+ date: 2023-11-03 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: multi_json
@@ -219,6 +219,20 @@ dependencies:
219
219
  - - "~>"
220
220
  - !ruby/object:Gem::Version
221
221
  version: 0.21.2
222
+ - !ruby/object:Gem::Dependency
223
+ name: simplecov-cobertura
224
+ requirement: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - "~>"
227
+ - !ruby/object:Gem::Version
228
+ version: 2.1.0
229
+ type: :development
230
+ prerelease: false
231
+ version_requirements: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - "~>"
234
+ - !ruby/object:Gem::Version
235
+ version: 2.1.0
222
236
  - !ruby/object:Gem::Dependency
223
237
  name: typhoeus
224
238
  requirement: !ruby/object:Gem::Requirement
@@ -308,6 +322,7 @@ files:
308
322
  - lib/iterable/message_types.rb
309
323
  - lib/iterable/metadata.rb
310
324
  - lib/iterable/metadata_table.rb
325
+ - lib/iterable/push.rb
311
326
  - lib/iterable/push_templates.rb
312
327
  - lib/iterable/request.rb
313
328
  - lib/iterable/response.rb
@@ -320,7 +335,7 @@ licenses:
320
335
  - MIT
321
336
  metadata:
322
337
  rubygems_mfa_required: 'true'
323
- post_install_message:
338
+ post_install_message:
324
339
  rdoc_options:
325
340
  - "--charset=UTF-8"
326
341
  - "--main=README.md"
@@ -337,8 +352,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
337
352
  - !ruby/object:Gem::Version
338
353
  version: '0'
339
354
  requirements: []
340
- rubygems_version: 3.0.3
341
- signing_key:
355
+ rubygems_version: 3.1.6
356
+ signing_key:
342
357
  specification_version: 4
343
358
  summary: Iterable REST API Client
344
359
  test_files: []
metadata.gz.sig CHANGED
Binary file