urbanairship 5.3.0 → 5.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG +29 -0
- data/docs/create_and_send.rst +551 -0
- data/docs/examples.rst +8 -8
- data/docs/index.rst +4 -0
- data/lib/urbanairship.rb +4 -0
- data/lib/urbanairship/common.rb +3 -2
- data/lib/urbanairship/devices/create_and_send.rb +96 -0
- data/lib/urbanairship/devices/email.rb +30 -40
- data/lib/urbanairship/devices/email_notification.rb +92 -0
- data/lib/urbanairship/devices/mms_notification.rb +107 -0
- data/lib/urbanairship/devices/open_channel.rb +89 -44
- data/lib/urbanairship/devices/segment.rb +6 -9
- data/lib/urbanairship/devices/sms.rb +15 -18
- data/lib/urbanairship/devices/sms_notification.rb +54 -0
- data/lib/urbanairship/devices/static_lists.rb +6 -7
- data/lib/urbanairship/version.rb +1 -1
- data/urbanairship.gemspec +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65cc3a3fd4338610d0689454dad88addc5529cd5e8011e839360be5ab49146f3
|
4
|
+
data.tar.gz: af48efa2117b79b9bac9f9c634cff5ce43e572a6eaf46d4d1e940f8678adcaa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 295d9fc6469ce209e9c2b3a108641089e65993a9e6a54673702d8f7fc97c0204a7ee2b22c2e5fed80985c262ee4690586992d0f57d7ccb8fce98fcaa548b0f53
|
7
|
+
data.tar.gz: f91849ee2e0b5f0e8cb4e5897058937b71c140bb25de8c283c450e16971dffc3fa996a179804eed2e6bf765817f6efbe5c4f85294ac8de2741bae71f88b2349b
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
--------------------
|
2
|
+
5.6.1
|
3
|
+
--------------------
|
4
|
+
- Updates EmailNotification templating
|
5
|
+
|
6
|
+
--------------------
|
7
|
+
5.6.0
|
8
|
+
--------------------
|
9
|
+
- Refactors EmailNotification class
|
10
|
+
- Adds Create and Send implementation to Open Channel class
|
11
|
+
|
12
|
+
--------------------
|
13
|
+
5.5.1
|
14
|
+
--------------------
|
15
|
+
- Updates validate_url method
|
16
|
+
|
17
|
+
--------------------
|
18
|
+
5.5.0
|
19
|
+
--------------------
|
20
|
+
- Add Create and Send Functionality for Email
|
21
|
+
- Add endpoints for Create and Send Validation and Scheduling
|
22
|
+
- Add Create and Send Functionality for SMS
|
23
|
+
- Update Rake version from 10.0 to 12.3.3
|
24
|
+
|
25
|
+
--------------------
|
26
|
+
5.4.0
|
27
|
+
--------------------
|
28
|
+
- Change BASE_URL to go.airship.com
|
29
|
+
|
1
30
|
--------------------
|
2
31
|
5.3.0
|
3
32
|
--------------------
|
@@ -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
|