urbanairship 5.7.0 → 8.0.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +2 -2
  3. data/.travis.yml +2 -2
  4. data/CHANGELOG +33 -0
  5. data/README.rst +95 -38
  6. data/docs/attributes.rst +73 -0
  7. data/docs/index.rst +3 -0
  8. data/docs/named_user.rst +22 -0
  9. data/docs/push.rst +24 -0
  10. data/docs/sms.rst +19 -0
  11. data/docs/static_lists.rst +2 -2
  12. data/lib/urbanairship.rb +7 -0
  13. data/lib/urbanairship/ab_tests/ab_test.rb +8 -9
  14. data/lib/urbanairship/automations/automation.rb +11 -11
  15. data/lib/urbanairship/client.rb +34 -12
  16. data/lib/urbanairship/common.rb +110 -43
  17. data/lib/urbanairship/configuration.rb +2 -1
  18. data/lib/urbanairship/custom_events/custom_event.rb +60 -0
  19. data/lib/urbanairship/custom_events/payload.rb +89 -0
  20. data/lib/urbanairship/devices/attribute.rb +54 -0
  21. data/lib/urbanairship/devices/attributes.rb +53 -0
  22. data/lib/urbanairship/devices/channel_tags.rb +2 -2
  23. data/lib/urbanairship/devices/channel_uninstall.rb +10 -10
  24. data/lib/urbanairship/devices/create_and_send.rb +4 -4
  25. data/lib/urbanairship/devices/devicelist.rb +28 -7
  26. data/lib/urbanairship/devices/email.rb +5 -5
  27. data/lib/urbanairship/devices/named_user.rb +22 -12
  28. data/lib/urbanairship/devices/open_channel.rb +22 -23
  29. data/lib/urbanairship/devices/segment.rb +6 -8
  30. data/lib/urbanairship/devices/sms.rb +40 -9
  31. data/lib/urbanairship/devices/static_lists.rb +12 -12
  32. data/lib/urbanairship/push/location.rb +18 -18
  33. data/lib/urbanairship/push/push.rb +5 -5
  34. data/lib/urbanairship/push/schedule.rb +9 -0
  35. data/lib/urbanairship/reports/response_statistics.rb +42 -31
  36. data/lib/urbanairship/version.rb +1 -1
  37. data/urbanairship.gemspec +1 -0
  38. metadata +25 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d4dc107770392a93c88c327e14122fc56cb6ec8fbd17f58984df43d2661d630
4
- data.tar.gz: 75c8ff88b54de9ad97fa3dbf503333bc49cd29c0fcfea2e937fe7cce5a4f3c92
3
+ metadata.gz: 8c91f31ef623a57075fe0acde9fe467d17dc2b0bbb634070c8da11cad54b08f5
4
+ data.tar.gz: eefb6b294cd953148c27fa91bae207888cbb163c6ec620301aa41b243046b46a
5
5
  SHA512:
6
- metadata.gz: e6203f67400dd7581568c1307c688ae842c32c1b67532ead780a62cd3ca9aa9256511a5d6a7f0b9e68f58acc5a3e56bfc4172f5ec4bf24c622285f94f04d4bd3
7
- data.tar.gz: 4c6660cdd60ed9628151f19a448ecbbdde3b43a0bff521c95ef1903874f17610c3194c467623bd37a67f95f9fea9139e1b60acaf818aa2899f0ba7f6c022591d
6
+ metadata.gz: 1c19a821551da7ad1593c91ef7dd0c922dd2f4637ee74a2f29a1fcecce0db4185b09e0fa908fedcc6b124897c3bcd9a41c1070d841b6cef45436ac26a5ba3382
7
+ data.tar.gz: 15bd6f34bf76d038d359b79443f7c12464345ea1cf3cc959254a2350b597a5a91be89940713d3de4a5caba50495cd66ea3cb39cbb6e91ad067d511f8c69af4f8
@@ -15,8 +15,8 @@ Please include link to open issue if applicable.
15
15
 
16
16
  * I've tested for Ruby versions:
17
17
 
18
- - [ ] 2.2.5
19
- - [ ] 2.3.1
18
+ - [ ] 2.6.7
19
+ - [ ] 2.7.2
20
20
 
21
21
  ### Airship Contribution Agreement
