urbanairship 5.0.1 → 5.2.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 +5 -5
- data/.github/CONTRIBUTING.md +1 -1
- data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
- data/CHANGELOG +15 -0
- data/README.rst +8 -0
- data/docs/email.rst +109 -0
- data/docs/open_channels.rst +67 -0
- data/docs/push.rst +37 -0
- data/docs/sms.rst +67 -0
- data/lib/urbanairship.rb +2 -0
- data/lib/urbanairship/configuration.rb +3 -2
- data/lib/urbanairship/devices/email.rb +131 -0
- data/lib/urbanairship/devices/named_user.rb +26 -1
- data/lib/urbanairship/devices/sms.rb +88 -0
- data/lib/urbanairship/loggable.rb +1 -3
- data/lib/urbanairship/push/payload.rb +40 -6
- data/lib/urbanairship/reports/response_statistics.rb +1 -1
- data/lib/urbanairship/version.rb +1 -1
- data/urbanairship.gemspec +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a0a8f54aa42d65833b2a8082b5c1d8f9e9f45e3b6665c4eae63046257a4961d8
|
4
|
+
data.tar.gz: 4951fed75673d26690e4098e76c6408fc1f370b10b11b8c0759eef7cabb408a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f60e2227e91e5f0fc9765756a5aebb379f70c9db7048720bff76e505ebb83d201c726461964e7796a49be10d2aa6f2ff767f116e23c64b3d56ae2699078bae86
|
7
|
+
data.tar.gz: 467c82df1874d9e84ffb65d20a20977f4f2fc016a39d41e3311fec5b17911d7c168103a7ab4275af676bf0f55ff21bc073ce42cfbc0427eaf43b2e8ad8359ca3
|
data/.github/CONTRIBUTING.md
CHANGED
@@ -8,4 +8,4 @@ Please read through the agreement at the URL below.
|
|
8
8
|
|
9
9
|
If you have questions about this agreement or why we need it please contact us at https://support.urbanairship.com/.
|
10
10
|
|
11
|
-
[Contribution Agreement](https://docs.
|
11
|
+
[Contribution Agreement](https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform)
|
@@ -5,6 +5,7 @@ Please include link to open issue if applicable.
|
|
5
5
|
* If applicable
|
6
6
|
|
7
7
|
### Testing
|
8
|
+
- [ ] If these changes added new functionality, I tested them against the live API with real auth
|
8
9
|
- [ ] I wrote tests covering these changes
|
9
10
|
|
10
11
|
* I've tested for Ruby versions:
|
@@ -13,7 +14,7 @@ Please include link to open issue if applicable.
|
|
13
14
|
- [ ] 2.3.1
|
14
15
|
|
15
16
|
### Urban Airship Contribution Agreement
|
16
|
-
https://docs.
|
17
|
+
[Link here](https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform)
|
17
18
|
|
18
19
|
- [ ] I've filled out and signed UA's contribution agreement form.
|
19
20
|
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
--------------------
|
2
|
+
5.2.0
|
3
|
+
--------------------
|
4
|
+
- Updates automatic timeout for API request from 5 seconds to 60
|
5
|
+
- Adds SMS Register implementation. Register, Opt-out, Uninstall, Lookup
|
6
|
+
- Adds SMS Send functionality for Notification object
|
7
|
+
- Updates named_user.rb to include NamedUserUninstaller class
|
8
|
+
- Adds Email Send support
|
9
|
+
- Adds Email Registration support
|
10
|
+
|
11
|
+
--------------------
|
12
|
+
5.1.0
|
13
|
+
--------------------
|
14
|
+
- Adds functionality for custom logger
|
15
|
+
|
1
16
|
--------------------
|
2
17
|
5.0.1
|
3
18
|
--------------------
|
data/README.rst
CHANGED
@@ -56,6 +56,14 @@ In your app initialization, you can do something like the following:
|
|
56
56
|
>>> config.timeout = 60
|
57
57
|
>>> end
|
58
58
|
|
59
|
+
If you want to use a custom logger (e.g Rails.logger), you can do:
|
60
|
+
|
61
|
+
>>> require 'urbanairship'
|
62
|
+
>>> Urbanairship.configure do |config|
|
63
|
+
>>> config.custom_logger = Rails.logger
|
64
|
+
>>> config.log_level = Logger::WARN
|
65
|
+
>>> config.timeout = 60
|
66
|
+
>>> end
|
59
67
|
|
60
68
|
Available Configurations
|
61
69
|
------------------------
|
data/docs/email.rst
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
Email
|
2
|
+
=====
|
3
|
+
|
4
|
+
Register Email Channel
|
5
|
+
----------------------
|
6
|
+
|
7
|
+
.. code-block:: ruby
|
8
|
+
|
9
|
+
require 'urbanairship'
|
10
|
+
UA = Urbanairship
|
11
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
12
|
+
email_channel = UA::Email.new(client: airship)
|
13
|
+
email_channel.type = 'email'
|
14
|
+
email_channel.commercial_opted_in = '2018-10-28T10:34:22'
|
15
|
+
email_channel.address = 'new.name@new.domain.com'
|
16
|
+
email_channel.timezone = 'America/Los_Angeles'
|
17
|
+
email_channel.locale_country = 'US'
|
18
|
+
email_channel.locale_language = 'en'
|
19
|
+
email_channel.register
|
20
|
+
|
21
|
+
.. note::
|
22
|
+
|
23
|
+
The registration of an email channel should yield a 201 response. The address
|
24
|
+
portion must be defined with an email address to register an email channel.
|
25
|
+
There are a few more fields listed on the email object that can be set as well
|
26
|
+
such as transactional_opted_in.
|
27
|
+
|
28
|
+
Uninstall Email Channel
|
29
|
+
-----------------------
|
30
|
+
|
31
|
+
.. code-block:: ruby
|
32
|
+
|
33
|
+
require 'urbanairship'
|
34
|
+
UA = Urbanairship
|
35
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
36
|
+
email_channel = UA::Email.new(client: airship)
|
37
|
+
email_channel.address = 'new.name@new.domain.com'
|
38
|
+
email_channel.uninstall
|
39
|
+
|
40
|
+
.. note::
|
41
|
+
|
42
|
+
This will uninstall an existing email channel. Note that a valid email must
|
43
|
+
be present to make the request.
|
44
|
+
|
45
|
+
Lookup Email Channel
|
46
|
+
--------------------
|
47
|
+
|
48
|
+
.. code-block:: ruby
|
49
|
+
|
50
|
+
require 'urbanairship'
|
51
|
+
UA = Urbanairship
|
52
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
53
|
+
email_channel = UA::Email.new(client: airship)
|
54
|
+
email_channel.address = 'new.name@new.domain.com'
|
55
|
+
email_channel.lookup
|
56
|
+
|
57
|
+
Update Email Channel
|
58
|
+
--------------------
|
59
|
+
|
60
|
+
.. code-block:: ruby
|
61
|
+
|
62
|
+
require 'urbanairship'
|
63
|
+
UA = Urbanairship
|
64
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
65
|
+
email_channel = UA::Email.new(client: airship)
|
66
|
+
email_channel.channel_id = '01234567-890a-bcde-f012-3456789abc0'
|
67
|
+
email_channel.type = 'email'
|
68
|
+
email_channel.commercial_opted_in = '2018-10-28T10:34:22'
|
69
|
+
email_channel.address = 'new.name@new.domain.com'
|
70
|
+
email_channel.timezone = 'America/Los_Angeles'
|
71
|
+
email_channel.locale_country = 'US'
|
72
|
+
email_channel.locale_language = 'en'
|
73
|
+
email_channel.update
|
74
|
+
|
75
|
+
.. note::
|
76
|
+
|
77
|
+
The only thing required to make a request is the channel_id. However, anything
|
78
|
+
that needs to be updated must also be included.
|
79
|
+
|
80
|
+
Email Tags
|
81
|
+
----------
|
82
|
+
|
83
|
+
Using the Email Tag class inheriting from Channel Tags, tags can be added,
|
84
|
+
removed, or set for a single email channel.
|
85
|
+
|
86
|
+
.. code-block:: ruby
|
87
|
+
|
88
|
+
require 'urbanairship'
|
89
|
+
UA = Urbanairship
|
90
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
91
|
+
email_tags = UA::EmailTags.new(client: airship)
|
92
|
+
#set an audience
|
93
|
+
email_tags.set_audience(email_address: 'new.name@new.domain.com')
|
94
|
+
#add a tag
|
95
|
+
email_tags.add(group_name: :group_name, tags: :tag1)
|
96
|
+
#remove a tag
|
97
|
+
email_tags.remove(group_name: :group_name, tags: :tag1)
|
98
|
+
#set a tag
|
99
|
+
email_tags.set(group_name: :group_name, tags: :tag1)
|
100
|
+
#finally, send the request
|
101
|
+
email_tags.send_request
|
102
|
+
|
103
|
+
.. note::
|
104
|
+
|
105
|
+
The code-block above can be used to set, add, or remove tags depending on the
|
106
|
+
needs of the request. An audience or email channel must be set before adding,
|
107
|
+
setting, or removing a tag. It should be noted that add and set functionality cannot
|
108
|
+
be used simultaneously, as well as remove and set. Conversely, add and remove
|
109
|
+
may be used in the same request.
|
@@ -0,0 +1,67 @@
|
|
1
|
+
Open Channels
|
2
|
+
=============
|
3
|
+
|
4
|
+
Create Open Channel
|
5
|
+
-------------------
|
6
|
+
Upon creation an open channel needs an address, boolean opt-in value,
|
7
|
+
and an open platform. Further params are optional, and can be set when
|
8
|
+
updating an open channel.
|
9
|
+
|
10
|
+
.. code-block:: ruby
|
11
|
+
|
12
|
+
require 'urbanairship'
|
13
|
+
UA = Urbanairship
|
14
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
15
|
+
open_channel = UA::OpenChannel.new(client: airship)
|
16
|
+
open_channel.opt_in = true
|
17
|
+
open_channel.address = 'address'
|
18
|
+
open_channel.open_platform = 'platform'
|
19
|
+
open_channel.create()
|
20
|
+
|
21
|
+
.. note::
|
22
|
+
|
23
|
+
The creation of an open channel should yield a 201 response. This is the minimum
|
24
|
+
required to create an open channel. `opt_in` must be a boolean, `address` and
|
25
|
+
`open_platform` must be strings.
|
26
|
+
|
27
|
+
Update Open Channel
|
28
|
+
-------------------
|
29
|
+
Updating an open channel is done by updating the attributes on the open channel.
|
30
|
+
|
31
|
+
.. code-block:: ruby
|
32
|
+
|
33
|
+
require 'urbanairship'
|
34
|
+
UA = Urbanairship
|
35
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
36
|
+
open_channel = UA::OpenChannel.new(client: airship)
|
37
|
+
open_channel.opt_in = true
|
38
|
+
open_channel.address = 'address'
|
39
|
+
open_channel.open_platform = 'platform'
|
40
|
+
open_channel.channel_id = 'channel_id'
|
41
|
+
open_channel.tags= ['tag1', 'tag2']
|
42
|
+
open_channel.identifiers = 'identifiers'
|
43
|
+
|
44
|
+
#creates the open_channel with all the listed attributes
|
45
|
+
open_channel.create()
|
46
|
+
|
47
|
+
#updates open_channel tags
|
48
|
+
open_channel.tags = ['tag3', 'tag4']
|
49
|
+
open_channel.update(set_tags: true)
|
50
|
+
|
51
|
+
.. note::
|
52
|
+
|
53
|
+
Not all of the attributes listed above have to be present to update an open
|
54
|
+
channel.
|
55
|
+
|
56
|
+
Lookup Open Channel
|
57
|
+
-------------------
|
58
|
+
Looking up an open channel is done by passing the channel_id in question to
|
59
|
+
the lookup method.
|
60
|
+
|
61
|
+
.. code-block:: ruby
|
62
|
+
|
63
|
+
require 'urbanairship'
|
64
|
+
UA = Urbanairship
|
65
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
66
|
+
open_channel = UA::OpenChannel.new(client: airship)
|
67
|
+
open_channel.lookup(channel_id: 'channel_id')
|
data/docs/push.rst
CHANGED
@@ -287,6 +287,43 @@ platform-specific alerts, and we set a number of other platform-specific options
|
|
287
287
|
)
|
288
288
|
)
|
289
289
|
|
290
|
+
**Example Email Override**
|
291
|
+
|
292
|
+
.. code-block:: ruby
|
293
|
+
|
294
|
+
push.notification = UA.notification(
|
295
|
+
alert: 'Hello World!',
|
296
|
+
email: UA.email(
|
297
|
+
subject: 'Hello Inbox!',
|
298
|
+
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>',
|
299
|
+
plaintext_body: 'Plaintext version goes here [[ua-unsubscribe href=\"http://unsubscribe.urbanairship.com/email/success.html\"]]',
|
300
|
+
message_type: 'commercial',
|
301
|
+
sender_name: 'Airship',
|
302
|
+
sender_address: 'team@urbanairship.com',
|
303
|
+
reply_to: 'no-reply@urbanairship.com'
|
304
|
+
)
|
305
|
+
)
|
306
|
+
|
307
|
+
.. note::
|
308
|
+
|
309
|
+
Email override MUST be used for sending emails.
|
310
|
+
|
311
|
+
**Example SMS Override**
|
312
|
+
|
313
|
+
.. code-block:: ruby
|
314
|
+
|
315
|
+
push.notification = UA.notification(
|
316
|
+
alert: 'Hello World!',
|
317
|
+
sms: UA.sms(
|
318
|
+
alert: 'Hello SMS!',
|
319
|
+
expiry: '2018-04-01T12:00:00'
|
320
|
+
)
|
321
|
+
)
|
322
|
+
|
323
|
+
.. note::
|
324
|
+
|
325
|
+
SMS override MUST be used for sending SMS messages.
|
326
|
+
|
290
327
|
**Example Open Platform Override**
|
291
328
|
|
292
329
|
.. code-block:: ruby
|
data/docs/sms.rst
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
SMS Channel
|
2
|
+
===========
|
3
|
+
|
4
|
+
Register SMS Channel
|
5
|
+
--------------------
|
6
|
+
|
7
|
+
SMS channels need a sender, and MSISDN, upon registration. The opted_in key
|
8
|
+
is optional. The opted_in key represents the time when explicit permission was
|
9
|
+
received from the user to receive messages. The following is an example of a
|
10
|
+
request with an opted_in key.
|
11
|
+
|
12
|
+
|
13
|
+
.. code-block:: ruby
|
14
|
+
|
15
|
+
require 'urbanairship'
|
16
|
+
UA = Urbanairship
|
17
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
18
|
+
sms_channel = UA::Sms.new(client: airship)
|
19
|
+
sms_channel.msisdn = '15035556789'
|
20
|
+
sms_channel.sender = '12345'
|
21
|
+
sms_channel.opted_in = '2018-02-13T11:58:59'
|
22
|
+
sms_channel.register
|
23
|
+
|
24
|
+
Opt-Out of SMS Messages
|
25
|
+
-----------------------
|
26
|
+
|
27
|
+
Opting out of SMS messaging requires a sender and a MSISDN to be set.
|
28
|
+
|
29
|
+
.. code-block:: ruby
|
30
|
+
|
31
|
+
require 'urbanairship'
|
32
|
+
UA = Urbanairship
|
33
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
34
|
+
sms_channel = UA::Sms.new(client: airship)
|
35
|
+
sms_channel.msisdn = '15035556789'
|
36
|
+
sms_channel.sender = '12345'
|
37
|
+
sms_channel.opt_out
|
38
|
+
|
39
|
+
Uninstall SMS Channel
|
40
|
+
---------------------
|
41
|
+
|
42
|
+
Uninstalling SMS messaging requires a sender and a MSISDN to be set.
|
43
|
+
|
44
|
+
.. code-block:: ruby
|
45
|
+
|
46
|
+
require 'urbanairship'
|
47
|
+
UA = Urbanairship
|
48
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
49
|
+
sms_channel = UA::Sms.new(client: airship)
|
50
|
+
sms_channel.msisdn = '15035556789'
|
51
|
+
sms_channel.sender = '12345'
|
52
|
+
sms_channel.uninstall
|
53
|
+
|
54
|
+
SMS Channel Lookup
|
55
|
+
------------------
|
56
|
+
|
57
|
+
Looking up an SMS channel requires a sender and an MSISDN to be set.
|
58
|
+
|
59
|
+
.. code-block:: ruby
|
60
|
+
|
61
|
+
require 'urbanairship'
|
62
|
+
UA = Urbanairship
|
63
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
64
|
+
sms_channel = UA::Sms.new(client: airship)
|
65
|
+
sms_channel.msisdn = '15035556789'
|
66
|
+
sms_channel.sender = '12345'
|
67
|
+
sms_channel.lookup
|
data/lib/urbanairship.rb
CHANGED
@@ -4,6 +4,8 @@ require 'urbanairship/push/schedule'
|
|
4
4
|
require 'urbanairship/push/push'
|
5
5
|
require 'urbanairship/devices/segment'
|
6
6
|
require 'urbanairship/devices/channel_uninstall'
|
7
|
+
require 'urbanairship/devices/sms'
|
8
|
+
require 'urbanairship/devices/email'
|
7
9
|
require 'urbanairship/client'
|
8
10
|
require 'urbanairship/common'
|
9
11
|
require 'urbanairship/configuration'
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Urbanairship
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :log_path, :log_level, :timeout
|
3
|
+
attr_accessor :custom_logger, :log_path, :log_level, :timeout
|
4
4
|
|
5
5
|
def initialize
|
6
|
+
@custom_logger = nil
|
6
7
|
@log_path = nil
|
7
8
|
@log_level = Logger::INFO
|
8
|
-
@timeout =
|
9
|
+
@timeout = 60
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'urbanairship'
|
2
|
+
require 'urbanairship/devices/channel_tags'
|
3
|
+
|
4
|
+
module Urbanairship
|
5
|
+
module Devices
|
6
|
+
class Email
|
7
|
+
include Urbanairship::Common
|
8
|
+
include Urbanairship::Loggable
|
9
|
+
attr_accessor :address,
|
10
|
+
:commercial_opted_in,
|
11
|
+
:commercial_opted_out,
|
12
|
+
:locale_country,
|
13
|
+
:locale_language,
|
14
|
+
:timezone,
|
15
|
+
:transactional_opted_in,
|
16
|
+
:transactional_opted_out,
|
17
|
+
:type,
|
18
|
+
:channel_id
|
19
|
+
|
20
|
+
def initialize(client: required('client'))
|
21
|
+
@client = client
|
22
|
+
@address = nil
|
23
|
+
@commercial_opted_in = nil
|
24
|
+
@commercial_opted_out = nil
|
25
|
+
@locale_country = nil
|
26
|
+
@locale_language = nil
|
27
|
+
@timezone = nil
|
28
|
+
@transactional_opted_in = nil
|
29
|
+
@transactional_opted_out = nil
|
30
|
+
@type = nil
|
31
|
+
@channel_id = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def register
|
35
|
+
fail ArgumentError, 'address must be set to register email channel' if @address.nil?
|
36
|
+
|
37
|
+
payload = {
|
38
|
+
'channel': {
|
39
|
+
'address': @address,
|
40
|
+
'commercial_opted_in': @commercial_opted_in,
|
41
|
+
'commercial_opted_out': @commercial_opted_out,
|
42
|
+
'locale_country': @locale_country,
|
43
|
+
'locale_language': @locale_language,
|
44
|
+
'timezone': @timezone,
|
45
|
+
'transactional_opted_in': @transactional_opted_in,
|
46
|
+
'transactional_opted_out': @transactional_opted_out,
|
47
|
+
'type': @type
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
response = @client.send_request(
|
52
|
+
method: 'POST',
|
53
|
+
body: JSON.dump(payload),
|
54
|
+
url: CHANNEL_URL + 'email',
|
55
|
+
content_type: 'application/json'
|
56
|
+
)
|
57
|
+
logger.info("Registering email channel with address #{@address}")
|
58
|
+
response
|
59
|
+
end
|
60
|
+
|
61
|
+
def uninstall
|
62
|
+
fail ArgumentError, 'address must be set to register email channel' if @address.nil?
|
63
|
+
|
64
|
+
payload = {
|
65
|
+
'email_address': @address
|
66
|
+
}
|
67
|
+
|
68
|
+
response = @client.send_request(
|
69
|
+
method: 'POST',
|
70
|
+
body: JSON.dump(payload),
|
71
|
+
url: CHANNEL_URL + 'email/uninstall',
|
72
|
+
content_type: 'application/json'
|
73
|
+
)
|
74
|
+
logger.info("Uninstalling email channel with address #{@address}")
|
75
|
+
response
|
76
|
+
end
|
77
|
+
|
78
|
+
def lookup
|
79
|
+
fail ArgumentError, 'address must be set to lookup email channel' if @address.nil?
|
80
|
+
|
81
|
+
response = @client.send_request(
|
82
|
+
method: 'GET',
|
83
|
+
url: CHANNEL_URL + 'email/' + @address
|
84
|
+
)
|
85
|
+
logger.info("Looking up email channel with address #{@address}")
|
86
|
+
response
|
87
|
+
end
|
88
|
+
|
89
|
+
def update
|
90
|
+
fail ArgumentError, 'address must be set to update email channel' if @channel_id.nil?
|
91
|
+
|
92
|
+
channel_data = {}
|
93
|
+
|
94
|
+
channel_data['address'] = @address if @address
|
95
|
+
channel_data['commercial_opted_in'] = @commercial_opted_in if @commercial_opted_in
|
96
|
+
channel_data['commercial_opted_out'] = @commercial_opted_out if @commercial_opted_out
|
97
|
+
channel_data['locale_country'] = @locale_country if @locale_country
|
98
|
+
channel_data['locale_language'] = @locale_language if @locale_language
|
99
|
+
channel_data['timezone'] = @timezone if @timezone
|
100
|
+
channel_data['transactional_opted_in'] = @transactional_opted_in if @transactional_opted_in
|
101
|
+
channel_data['transactional_opted_out'] = @transactional_opted_out if @transactional_opted_out
|
102
|
+
channel_data['type'] = @type if @type
|
103
|
+
|
104
|
+
payload = {channel: channel_data}
|
105
|
+
|
106
|
+
response = @client.send_request(
|
107
|
+
method: 'PUT',
|
108
|
+
url: CHANNEL_URL + 'email/' + @channel_id,
|
109
|
+
body: JSON.dump(payload),
|
110
|
+
content_type: 'application/json'
|
111
|
+
)
|
112
|
+
logger.info("Updating email channel with address #{@address}")
|
113
|
+
response
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
class EmailTags < ChannelTags
|
118
|
+
include Urbanairship::Common
|
119
|
+
|
120
|
+
def initialize(client: required('client'))
|
121
|
+
super(client: client)
|
122
|
+
@url = CHANNEL_URL + 'email/tags'
|
123
|
+
end
|
124
|
+
|
125
|
+
def set_audience(email_address: required('email_address'))
|
126
|
+
@audience['email_address'] = email_address
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
@@ -83,5 +83,30 @@ module Urbanairship
|
|
83
83
|
@data_attribute = 'named_users'
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
class NamedUserUninstaller
|
88
|
+
include Urbanairship::Common
|
89
|
+
include Urbanairship::Loggable
|
90
|
+
attr_accessor :named_user_ids
|
91
|
+
|
92
|
+
def initialize(client: required('client'))
|
93
|
+
@client = client
|
94
|
+
@named_user_ids = nil
|
95
|
+
end
|
96
|
+
|
97
|
+
def uninstall
|
98
|
+
payload = {}
|
99
|
+
payload['named_user_id'] = @named_user_ids
|
100
|
+
|
101
|
+
response = @client.send_request(
|
102
|
+
method: 'POST',
|
103
|
+
body: JSON.dump(payload),
|
104
|
+
url: NAMED_USER_URL + '/uninstall',
|
105
|
+
content_type: 'application/json'
|
106
|
+
)
|
107
|
+
logger.info { "Uninstalled named_user_ids #{@named_user_ids} " }
|
108
|
+
response
|
109
|
+
end
|
110
|
+
end
|
86
111
|
end
|
87
|
-
end
|
112
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'urbanairship'
|
2
|
+
|
3
|
+
module Urbanairship
|
4
|
+
module Devices
|
5
|
+
class Sms
|
6
|
+
include Urbanairship::Common
|
7
|
+
include Urbanairship::Loggable
|
8
|
+
attr_accessor :msisdn, :sender, :opted_in, :sender
|
9
|
+
|
10
|
+
def initialize(client: required('client'))
|
11
|
+
@client = client
|
12
|
+
@sender = nil
|
13
|
+
@msisdn = nil
|
14
|
+
@opted_in = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def register
|
18
|
+
fail ArgumentError, 'sender must be set to register sms channel' if @sender.nil?
|
19
|
+
fail ArgumentError, 'msisdn must be set to register sms channel' if @msisdn.nil?
|
20
|
+
|
21
|
+
payload = {
|
22
|
+
'msisdn': @msisdn,
|
23
|
+
'sender': @sender,
|
24
|
+
'opted_in': @opted_in
|
25
|
+
}
|
26
|
+
|
27
|
+
response = @client.send_request(
|
28
|
+
method: 'POST',
|
29
|
+
body: JSON.dump(payload),
|
30
|
+
url: CHANNEL_URL + 'sms',
|
31
|
+
content_type: 'application/json'
|
32
|
+
)
|
33
|
+
logger.info("Registering SMS channel with msisdn #{@msisdn}")
|
34
|
+
response
|
35
|
+
end
|
36
|
+
|
37
|
+
def opt_out
|
38
|
+
fail ArgumentError, 'sender must be set to register sms channel' if @sender.nil?
|
39
|
+
fail ArgumentError, 'msisdn must be set to register sms channel' if @msisdn.nil?
|
40
|
+
|
41
|
+
payload = {
|
42
|
+
'msisdn': @msisdn,
|
43
|
+
'sender': @sender,
|
44
|
+
}
|
45
|
+
|
46
|
+
response = @client.send_request(
|
47
|
+
method: 'POST',
|
48
|
+
body: JSON.dump(payload),
|
49
|
+
url: CHANNEL_URL + 'sms/opt-out',
|
50
|
+
content_type: 'application/json'
|
51
|
+
)
|
52
|
+
logger.info("Opting Out of SMS messages for #{@msisdn}")
|
53
|
+
response
|
54
|
+
end
|
55
|
+
|
56
|
+
def uninstall
|
57
|
+
fail ArgumentError, 'sender must be set to register sms channel' if @sender.nil?
|
58
|
+
fail ArgumentError, 'msisdn must be set to register sms channel' if @msisdn.nil?
|
59
|
+
|
60
|
+
payload = {
|
61
|
+
'msisdn': @msisdn,
|
62
|
+
'sender': @sender,
|
63
|
+
}
|
64
|
+
|
65
|
+
response = @client.send_request(
|
66
|
+
method: 'POST',
|
67
|
+
body: JSON.dump(payload),
|
68
|
+
url: CHANNEL_URL + 'sms/uninstall',
|
69
|
+
content_type: 'application/json'
|
70
|
+
)
|
71
|
+
logger.info("Uninstalling SMS channel for #{@msisdn}")
|
72
|
+
response
|
73
|
+
end
|
74
|
+
|
75
|
+
def lookup
|
76
|
+
fail ArgumentError,'msisdn is required for lookup' if @msisdn.nil?
|
77
|
+
fail ArgumentError,'sender is required for lookup' if @sender.nil?
|
78
|
+
|
79
|
+
response = @client.send_request(
|
80
|
+
method: 'GET',
|
81
|
+
url: CHANNEL_URL + 'sms/' + @msisdn + '/' + @sender
|
82
|
+
)
|
83
|
+
logger.info { "Retrieved information for msisdn #{@msisdn}" }
|
84
|
+
response
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'logger'
|
2
2
|
|
3
|
-
|
4
3
|
module Urbanairship
|
5
4
|
module Loggable
|
6
|
-
|
7
5
|
def logger
|
8
6
|
Loggable.logger
|
9
7
|
end
|
10
8
|
|
11
9
|
def self.logger
|
12
|
-
@logger ||= Loggable.create_logger
|
10
|
+
@logger ||= Urbanairship.configuration.custom_logger || Loggable.create_logger
|
13
11
|
end
|
14
12
|
|
15
13
|
def self.create_logger
|
@@ -8,7 +8,7 @@ module Urbanairship
|
|
8
8
|
# Notification Object for a Push Payload
|
9
9
|
def notification(alert: nil, ios: nil, android: nil, amazon: nil,
|
10
10
|
web: nil, wns: nil, open_platforms: nil,
|
11
|
-
actions: nil, interactive: nil)
|
11
|
+
actions: nil, interactive: nil, sms: nil, email: nil)
|
12
12
|
payload = compact_helper({
|
13
13
|
alert: alert,
|
14
14
|
ios: ios,
|
@@ -17,10 +17,12 @@ module Urbanairship
|
|
17
17
|
web: web,
|
18
18
|
wns: wns,
|
19
19
|
actions: actions,
|
20
|
-
interactive: interactive
|
20
|
+
interactive: interactive,
|
21
|
+
sms: sms,
|
22
|
+
email: email
|
21
23
|
})
|
22
24
|
if open_platforms
|
23
|
-
open_platforms.each {|platform, overrides|
|
25
|
+
open_platforms.each {|platform, overrides|
|
24
26
|
payload[platform] = overrides
|
25
27
|
}
|
26
28
|
end
|
@@ -124,7 +126,7 @@ module Urbanairship
|
|
124
126
|
end
|
125
127
|
|
126
128
|
# Open Platform specific portion of Push Notification Object.
|
127
|
-
def open_platform(alert: nil, title: nil, summary: nil,
|
129
|
+
def open_platform(alert: nil, title: nil, summary: nil,
|
128
130
|
extra: nil, media_attachment: nil, interactive: nil)
|
129
131
|
compact_helper({
|
130
132
|
alert: alert,
|
@@ -171,6 +173,38 @@ module Urbanairship
|
|
171
173
|
compact_helper({ type: type, button_actions: button_actions })
|
172
174
|
end
|
173
175
|
|
176
|
+
#SMS specific portion of Push Notification Object
|
177
|
+
def sms(alert: nil, expiry: nil)
|
178
|
+
compact_helper({
|
179
|
+
alert: alert,
|
180
|
+
expiry: expiry
|
181
|
+
})
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
#Email specific portion of Push Notification Object
|
186
|
+
def email(bypass_opt_in_level: nil, html_body: nil, message_type: required('message_type'),
|
187
|
+
plaintext_body: required('plaintext_body'), reply_to: required('reply_to'),
|
188
|
+
sender_address: required('sender_address'), sender_name: required('sender_name'),
|
189
|
+
subject: required('subject'))
|
190
|
+
fail ArgumentError, 'Message type must not be nil' if message_type.nil?
|
191
|
+
fail ArgumentError, 'Plaintext Body must not be nil' if plaintext_body.nil?
|
192
|
+
fail ArgumentError, 'Reply To must not be nil' if reply_to.nil?
|
193
|
+
fail ArgumentError, 'Sender address must not be nil' if sender_address.nil?
|
194
|
+
fail ArgumentError, 'Sender name must not be nil' if sender_name.nil?
|
195
|
+
fail ArgumentError, 'Subject must not be nil' if subject.nil?
|
196
|
+
compact_helper({
|
197
|
+
bypass_opt_in_level: bypass_opt_in_level,
|
198
|
+
html_body: html_body,
|
199
|
+
message_type: message_type,
|
200
|
+
plaintext_body: plaintext_body,
|
201
|
+
reply_to: reply_to,
|
202
|
+
sender_address: sender_address,
|
203
|
+
sender_name: sender_name,
|
204
|
+
subject: subject
|
205
|
+
})
|
206
|
+
end
|
207
|
+
|
174
208
|
def all
|
175
209
|
'all'
|
176
210
|
end
|
@@ -233,9 +267,9 @@ module Urbanairship
|
|
233
267
|
fail ArgumentError, 'type must not be nil' if type.nil?
|
234
268
|
|
235
269
|
mapping = {
|
236
|
-
big_picture: 'big_picture', big_text: 'big_text', inbox: 'lines'
|
270
|
+
big_picture: 'big_picture', big_text: 'big_text', inbox: 'lines'
|
237
271
|
}
|
238
|
-
|
272
|
+
|
239
273
|
compact_helper({
|
240
274
|
type: type,
|
241
275
|
mapping[type.to_sym] => content,
|
data/lib/urbanairship/version.rb
CHANGED
data/urbanairship.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_runtime_dependency 'rest-client', '>= 1.4', '< 4.0'
|
31
31
|
|
32
|
-
spec.add_development_dependency 'bundler', '
|
32
|
+
spec.add_development_dependency 'bundler', '>= 1'
|
33
33
|
spec.add_development_dependency 'guard-rspec'
|
34
34
|
spec.add_development_dependency 'pry', '~> 0'
|
35
35
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urbanairship
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Urban Airship
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -34,14 +34,14 @@ dependencies:
|
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '1'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1'
|
47
47
|
- !ruby/object:Gem::Dependency
|
@@ -141,14 +141,17 @@ files:
|
|
141
141
|
- docs/channel_uninstall.rst
|
142
142
|
- docs/conf.py
|
143
143
|
- docs/devices.rst
|
144
|
+
- docs/email.rst
|
144
145
|
- docs/examples.rst
|
145
146
|
- docs/exceptions.rst
|
146
147
|
- docs/index.rst
|
147
148
|
- docs/location.rst
|
148
149
|
- docs/named_user.rst
|
150
|
+
- docs/open_channels.rst
|
149
151
|
- docs/push.rst
|
150
152
|
- docs/reports.rst
|
151
153
|
- docs/segment.rst
|
154
|
+
- docs/sms.rst
|
152
155
|
- docs/static_lists.rst
|
153
156
|
- docs/tags.rst
|
154
157
|
- example/pusher.rb
|
@@ -159,9 +162,11 @@ files:
|
|
159
162
|
- lib/urbanairship/devices/channel_tags.rb
|
160
163
|
- lib/urbanairship/devices/channel_uninstall.rb
|
161
164
|
- lib/urbanairship/devices/devicelist.rb
|
165
|
+
- lib/urbanairship/devices/email.rb
|
162
166
|
- lib/urbanairship/devices/named_user.rb
|
163
167
|
- lib/urbanairship/devices/open_channel.rb
|
164
168
|
- lib/urbanairship/devices/segment.rb
|
169
|
+
- lib/urbanairship/devices/sms.rb
|
165
170
|
- lib/urbanairship/devices/static_lists.rb
|
166
171
|
- lib/urbanairship/loggable.rb
|
167
172
|
- lib/urbanairship/push/audience.rb
|
@@ -193,8 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
198
|
- !ruby/object:Gem::Version
|
194
199
|
version: '0'
|
195
200
|
requirements: []
|
196
|
-
|
197
|
-
rubygems_version: 2.4.5.1
|
201
|
+
rubygems_version: 3.0.1
|
198
202
|
signing_key:
|
199
203
|
specification_version: 4
|
200
204
|
summary: Ruby Gem for using the Urban Airship API
|