urbanairship 5.4.0 → 5.7.0

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: 6f260b6f4cd6af338f251cc34c473eeb49063c7eb0daa5ad3a569f0d90a3584d
4
- data.tar.gz: 160fcdd2a23b6dea6008b09b03f22a65d601555590810b3d951394aa24d8f51e
3
+ metadata.gz: 6d4dc107770392a93c88c327e14122fc56cb6ec8fbd17f58984df43d2661d630
4
+ data.tar.gz: 75c8ff88b54de9ad97fa3dbf503333bc49cd29c0fcfea2e937fe7cce5a4f3c92
5
5
  SHA512:
6
- metadata.gz: 4103a2061061355627af7cfee8879fd231a8eccda95a1f5ad1a4af3be9471d8177844e8de8b9a5ba832607249cbf67928df77951da03317d8e9a6c9df209ec0b
7
- data.tar.gz: 4c0e50e54f17166a734c929f33b912b9afcdb593edadf7549bf2a55b548e10b21cbcca69d687fa58dfcae2fa31579a28f355485a6034055933cd6229fdf85e49
6
+ metadata.gz: e6203f67400dd7581568c1307c688ae842c32c1b67532ead780a62cd3ca9aa9256511a5d6a7f0b9e68f58acc5a3e56bfc4172f5ec4bf24c622285f94f04d4bd3
7
+ data.tar.gz: 4c6660cdd60ed9628151f19a448ecbbdde3b43a0bff521c95ef1903874f17610c3194c467623bd37a67f95f9fea9139e1b60acaf818aa2899f0ba7f6c022591d
data/.gitignore CHANGED
@@ -9,6 +9,7 @@
9
9
  /pkg/
10
10
  /spec/reports/
11
11
  /tmp/
12
+ /csv_file
12
13
 
13
14
  # App
14
15
  urbanairship.log
data/CHANGELOG CHANGED
@@ -1,3 +1,33 @@
1
+ --------------------
2
+ 5.7.0
3
+ --------------------
4
+ - Adds Automation support
5
+ - Adds A/B test support
6
+
7
+ --------------------
8
+ 5.6.1
9
+ --------------------
10
+ - Updates EmailNotification templating
11
+
12
+ --------------------
13
+ 5.6.0
14
+ --------------------
15
+ - Refactors EmailNotification class
16
+ - Adds Create and Send implementation to Open Channel class
17
+
18
+ --------------------
19
+ 5.5.1
20
+ --------------------
21
+ - Updates validate_url method
22
+
23
+ --------------------
24
+ 5.5.0
25
+ --------------------
26
+ - Add Create and Send Functionality for Email
27
+ - Add endpoints for Create and Send Validation and Scheduling
28
+ - Add Create and Send Functionality for SMS
29
+ - Update Rake version from 10.0 to 12.3.3
30
+
1
31
  --------------------
2
32
  5.4.0
3
33
  --------------------