22
22
  [Link here](https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform)
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.5
4
- - 2.3.1
3
+ - 2.6.7
4
+ - 2.7.2
data/CHANGELOG CHANGED
@@ -1,3 +1,36 @@
1
+ --------------------
2
+ 8.0.0
3
+ --------------------
4
+ - Updates officially supported versions to 2.6.7 and 2.7.2
5
+ - Fixes headers to reduce warning messages
6
+ - Fixes for multiple mis-set named user urls
7
+ - Fix to automatically convert an integer named user to a string so it can be successfully submitted
8
+ - Adds attribute support for named users
9
+
10
+ --------------------
11
+ 7.0.0
12
+ --------------------
13
+ - Refactors base url naming
14
+
15
+ --------------------
16
+ 6.0.0
17
+ --------------------
18
+ - Creates custom base url, and refactors urls within classes
19
+ - Adds support for sending custom events
20
+
21
+ --------------------
22
+ 5.9.0
23
+ --------------------
24
+ - Adds support for bearer token auth
25
+ - Updates broken code for static lists
26
+ - Adds support for update sms channel
27
+
28
+ --------------------
29
+ 5.8.0
30
+ --------------------
31
+ - Adds scheudling support for PTSO
32
+ - Adds attribute support
33
+
1
34
  --------------------
2
35
  5.7.0
3
36
  --------------------
data/README.rst CHANGED
@@ -14,16 +14,16 @@ Requirements
14
14
 
15
15
  We officially support the following Ruby versions::
16
16
 
17
- 2.2.5
18
- 2.3.1
17
+ 2.6.7
18
+ 2.7.2
19
19
 
20
- Newer versions should work as well.
20
+ Newer 2.x versions should work as well.
21
21
 
22
22
 
23
23
  Functionality
24
24
  =============
25
25
 
26
- Version 5.0 is a major upgrade, as some features have been removed that were present in earlier versions. A more detailed list of changes can be found in the CHANGELOG.
26
+ Version 8.0 is a major upgrade, as we have changed the tested/supported versions of Ruby. A more detailed list of changes can be found in the CHANGELOG.
27
27
 
28
28
 
29
29
  Questions
@@ -38,17 +38,23 @@ Installation
38
38
 
39
39
  If you have the ``bundler`` gem (if not you can get it with
40
40
  ``$ gem install bundler``) add this line to your application's
41
- Gemfile::
41
+ Gemfile:
42
42
 
43
- >>> gem 'urbanairship'
43
+ .. code-block::
44
44
 
45
- And then execute::
45
+ >>> $ gem 'urbanairship'
46
46
 
47
- >>> $ bundle
47
+ And then execute:
48
48
 
49
- OR install it yourself as::
49
+ .. code-block::
50
50
 
51
- >>> gem install urbanairship
51
+ >>> $ bundle
52
+
53
+ OR install it yourself as:
54
+
55
+ .. code-block::
56
+
57
+ >>> $ gem install urbanairship
52
58
 
53
59
 
54
60
  Configuration
@@ -56,27 +62,35 @@ Configuration
56
62
 
57
63
  In your app initialization, you can do something like the following:
58
64
 
59
- >>> require 'urbanairship'
60
- >>> Urbanairship.configure do |config|
61
- >>> config.log_path = '/path/to/your/logfile'
62
- >>> config.log_level = Logger::WARN
63
- >>> config.timeout = 60
64
- >>> end
65
+ .. code-block:: ruby
66
+
67
+ require 'urbanairship'
68
+
69
+ Urbanairship.configure do |config|
70
+ config.server = 'go.airship.eu'
71
+ config.log_path = '/path/to/your/logfile'
72
+ config.log_level = Logger::WARN
73
+ config.timeout = 60
74
+ end
75
+
65
76
 
66
77
  If you want to use a custom logger (e.g Rails.logger), you can do:
67
78
 
68
- >>> require 'urbanairship'
69
- >>> Urbanairship.configure do |config|
70
- >>> config.custom_logger = Rails.logger
71
- >>> config.log_level = Logger::WARN
72
- >>> config.timeout = 60
73
- >>> end
79
+ .. code-block:: ruby
80
+
81
+ require 'urbanairship'
82
+
83
+ Urbanairship.configure do |config|
84
+ config.custom_logger = Rails.logger
85
+ config.log_level = Logger::WARN
86
+ end
74
87
 
75
88
  Available Configurations
76
89
  ------------------------
77
90
 
78
91
  - **log_path**: Allows to define the folder where the log file will be created (the default is nil).
79
92
  - **log_level**: Allows to define the log level and only messages at that level or higher will be printed (the default is INFO).
93
+ - **server**: Allow to define the Airship server you want to use ("go.airship.eu" or "go.urbanairship.com")
80
94
  - **timeout**: Allows to define the request timeout in seconds (the default is 5).
81
95
 
82
96
 
@@ -96,28 +110,71 @@ information.
96
110
  Broadcast to All Devices
97
111
  ------------------------
98
112
 
99
- >>> require 'urbanairship'
100
- >>> UA = Urbanairship
101
- >>> airship = UA::Client.new(key:'application_key', secret:'master_secret')
102
- >>> p = airship.create_push
103
- >>> p.audience = UA.all
104
- >>> p.notification = UA.notification(alert: 'Hello')
105
- >>> p.device_types = UA.all
106
- >>> p.send_push
113
+ .. code-block:: ruby
114
+
115
+ require 'urbanairship'
116
+
117
+ UA = Urbanairship
107
118
 
119
+ airship = UA::Client.new(key:'application_key', secret:'master_secret')
120
+ p = airship.create_push
121
+ p.audience = UA.all
122
+ p.notification = UA.notification(alert: 'Hello')
123
+ p.device_types = UA.all
124
+ p.send_push
108
125
 
109
126
  Simple Tag Push
110
127
  ---------------
111
128
 
112
- >>> require 'urbanairship'
113
- >>> UA = Urbanairship
114
- >>> airship = UA::Client.new(key:'application_key', secret:'master_secret')
115
- >>> p = airship.create_push
116
- >>> p.audience = UA.tag('some_tag')
117
- >>> p.notification = UA.notification(alert: 'Hello')
118
- >>> p.device_types = UA.all
119
- >>> p.send_push
129
+ .. code-block:: ruby
130
+
131
+ require 'urbanairship'
132
+
133
+ UA = Urbanairship
134
+
135
+ airship = UA::Client.new(key:'application_key', secret:'master_secret')
136
+ p = airship.create_push
137
+ p.audience = UA.tag('some_tag')
138
+ p.notification = UA.notification(alert: 'Hello')
139
+ p.device_types = UA.all
140
+ p.send_push
141
+
142
+ Specify the Airship server used to make your requests
143
+ -----------------------------------------------------
144
+ By default, the request will be sent to the 'go.urbanairship.com' server:
145
+
146
+ .. code-block:: ruby
147
+
148
+ require 'urbanairship'
149
+
150
+ Urbanairship::Client.new(key:'application_key', secret:'master_secret')
151
+
152
+ You can change the server globally in the Urbanairship configuration:
153
+
154
+ .. code-block:: ruby
155
+
156
+ require 'urbanairship'
157
+
158
+ Urbanairship.configure do |config|
159
+ config.server = 'go.airship.eu'
160
+ end
161
+
162
+ Urbanairship::Client.new(key:'application_key', secret:'master_secret')
163
+ # request will be sent to the 'go.airship.eu' server
164
+
165
+ Finally, you can change the targeted server on a request basis:
166
+
167
+ .. code-block:: ruby
168
+
169
+ require 'urbanairship'
170
+
171
+ Urbanairship.configure do |config|
172
+ config.server = 'go.airship.eu'
173
+ end
120
174
 
175
+ Urbanairship::Client.new(key:'application_key', secret:'master_secret', server: 'go.urbanairship.com')
176
+ # The Urbanairship configuration is overridden by the client and the
177
+ # request will be sent to the 'go.urbanairship.com' server
121
178
 
122
179
  Contributing
123
180
  ============