@@ -0,0 +1,162 @@
1
+ A/B Tests
2
+ =========
3
+
4
+ In this client, we format A/B tests with three nesting components. The first is the Variant,
5
+ the difference between one kind of push and another. The Variant is a part of the Experiment
6
+ object, with many variants in an array. Lastly. AbTest handles what Experiments along with their Variants
7
+ get sent to the various API endpoints. Basic pushes can be added straight to the Variant object
8
+ on the push instance variable, or a Push object can be created, and the payload applied to the
9
+ Variant object. For more information on this please visit: https://docs.airship.com/api/ua/#tag/a/b-tests
10
+
11
+ List Existing A/B Tests
12
+ -----------------------
13
+
14
+ This endpoint will return the existing A/B tests on a project.
15
+
16
+ .. code-block:: ruby
17
+
18
+ require 'urbanairship'
19
+ UA = Urbanairship
20
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
21
+ ab_test = UA::AbTest.new(client: airship)
22
+ ab_test.limit = 5
23
+ ab_test.list_ab_test
24
+
25
+ .. note::
26
+
27
+ Should return a 200 HTTP status code as well as a list of existing A/B tests with a
28
+ default offset and a limit of 5. The limit and offset are optional here.
29
+
30
+ Create A/B Test
31
+ ----------------
32
+
33
+ As described above, the creation of an A/B Test consists of creating a few objects, grabbing
34
+ pertinent data out of them, and creating an A/B Test that is as complicated or as simple as you
35
+ like. In some cases, it might be easier to assign the payload values yourself, but as pushes,
36
+ and the tests themselves get more complicated, it is easier to let the objects do the work for you.
37
+
38
+
39
+ .. code-block:: ruby
40
+
41
+ require 'urbanairship'
42
+ UA = Urbanairship
43
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
44
+ variant_one = UA::Variant.new(client: airship)
45
+ variant_one.push = {
46
+ "notification": {
47
+ "alert": "I love cereal"
48
+ }
49
+ }
50
+ variant_two = UA::Variant.new(client: airship)
51
+ variant_two.push = {
52
+ "notification": {
53
+ "alert": "I prefer oatmeal"
54
+ }
55
+ }
56
+ experiment = UA::Experiment.new(client: airship)
57
+ experiment.name = 'Neat experiment'
58
+ experiment.description = 'See how neat we can get'
59
+ experiment.audience = 'all'
60
+ experiment.device_types = 'all'
61
+ experiment.variants << variant_one.payload
62
+ experiment.variants << variant_two.payload
63
+ ab_test = UA::AbTest.new(client: airship)
64
+ ab_test.experiment_object = experiment.payload
65
+ ab_test.create_ab_test
66
+
67
+ .. note::
68
+
69
+ Should return a 201 HTTP status code as well as other information detailing specific
70
+ information (such as push_id) for the newly created A/B Test.
71
+
72
+ List Scheduled A/B Tests
73
+ ------------------------
74
+
75
+ This will list all the scheduled A/B Tests for a project.
76
+
77
+ .. code-block:: ruby
78
+
79
+ require 'urbanairship'
80
+ UA = Urbanairship
81
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
82
+ ab_test = UA::AbTest.new(client: airship)
83
+ ab_test.list_scheduled_ab_test
84
+
85
+ .. note::
86
+
87
+ Should return a 200 HTTP status code. Here, you can also apply limit and offset by assigning
88
+ values to the instance variables on the AbTest object.
89
+
90
+ Delete A/B Test
91
+ ----------------
92
+
93
+ This will delete an A/B Test with a given experiment ID.
94
+
95
+ .. code-block:: ruby
96
+
97
+ require 'urbanairship'
98
+ UA = Urbanairship
99
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
100
+ ab_test = UA::AbTest.new(client: airship)
101
+ ab_test.experiment_id = '<experiment_id>'
102
+ ab_test.delete_ab_test
103
+
104
+ .. note::
105
+
106
+ Response should be a 200 HTTP Response
107
+
108
+ Validate A/B Test
109
+ ------------------
110
+
111
+ Very similar to the create A/B Test endpoint, this will validate an A/B Test to
112
+ see if it is formatted properly.
113
+
114
+ .. code-block:: ruby
115
+
116
+ require 'urbanairship'
117
+ UA = Urbanairship
118
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
119
+ variant_one = UA::Variant.new(client: airship)
120
+ variant_one.push = {
121
+ "notification": {
122
+ "alert": "I love cereal"
123
+ }
124
+ }
125
+ variant_two = UA::Variant.new(client: airship)
126
+ variant_two.push = {
127
+ "notification": {
128
+ "alert": "I prefer oatmeal"
129
+ }
130
+ }
131
+ experiment = UA::Experiment.new(client: airship)
132
+ experiment.name = 'Neat experiment'
133
+ experiment.description = 'See how neat we can get'
134
+ experiment.audience = 'all'
135
+ experiment.device_types = 'all'
136
+ experiment.variants << variant_one.payload
137
+ experiment.variants << variant_two.payload
138
+ ab_test = UA::AbTest.new(client: airship)
139
+ ab_test.experiment_object = experiment.payload
140
+ ab_test.validate_ab_test
141
+
142
+ .. note::
143
+
144
+ Should return a 200 HTTP status code.
145
+
146
+ Individual A/B Test Lookup
147
+ --------------------------
148
+
149
+ This will lookup a specific A/B Test with a given experiment_id
150
+
151
+ .. code-block:: ruby
152
+
153
+ require 'urbanairship'
154
+ UA = Urbanairship
155
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
156
+ ab_test = UA::AbTest.new(client: airship)
157
+ ab_test.experiment_id = '<experiment_id>'
158
+ ab_test.lookup_ab_test
159
+
160
+ .. note::
161
+
162
+ Should return a 200 HTTP status code
@@ -0,0 +1,212 @@
1
+ Automations
2
+ ===========
3
+
4
+ The Automation class harnesses the Pipeline class in order to provide functionality
5
+ for creating, listing, validating, updating, and deleting pipelines. There are a lot
6
+ of moving parts that go into creating a pipeline, so please view our docs on that
7
+ topic here: https://docs.airship.com/api/ua/#schemas%2fpipelineobject
8
+
9
+ List Existing Automations
10
+ -------------------------
11
+
12
+ This is for viewing existing pipeleines for a project. There are optional parameters
13
+ that can be passed into the URI to have control over what pipelines are returned. In the
14
+ following example a limit query of 5 will be added to the URI.
15
+
16
+ .. code-block:: ruby
17
+
18
+ require 'urbanairship'
19
+ UA = Urbanairship
20
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
21
+ automation = UA::Automation.new(client: airship)
22
+ automation.limit = 5
23
+ automation.list_automations
24
+
25
+ .. note::
26
+
27
+ Should return a 200 HTTP status code, and 5 of the most recent Automations
28
+
29
+ Create Automation
30
+ -----------------
31
+
32
+ This will use the Pipeline model to create an automation. You may add several
33
+ pipelines objects to create several automations/pipelines at once. The example
34
+ below adds two. If you would like to just add one pipeline, forgo the array,
35
+ and assign the pipeline payload directly to automation.pipeline_object.
36
+
37
+ .. code-block:: ruby
38
+
39
+ require 'urbanairship'
40
+ UA = Urbanairship
41
+ airship = UA::Client.new(key:'<app_key>', secret:'<app_secret>')
42
+ pipeline_one = UA::Pipeline.new(client: airship)
43
+ pipeline_one.enabled = true
44
+ pipeline_one.immediate_trigger = {
45
+ "tag_added": {
46
+ "tag": "new_customer",
47
+ "group": "crm"
48
+ }
49
+ }
50
+ pipeline_one.outcome = {
51
+ "push": {
52
+ "audience": "triggered",
53
+ "device_types": "all",
54
+ "notification": {
55
+ "alert": "Hello new customer!"
56
+ }
57
+ }
58
+ }
59
+ pipeline_two = UA::Pipeline.new(client: airship)
60
+ pipeline_two.enabled = true
61
+ pipeline_two.immediate_trigger = {
62
+ "tag_added": {
63
+ "tag": "new_customer",
64
+ "group": "crm"
65
+ }
66
+ }
67
+ pipeline_two.outcome = {
68
+ "push": {
69
+ "audience": "triggered",
70
+ "device_types": "all",
71
+ "notification": {
72
+ "alert": "Here is a different second alert!"
73
+ }
74
+ }
75
+ }
76
+ pipelines = [pipeline_one.payload, pipeline_two.payload]
77
+ automation = UA::Automation.new(client: airship)
78
+ automation.pipeline_object = pipelines
79
+ automation.create_automation
80
+
81
+ .. note::
82
+
83
+ Should return a 201 HTTP status code.
84
+
85
+ List Deleted Automations
86
+ ------------------------
87
+
88
+ This is for viewing deleted pipeleines for a project. The optional param here is for "start";
89
+ a timestamp of the starting element for paginating results in the format of YYYY-MM-DD.
90
+
91
+ .. code-block:: ruby
92
+
93
+ require 'urbanairship'
94
+ UA = Urbanairship
95
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
96
+ automation = UA::Automation.new(client: airship)
97
+ automation.start = 2020-02-20
98
+ automation.list_deleted_automations
99
+
100
+ .. note::
101
+
102
+ Should return a 200 HTTP status code, and the deleted automations from either most current
103
+ or from a given start date.
104
+
105
+ Validate Automation
106
+ -------------------
107
+
108
+ This endpoint is a lot like the create automation endpoint, the basic set up is the same,
109
+ only difference here is the method selected.
110
+
111
+ .. code-block:: ruby
112
+
113
+ require 'urbanairship'
114
+ UA = Urbanairship
115
+ airship = UA::Client.new(key:'<app_key>', secret:'<app_secret>')
116
+ pipeline = UA::Pipeline.new(client: airship)
117
+ pipeline.enabled = true
118
+ pipeline.immediate_trigger = {
119
+ "tag_added": {
120
+ "tag": "new_customer",
121
+ "group": "crm"
122
+ }
123
+ }
124
+ pipeline.outcome = {
125
+ "push": {
126
+ "audience": "triggered",
127
+ "device_types": "all",
128
+ "notification": {
129
+ "alert": "Hello new customer!"
130
+ }
131
+ }
132
+ }
133
+ automation = UA::Automation.new(client: airship)
134
+ automation.pipeline_object = pipeline.payload
135
+ automation.validate_automation
136
+
137
+ .. note::
138
+
139
+ Should return a 200 HTTP status code.
140
+
141
+ Individual Automation Lookup
142
+ ----------------------------
143
+
144
+ This is for looking up a single automation with a given ID.
145
+
146
+ .. code-block:: ruby
147
+
148
+ require 'urbanairship'
149
+ UA = Urbanairship
150
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
151
+ automation = UA::Automation.new(client: airship)
152
+ automation.pipeline_id = '86ad9239-373d-d0a5-d5d8-04fed18f79bc'
153
+ automation.lookup_automation
154
+
155
+ .. note::
156
+
157
+ Should return a 200 HTTP status code, and the payload for the automation in question.
158
+
159
+ Update Automation
160
+ -----------------
161
+
162
+ This is for updating an existing automation. You must include the full payload from a POST
163
+ response, with the updates that you want to make within the payload.
164
+
165
+ .. code-block:: ruby
166
+
167
+ require 'urbanairship'
168
+ UA = Urbanairship
169
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
170
+ pipeline = UA::Pipeline.new(client: airship)
171
+ pipeline.enabled = true
172
+ pipeline.immediate_trigger = {
173
+ "tag_added": {
174
+ "tag": "new_tag_update",
175
+ "group": "Locale"
176
+ }
177
+ }
178
+ pipeline.outcome = {
179
+ "push": {
180
+ "audience": "triggered",
181
+ "device_types": "all",
182
+ "notification": {
183
+ "alert": "Newly created alert message!"
184
+ }
185
+ }
186
+ }
187
+ automation = UA::Automation.new(client: airship)
188
+ automation.pipeline_id = '0f927674-918c-31ef-51ca-e96fdd234da4'
189
+ automation.pipeline_object = pipeline.payload
190
+ automation.update_automation
191
+
192
+ .. note::
193
+
194
+ Should return a 200 HTTP status code.
195
+
196
+ Delete Automation
197
+ -----------------
198
+
199
+ This is for deleting a pipeline with a given ID.
200
+
201
+ .. code-block:: ruby
202
+
203
+ require 'urbanairship'
204
+ UA = Urbanairship
205
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
206
+ automation = UA::Automation.new(client: airship)
207
+ automation.pipeline_id = '86ad9239-373d-d0a5-d5d8-04fed18f79bc'
208
+ automation.delete_automation
209
+
210
+ .. note::
211
+
212
+ Response should be a 204 No Content
@@ -0,0 +1,551 @@
1
+ Create and Send
2
+ ===============
3
+
4
+ The CreateAndSend class uses various notification classes as the portion of the notification
5
+ part of the payload. Different channels that harness Create and Send will require slightly different
6
+ implementation, and therefore, a different notification object.
7
+
8
+ For more context see EmailNotification and SmsNotification to see how each class method
9
+ operates, and how that is used to create the notification portion of the Create and Send payload.
10
+
11
+ For background information visit out docs here: https://docs.airship.com/api/ua/#tag/create-and-send
12
+
13
+ Create and Send Validation
14
+ --------------------------
15
+
16
+ Here, the payload that is being validated is one that would be used for email override.
17
+ However, this validation method should work on any other create and send notification objects.
18
+
19
+ .. code-block:: ruby
20
+
21
+ require 'urbanairship'
22
+ UA = Urbanairship
23
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
24
+ email_notification = UA::EmailNotification.new(client: airship)
25
+ email_notification.bypass_opt_in_level = false
26
+ email_notification.html_body = "<h2>Richtext body goes here</h2><p>Wow!</p><p><a data-ua-unsubscribe=\"1\" title=\"unsubscribe\" href=\"http://unsubscribe.urbanairship.com/email/success.html\">Unsubscribe</a></p>"
27
+ email_notification.message_type = 'transactional'
28
+ email_notification.plaintext_body = 'Plaintext version goes here [[ua-unsubscribe href=\"http://unsubscribe.urbanairship.com/email/success.html\"]]'
29
+ email_notification.reply_to = '<reply_to address>'
30
+ email_notification.sender_address = '<sender_address>'
31
+ email_notification.sender_name = 'Sender Name'
32
+ email_notification.subject = 'Subject Line'
33
+ override = email_notification.email_override
34
+ send_it = UA::CreateAndSend.new(client: airship)
35
+ send_it.addresses = [
36
+ {
37
+ "ua_address": "test@example.com",
38
+ "ua_commercial_opted_in": "2019-12-29T10:34:22"
39
+ }
40
+ ]
41
+ send_it.device_types = [ "email" ]
42
+ send_it.campaigns = ["winter sale", "west coast"]
43
+ send_it.notification = email_notification.email_override
44
+ send_it.validate
45
+
46
+ .. note::
47
+
48
+ Should return a 200 HTTP status code.
49
+
50
+ Schedule Create and Send Operation
51
+ ----------------------------------
52
+
53
+ Here, the payload that is being scheduled is one that would be used for email override.
54
+ However, this operation method should schedule any other create and send notification objects.
55
+
56
+ .. code-block:: ruby
57
+
58
+ require 'urbanairship'
59
+ UA = Urbanairship
60
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
61
+ email_notification = UA::EmailNotification.new(client: airship)
62
+ email_notification.bypass_opt_in_level = false
63
+ email_notification.html_body = "<h2>Richtext body goes here</h2><p>Wow!</p><p><a data-ua-unsubscribe=\"1\" title=\"unsubscribe\" href=\"http://unsubscribe.urbanairship.com/email/success.html\">Unsubscribe</a></p>"
64
+ email_notification.message_type = 'transactional'
65
+ email_notification.plaintext_body = 'Plaintext version goes here [[ua-unsubscribe href=\"http://unsubscribe.urbanairship.com/email/success.html\"]]'
66
+ email_notification.reply_to = '<reply_to address>'
67
+ email_notification.sender_address = '<sender_address>'
68
+ email_notification.sender_name = 'Sender Name'
69
+ email_notification.subject = 'Subject Line'
70
+ override = email_notification.email_override
71
+ send_it = UA::CreateAndSend.new(client: airship)
72
+ send_it.addresses = [
73
+ {
74
+ "ua_address": "test@example.com",
75
+ "ua_commercial_opted_in": "2019-12-29T10:34:22"
76
+ }
77
+ ]
78
+ send_it.device_types = [ "email" ]
79
+ send_it.campaigns = ["winter sale", "west coast"]
80
+ send_it.notification = email_notification.email_override
81
+ send_it.name = 'Name for scheduled create and send'
82
+ send_it.scheduled_time = "2019-13-29T10:34:22"
83
+ send_it.schedule
84
+
85
+ .. note::
86
+
87
+ Should return a 201 HTTP status code.
88
+
89
+ Create and Send to Email Channels
90
+ =================================
91
+
92
+ You will need to create an EmailNotification object before adding that to the notification
93
+ field as the create and send object.
94
+
95
+ Create and Send with Email Override
96
+ -----------------------------------
97
+
98
+ The first few lines of code are creating a EmailNotification object, and assigning
99
+ instance variables to the object. The line of code here:
100
+ `override = email_notification.email_override`
101
+ is using a class method on EmailNotification specific for an email override in order
102
+ to format the payload correctly for the notification portion of the CreateAndSend object.
103
+
104
+ .. code-block:: ruby
105
+
106
+ require 'urbanairship'
107
+ UA = Urbanairship
108
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
109
+ email_notification = UA::EmailNotification.new(client: airship)
110
+ email_notification.bypass_opt_in_level = false
111
+ email_notification.html_body = "<h2>Richtext body goes here</h2><p>Wow!</p><p><a data-ua-unsubscribe=\"1\" title=\"unsubscribe\" href=\"http://unsubscribe.urbanairship.com/email/success.html\">Unsubscribe</a></p>"
112
+ email_notification.message_type = 'transactional'
113
+ email_notification.plaintext_body = 'Plaintext version goes here [[ua-unsubscribe href=\"http://unsubscribe.urbanairship.com/email/success.html\"]]'
114
+ email_notification.reply_to = '<reply_to address>'
115
+ email_notification.sender_address = '<sender_address>'
116
+ email_notification.sender_name = 'Sender Name'
117
+ email_notification.subject = 'Subject Line'
118
+ override = email_notification.email_override
119
+ send_it = UA::CreateAndSend.new(client: airship)
120
+ send_it.addresses = [
121
+ {
122
+ "ua_address": "test@example.com",
123
+ "ua_commercial_opted_in": "2019-12-29T10:34:22"
124
+ }
125
+ ]
126
+ send_it.device_types = [ "email" ]
127
+ send_it.campaigns = ["winter sale", "west coast"]
128
+ send_it.notification = override
129
+ send_it.create_and_send
130
+
131
+ .. note::
132
+
133
+ Should return a 202 Accepted HTTP response.
134
+
135
+ Create and Send with Email Inline Template/Template ID
136
+ ------------------------------------------------------
137
+
138
+ The first few lines of code are creating a EmailNotification object, and assigning
139
+ instance variables to the object. The line of code here:
140
+ `inline_template = email_notification.email_with_inline_template`
141
+ is using a class method on EmailNotification specific for an inline template. This goes
142
+ on to format the payload correctly for the notification portion of the CreateAndSend object
143
+ shown in the line of code here:
144
+ `send_it.notification = inline_template`
145
+
146
+ .. code-block:: ruby
147
+
148
+ require 'urbanairship'
149
+ UA = Urbanairship
150
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
151
+ email_notification = UA::EmailNotification.new(client: airship)
152
+ email_notification.message_type = 'transactional'
153
+ email_notification.reply_to = 'reply_to_this@email.com'
154
+ email_notification.sender_address = 'sends_from_this@email.com'
155
+ email_notification.sender_name = 'Sender Name'
156
+ email_notification.template_id = "<template_id>"
157
+ inline_template = email_notification.email_with_inline_template
158
+ send_it = UA::CreateAndSend.new(client: airship)
159
+ send_it.addresses = [
160
+ {
161
+ "ua_address": "test@example.com",
162
+ "ua_commercial_opted_in": "2019-12-29T10:34:22"
163
+ }
164
+ ]
165
+ send_it.device_types = [ "email" ]
166
+ send_it.campaigns = ["winter sale", "west coast"]
167
+ send_it.notification = inline_template
168
+ send_it.create_and_send
169
+
170
+ .. note::
171
+
172
+ Should return a 202 Accepted HTTP response.
173
+
174
+ Create and Send with Email Inline Template/Fields
175
+ -------------------------------------------------
176
+
177
+ The first few lines of code are creating a EmailNotification object, and assigning
178
+ instance variables to that object. The line of code here:
179
+ `inline_template = email_notification.email_with_inline_template`
180
+ is using a class method on EmailNotification specific for an inline template. This goes
181
+ on to format the payload correctly for the notification portion of the CreateAndSend object
182
+ shown in the line of code here:
183
+ `send_it.notification = inline_template`
184
+
185
+ .. code-block:: ruby
186
+
187
+ require 'urbanairship'
188
+ UA = Urbanairship
189
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
190
+ email_notification = UA::EmailNotification.new(client: airship)
191
+ email_notification.message_type = 'transactional'
192
+ email_notification.reply_to = 'reply_to_this@email.com'
193
+ email_notification.sender_address = 'sends_from_this@email.com'
194
+ email_notification.sender_name = 'Sender Name''
195
+ email_notification.subject= "I'm sending some stuff"
196
+ email_notification.plaintext_body = 'Plaintext version goes here [[ua-unsubscribe href=\"http://unsubscribe.urbanairship.com/email/success.html\"]]'
197
+ inline_template = email_notification.email_with_inline_template
198
+ send_it = UA::CreateAndSend.new(client: airship)
199
+ send_it.addresses = [
200
+ {
201
+ "ua_address": "example@test.com",
202
+ "ua_commercial_opted_in": "2019-12-29T10:34:22"
203
+ }
204
+ ]
205
+ send_it.device_types = [ "email" ]
206
+ send_it.campaigns = ["winter sale", "west coast"]
207
+ send_it.notification = inline_template
208
+ send_it.create_and_send
209
+
210
+ .. note::
211
+
212
+ Should return a 202 Accepted HTTP response.
213
+
214
+ Create and Send to SMS Channels
215
+ ================================
216
+
217
+ Create and Send to SMS Override
218
+ -------------------------------
219
+
220
+ The first few lines of code are creating a SmsNotification object, and assigning
221
+ instance variables to that object. The line of code here:
222
+ `override = notification.sms_notification_override`
223
+ is using a class method on SmsNotification specific for a sms override. This goes
224
+ on to format the payload correctly for the notification portion of the CreateAndSend object
225
+ shown in the line of code here:
226
+ `send_it.notification = inline_template`
227
+
228
+ .. code-block:: ruby
229
+
230
+ require 'urbanairship'
231
+ UA = Urbanairship
232
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
233
+ notification = UA::SmsNotification.new(client: airship)
234
+ notification.sms_alert = "A shorter alert with a link for SMS users to click https://www.mysite.com/amazingly/long/url-that-takes-up-lots-of-characters"
235
+ notification.generic_alert = "A generic alert sent to all platforms without overrides in device_types"
236
+ notification.expiry = 172800
237
+ notification.shorten_links = true
238
+ override = notification.sms_notification_override
239
+ send_it = UA::CreateAndSend.new(client: airship)
240
+ send_it.addresses = [
241
+ {
242
+ "ua_msisdn": "15558675309",
243
+ "ua_sender": "12345",
244
+ "ua_opted_in": "2018-11-11T18:45:30"
245
+ }
246
+ ]
247
+ send_it.device_types = [ "sms" ]
248
+ send_it.notification = override
249
+ send_it.campaigns = ["winter sale", "west coast"]
250
+ send_it.create_and_send
251
+
252
+ .. note::
253
+
254
+ Should return a 202 Accepted HTTP response.
255
+
256
+ Create and Send to SMS With Inline Template
257
+ -------------------------------------------
258
+
259
+ The first few lines of code are creating a SmsNotification object, and assigning
260
+ instance variables to that object. The line of code here:
261
+ `template = notification.sms_inline_template`
262
+ is using a class method on SmsNotification specific for a sms inline template. This goes
263
+ on to format the payload correctly for the notification portion of the CreateAndSend object
264
+ shown in the line of code here:
265
+ `send_it.notification = template`
266
+
267
+ .. code-block:: ruby
268
+
269
+ require 'urbanairship'
270
+ UA = Urbanairship
271
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
272
+ notification = UA::SmsNotification.new(client: airship)
273
+ notification.sms_alert = "Hi, {{customer.first_name}}, your {{#each cart}}{{this.name}}{{/each}} are ready to pickup at our {{customer.location}} location!"
274
+ notification.expiry = 172800
275
+ notification.shorten_links = true
276
+ template = notification.sms_inline_template
277
+ send_it = UA::CreateAndSend.new(client: airship)
278
+ send_it.addresses = [
279
+ {
280
+ "ua_msisdn": "15558675309",
281
+ "ua_sender": "12345",
282
+ "ua_opted_in": "2018-11-11T18:45:30",
283
+ "customer": {
284
+ "first_name": "Customer Name",
285
+ "last_name": "Last Name",
286
+ "location": "Location",
287
+ },
288
+ "cart": [
289
+ {
290
+ "name": "Robot Unicorn",
291
+ "qty": 1
292
+ },
293
+ {
294
+ "name": "Holy Hand Grenade of Antioch",
295
+ "qty": 1
296
+ }
297
+ ]
298
+ }
299
+ ]
300
+ send_it.device_types = [ "sms" ]
301
+ send_it.notification = template
302
+ send_it.campaigns = [ "order-pickup" ]
303
+ send_it.create_and_send
304
+
305
+ .. note::
306
+
307
+ Should return a 202 Accepted HTTP response.
308
+
309
+ Create and Send to SMS With Template ID
310
+ ---------------------------------------
311
+
312
+ The first few lines of code are creating a SmsNotification object, and assigning
313
+ instance variables to that object. The line of code here:
314
+ `template = notification.sms_inline_template`
315
+ is using a class method on SmsNotification specific for a sms template ID. This goes
316
+ on to format the payload correctly for the notification portion of the CreateAndSend object
317
+ shown in the line of code here:
318
+ `send_it.notification = template`
319
+
320
+ .. code-block:: ruby
321
+
322
+ require 'urbanairship'
323
+ UA = Urbanairship
324
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
325
+ notification = UA::SmsNotification.new(client: airship)
326
+ notification.template_id = <sms_template_id_for_app>
327
+ notification.expiry = 172800
328
+ notification.shorten_links = true
329
+ template = notification.sms_inline_template
330
+ send_it = UA::CreateAndSend.new(client: airship)
331
+ send_it.addresses = [
332
+ {
333
+ "ua_msisdn": "15558675309",
334
+ "ua_sender": "12345",
335
+ "ua_opted_in": "2018-11-11T18:45:30",
336
+ "customer": {
337
+ "first_name": "Customer Name",
338
+ "last_name": "Last Name",
339
+ "location": "Your Location",
340
+ },
341
+ "cart": [
342
+ {
343
+ "name": "Robot Unicorn",
344
+ "qty": 1
345
+ },
346
+ {
347
+ "name": "Holy Hand Grenade of Antioch",
348
+ "qty": 1
349
+ }
350
+ ]
351
+ }
352
+ ]
353
+ send_it.device_types = [ "sms" ]
354
+ send_it.notification = template
355
+ send_it.campaigns = [ "order-pickup" ]
356
+ send_it.create_and_send
357
+
358
+ .. note::
359
+
360
+ Should return a 202 Accepted HTTP response.
361
+
362
+ Create and Send to MMS Channels
363
+ ================================
364
+
365
+ Create and Send to MMS Override
366
+ -------------------------------
367
+
368
+ The first few lines of code are creating a MmsNotification object, and assigning
369
+ instance variables to that object. The line of code here:
370
+ `mms_notification = override.mms_override`
371
+ is using a class method on MmsNotification specific for a sms template ID. This goes
372
+ on to format the payload correctly for the notification portion of the CreateAndSend object
373
+ shown in the line of code here:
374
+ `send_it.notification = mms_notification`
375
+
376
+ .. code-block:: ruby
377
+
378
+ require 'urbanairship'
379
+ UA = Urbanairship
380
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
381
+ override = UA::MmsNotification.new(client: airship)
382
+ override.fallback_text = "See https://urbanairship.com for double rainbows!"
383
+ override.shorten_links = true
384
+ override.content_length = 238686
385
+ override.content_type = "image/jpeg"
386
+ override.url = "https://www.metoffice.gov.uk/binaries/content/gallery/mohippo/images/learning/learn-about-the-weather/rainbows/full_featured_double_rainbow_at_savonlinna_1000px.jpg"
387
+ override.text = "A double rainbow is a wonderful sight where you get two spectacular natural displays for the price of one."
388
+ override.subject = "Double Rainbows"
389
+ mms_notification = override.mms_override
390
+ send_it = UA::CreateAndSend.new(client: airship)
391
+ send_it.addresses = [
392
+ {
393
+ "ua_msisdn": "15558675309",
394
+ "ua_sender": "12345",
395
+ "ua_opted_in": "2018-11-11T18:45:30",
396
+ }
397
+ ]
398
+ send_it.device_types = [ "mms" ]
399
+ send_it.notification = mms_notification
400
+ send_it.campaigns = ["winter sale", "west coast"]
401
+ send_it.create_and_send
402
+
403
+ .. note::
404
+
405
+ Should return a 202 Accepted HTTP response.
406
+
407
+ Create and Send to MMS Template with ID
408
+ ---------------------------------------
409
+
410
+ The first few lines of code are creating a MmsNotification object, and assigning
411
+ instance variables to that object. The line of code here:
412
+ `mms_notification = override.mms_template_with_id`
413
+ is using a class method on MmsNotification specific for a sms template ID. This goes
414
+ on to format the payload correctly for the notification portion of the CreateAndSend object
415
+ shown in the line of code here:
416
+ `send_it.notification = mms_notification`
417
+
418
+ .. code-block:: ruby
419
+
420
+ require 'urbanairship'
421
+ UA = Urbanairship
422
+ airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
423
+ override = UA::MmsNotification.new(client: airship)
424
+ override.template_id = "<existing_template_id>"
425
+ override.shorten_links = true
426
+ override.content_length = 19309
427
+ override.content_type = "image/jpeg"
428
+ override.url = "https://images-na.ssl-images-amazon.com/images/I/71eUHxwlMKL._AC_SX425_.jpg"
429
+ mms_notification = override.mms_template_with_id
430
+ send_it = UA::CreateAndSend.new(client: airship)
431
+ send_it.addresses = [
432
+ {
433
+ "ua_msisdn": "123456789",
434
+ "ua_sender": "12345",
435
+ "ua_opted_in": "2020-01-30T18:45:30",
436
+ "customer": {
437
+ "first_name": "Phil",
438
+ "last_name": "Leash",
439
+ }
440
+ }
441
+ ]
442
+ send_it.device_types = [ "mms" ]
443
+ send_it.notification = mms_notification
444
+ send_it.create_and_send
445
+
446
+
447
+ .. note::
448
+
449
+ Should return a 202 Accepted HTTP response.
450
+
451
+ Create and Send to MMS with Inline Template
452
+ -------------------------------------------
453
+
454
+ The first few lines of code are creating a MmsNotification object, and assigning
455
+ instance variables to that object. The line of code here:
456
+ `mms_notification = override.mms_inline_template`
457
+ is using a class method on MmsNotification specific for a sms template ID. This goes
458
+ on to format the payload correctly for the notification portion of the CreateAndSend object
459
+ shown in the line of code here:
460
+ `send_it.notification = mms_notification`
461
+
462
+ .. code-block:: ruby
463
+
464
+ require 'urbanairship'
465
+ UA = Urbanairship
466
+ airship = UA::Client.new(key:'<app_key>', secret:'<master_secret>')
467
+ override = UA::MmsNotification.new(client: airship)
468
+ override.subject = "Subject"
469
+ override.fallback_text = "Fallback text"
470
+ override.text = "Some slide text"
471
+ override.content_length = 123100
472
+ override.content_type = "image/jpeg"
473
+ override.url = 'image ending in allowed image types'
474
+ mms_notification = override.mms_inline_template
475
+ send_it = UA::CreateAndSend.new(client: airship)
476
+ send_it.addresses = [
477
+ {
478
+ "ua_msisdn": "123456789",
479
+ "ua_sender": "12345",
480
+ "ua_opted_in": "2020-01-30T18:45:30"
481
+ }
482
+ ]
483
+ send_it.device_types = [ "mms" ]
484
+ send_it.notification = mms_notification
485
+ send_it.create_and_send
486
+
487
+ .. note::
488
+
489
+ Should return a 202 Accepted HTTP response.
490
+
491
+ Create and Send to Open Channels
492
+ ================================
493
+
494
+ Create and Send to Open Channels with Template ID
495
+ -------------------------------------------------
496
+
497
+ The first few lines of code are creating an OpenChannel object, and assigning
498
+ instance variables to that object. This is essentially creating the payload that
499
+ will be passed to notification portion of the CreateAndSend class, which ultimately
500
+ is sending a fully constructed payload to the API.
501
+
502
+ .. code-block:: ruby
503
+
504
+ require 'urbanairship'
505
+ UA = Urbanairship
506
+ airship = UA::Client.new(key:'<app_key>', secret:'<master_secret>')
507
+ open_channel_notification = UA::OpenChannel.new(client:airship)
508
+ open_channel_notification.open_platform = 'smart_fridge'
509
+ open_channel_notification.template_id = "<template_id>"
510
+ send_it = UA::CreateAndSend.new(client: airship)
511
+ send_it.addresses = [
512
+ {
513
+ "ua_address": "<ua_address>",
514
+ "name": "Jane"
515
+ }
516
+ ]
517
+ send_it.device_types = [ 'open::smart_fridge' ]
518
+ send_it.notification = open_channel_notification.
519
+ send_it.campaigns = ["winter sale", "west coast"]
520
+ send_it.create_and_send
521
+
522
+ Create and Send to Open Channels Override
523
+ ------------------------------------------
524
+
525
+ The first few lines of code are creating an OpenChannel object, and assigning
526
+ instance variables to that object. This is essentially creating the payload that
527
+ will be passed to notification portion of the CreateAndSend class, which ultimately
528
+ is sending a fully constructed payload to the API.
529
+
530
+ .. code-block:: ruby
531
+
532
+ require 'urbanairship'
533
+ UA = Urbanairship
534
+ airship = UA::Client.new(key:'<app_key>', secret:'<master_secret>')
535
+ open_channel_notification = UA::OpenChannel.new(client:airship)
536
+ open_channel_notification.open_platform = 'smart_fridge'
537
+ open_channel_notification.alert = 'a general alert for all open channels'
538
+ open_channel_notification.platform_alert = 'an alert for specific open channel platforms'
539
+ open_channel_notification.media_attachment = 'https://example.com/cat_standing_up.jpeg'
540
+ open_channel_notification.title = 'That\'s pretty neat!'
541
+ send_it = UA::CreateAndSend.new(client: airship)
542
+ send_it.addresses = [
543
+ {
544
+ "ua_address": "<ua_address>",
545
+ "name": "Jane"
546
+ }
547
+ ]
548
+ send_it.device_types = [ 'open::smart_fridge' ]
549
+ send_it.notification = open_channel_notification,open_channel_override
550
+ send_it.campaigns = ["winter sale", "west coast"]
551
+ send_it.create_and_send