@@ -0,0 +1,73 @@
1
+ Attributes
2
+ ==========
3
+
4
+ Set Attribute for a Channel
5
+ ---------------------------
6
+
7
+ The following will set an attribute for a given channel ID.
8
+
9
+ .. code-block:: ruby
10
+
11
+ require 'urbanairship'
12
+ UA = Urbanairship
13
+ airship = UA::Client.new(key:'app_key', secret:'secret_key')
14
+ channel_info = UA::ChannelInfo.new(client: airship)
15
+ channel_info.audience = {"ios_channel": "b8f9b663-0a3b-cf45-587a-be880946e881"}
16
+ channel_info.attributes = {
17
+ "action": "set",
18
+ "key": "favorite_food",
19
+ "value": "cake"
20
+ }
21
+ channel_info.set_attributes
22
+
23
+ .. note::
24
+
25
+ This should return a 200 response
26
+
27
+ Set or Remove Attributes for a Named User
28
+ -----------------------------------------
29
+
30
+ The following example shows you how to set and remove attributes on a given named user.
31
+
32
+ .. code-block:: ruby
33
+
34
+ require 'urbanairship'
35
+ airship = Urbanairship::Client.new(key: 'application_key', secret: 'master_secret')
36
+ named_user = Urbanairship::NamedUser.new(client: airship)
37
+ named_user.named_user_id = 'named_user'
38
+ named_user.update_attributes(attributes: [
39
+ { action: 'set', key: 'first_name', value: 'Firstname' },
40
+ { action: 'remove', key: 'nickname' },
41
+ { action: 'set', key: 'last_name', value: 'Lastname', timestamp: Time.now.utc }
42
+ ])
43
+
44
+ .. note::
45
+
46
+ Timestamp is optional, if missing it will default to 'now'
47
+
48
+ Send Push to Audience with Attribute Specifications
49
+ ---------------------------------------------------
50
+
51
+ This will send a push to an audience who meet the specifications of attribute we
52
+ set here. This example is using a text attribute where we are looking for audience
53
+ members whose favorite food includes 'apple'. Some examples of what this could return
54
+ would be 'apple', 'pineapple', or 'apple pie'.
55
+
56
+ .. code-block:: ruby
57
+
58
+ require 'urbanairship'
59
+ UA = Urbanairship
60
+ airship = UA::Client.new(key:'app_key', secret:'secret_key')
61
+ new_attribute = UA::Attribute.new(client: airship)
62
+ new_attribute.attribute = 'favorite_food'
63
+ new_attribute.operator = 'contains'
64
+ new_attribute.value = 'apple'
65
+ push = airship.create_push
66
+ push.audience = new_attribute.payload
67
+ push.notification = UA.notification(alert: 'Hello')
68
+ push.device_types = ['android', 'ios', 'web']
69
+ push.send_push
70
+
71
+ .. note::
72
+
73
+ This should return a 202 response
data/docs/index.rst CHANGED
@@ -73,6 +73,9 @@ Contents:
73
73
  email.rst
74
74
  open_channels.rst
75
75
  sms.rst
76
+ automations.rst
77
+ ab_tests.rst
78
+ attributes.rst
76
79
 
77
80
 
78
81
  Indices and tables
data/docs/named_user.rst CHANGED
@@ -100,3 +100,25 @@ see `the API documentation
100
100
 
101
101
  A single request may contain an add or remove field, both, or a single set
102
102
  field.
103
+
104
+ Attributes
105
+ ----------
106
+
107
+ Set or remove attributes on a named user. For more information, see `the API documentation
108
+ https://docs.airship.com/api/ua/#operation-api-named_users-named_user_id-attributes-post>`__
109
+
110
+ .. code-block:: ruby
111
+
112
+ require 'urbanairship'
113
+ airship = Urbanairship::Client.new(key: 'application_key', secret: 'master_secret')
114
+ named_user = Urbanairship::NamedUser.new(client: airship)
115
+ named_user.named_user_id = 'named_user'
116
+ named_user.update_attributes(attributes: [
117
+ { action: 'set', key: 'first_name', value: 'Firstname' },
118
+ { action: 'remove', key: 'nickname' },
119
+ { action: 'set', key: 'last_name', value: 'Lastname', timestamp: Time.now.utc }
120
+ ])
121
+
122
+ .. note::
123
+
124
+ Timestamp is optional, if missing it will default to 'now'.
data/docs/push.rst CHANGED
@@ -507,6 +507,30 @@ local time.
507
507
  If the schedule is unsuccessful, an :rb:class:`AirshipFailure` exception
508
508
  will be raised.
509
509
 
510
+ Scheduled Delivery for Optimal Send Time
511
+ ----------------------------------------
512
+
513
+ Scheduled notifications build upon the Push object, and have two other
514
+ components: the scheduled time(s) and an optional name.
515
+
516
+ This example schedules the above notification delivery for optimal send time.
517
+
518
+ .. code-block:: ruby
519
+
520
+ schedule = airship.create_scheduled_push
521
+ schedule.push = push
522
+ schedule.name = "optional name for later reference"
523
+ schedule.schedule = UA.optimal_scheduled_time('2020-02-20')
524
+ response = schedule.send_push
525
+ print ("Created schedule. url: " + response.schedule_url)
526
+
527
+ If the schedule is unsuccessful, an :rb:class:`AirshipFailure` exception
528
+ will be raised.
529
+
530
+ .. note::
531
+
532
+ Make sure the time for UA.optimal_scheduled_time is a date versus a timestamp.
533
+
510
534
 
511
535
  Updating or Canceling a Schedule
512
536
  --------------------------------
data/docs/sms.rst CHANGED
@@ -21,6 +21,25 @@ request with an opted_in key.
21
21
  sms_channel.opted_in = '2018-02-13T11:58:59'
22
22
  sms_channel.register
23
23
 
24
+ Update SMS Channel
25
+ -------------------
26
+
27
+ To update an SMS channel you need a sender, MSISDN, and a channel ID.
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.opted_in = '2020-12-14T11:58:59'
38
+ sms_channel.timezone = 'America/Denver'
39
+ sms_channel.channel_id = 'a1b2c3d4e5f6'
40
+ sms_channel.update
41
+
42
+
24
43
  Opt-Out of SMS Messages
25
44
  -----------------------
26
45
 
@@ -28,7 +28,7 @@ string keys to arbitrary JSON values.
28
28
  airship = UA::Client.new(key:'application_key', secret:'master_secret')
29
29
  static_list = UA::StaticList.new(client: airship)
30
30
  static_list.name = 'list_name'
31
- static_list.create(description: 'description', extras: { 'key' => 'value' })
31
+ static_list.create(description: 'description', extra: {'key': 'value'})
32
32
 
33
33
 
34
34
  Upload List
@@ -71,7 +71,7 @@ Updates the metadata of a static list.
71
71
  airship = UA::Client.new(key:'application_key', secret:'master_secret')
72
72
  static_list = UA::StaticList.new(client: airship)
73
73
  static_list.name = 'list_name'
74
- static_list.update(description: 'description', { 'key' => 'value' })
74
+ static_list.update(description: 'new description', 'extra': {'new_key': 'new_value' })
75
75
 
76
76
 
77
77
  Delete List
data/lib/urbanairship.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'urbanairship/custom_events/custom_event'
2
+ require 'urbanairship/custom_events/payload'
1
3
  require 'urbanairship/push/audience'
2
4
  require 'urbanairship/push/payload'
3
5
  require 'urbanairship/push/schedule'
@@ -10,6 +12,8 @@ require 'urbanairship/devices/email_notification'
10
12
  require 'urbanairship/devices/sms_notification'
11
13
  require 'urbanairship/devices/mms_notification'
12
14
  require 'urbanairship/devices/create_and_send'
15
+ require 'urbanairship/devices/attribute'
16
+ require 'urbanairship/devices/attributes'
13
17
  require 'urbanairship/client'
14
18
  require 'urbanairship/common'
15
19
  require 'urbanairship/configuration'
@@ -30,10 +34,13 @@ require 'urbanairship/ab_tests/experiment'
30
34
  require 'urbanairship/ab_tests/ab_test'
31
35
 
32
36
  module Urbanairship
37
+ extend Urbanairship::CustomEvents::Payload
38
+ extend Urbanairship::CustomEvents
33
39
  extend Urbanairship::Push::Audience
34
40
  extend Urbanairship::Push::Payload
35
41
  extend Urbanairship::Push::Schedule
36
42
  extend Urbanairship::Push
43
+ include Urbanairship::CustomEvents
37
44
  include Urbanairship::Devices
38
45
  include Urbanairship::Reports
39
46
  include Urbanairship::Push