urbanairship 9.1.1 → 9.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ae923395b8a39ca5c21187a0f20a1a722e493758dd39a6896345a6982469d3a
4
- data.tar.gz: 71f45b035e2db2726b77a543e15c1538c95d88def506586413f61486f48e9b0a
3
+ metadata.gz: 4eec597e4717d02b44f452c7d1d634402e5957d5fe9df6a9cf052e3bb30d9357
4
+ data.tar.gz: 14be54ad8f59edcaa4ce0bfead99249571aa0f6c81d766956886abe994482a5f
5
5
  SHA512:
6
- metadata.gz: 88ad9d5d947d5c545d14626cc5c02704f019077842f0349d1975c498419b812ec89f07dbd28bd91d8c36394132b42a06ac6998264b67d71bfb051416ce8185a4
7
- data.tar.gz: dfefec7dbe7349ecba36d935fab3ba1a0a88290ce527fc1b27ce47bd036b5f5526f238d7be7e5170160fe349f2dc313387e8f787f6bfebfa8a4e7cfb72c004e3
6
+ metadata.gz: 01f091cd844d9dfc38ea6104d4a37aef5afabff3b7ee5bc9c3fc479c492a8dc15c3dbdf71a675c77c6d4138559cdee206dc505438c2c3dabc2b6e7487287add6
7
+ data.tar.gz: 9f5706357ceec8f731412fa966ec40f75ad07e0dec229e2673e56793ebfe382e6e01791ba3fc6ee3e024bbc410cca22de527f222c50ebdf013aa5488298d7839
@@ -17,6 +17,9 @@ jobs:
17
17
  uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
18
18
  with:
19
19
  ruby-version: ${{ matrix.ruby-version }}
20
+ bundler: none
21
+ - name: Install bundler 2.4
22
+ run: gem install bundler -v 2.4.22
20
23
  - name: Install dependencies
21
24
  run: bundle install
22
25
  - name: Run tests
data/CHANGELOG CHANGED
@@ -1,108 +1,137 @@
1
- --------------------
2
- 9.1.1
3
- --------------------
1
+ ## 9.3.0
2
+
3
+ - Adds Oauth support
4
+ - Changes default base URL from "go.airship.com" to "api.asnapius.com"
5
+
6
+ ---
7
+
8
+ ## 9.2.0
9
+
10
+ - Adds support for iOS Live Activity and Android Live Update
11
+ - Adds bypass_frequency_limits, bypass_holdout_groups, no_throttle, omit_from_activity_log, personalization, redact_payload parameters for push options
12
+
13
+ ---
14
+
15
+ ## 9.1.1
16
+
4
17
  - Adds thread_id Support
5
18
 
6
- --------------------
7
- 9.1.0
8
- --------------------
19
+ ---
20
+
21
+ ## 9.1.0
22
+
9
23
  - All requests will now automatically attempt to authenticate with bearer token auth if a
10
- token is included in the instantiation of the client. Previously, only custom events requests
11
- could use bearer token auth in this library. You can find more information about how to use
12
- bearer token auth in the README.
13
- - Also fixes an issue where a secret was required even when bearer token auth was being used
14
- (it is no longer required).
15
-
16
- --------------------
17
- 9.0.0
18
- --------------------
24
+ token is included in the instantiation of the client. Previously, only custom events requests
25
+ could use bearer token auth in this library. You can find more information about how to use
26
+ bearer token auth in the README.
27
+ - Also fixes an issue where a secret was required even when bearer token auth was being used
28
+ (it is no longer required).
29
+
30
+ ---
31
+
32
+ ## 9.0.0
33
+
19
34
  - Adds Tag List API Support
20
35
  - Removes location lookup endpoints
21
36
  - Removes location-based audience selectors
22
37
 
23
- --------------------
24
- 8.0.1
25
- --------------------
38
+ ---
39
+
40
+ ## 8.0.1
41
+
26
42
  - Adds app key to user agent string on request
27
43
 
28
- --------------------
29
- 8.0.0
30
- --------------------
44
+ ---
45
+
46
+ ## 8.0.0
47
+
31
48
  - Updates officially supported versions to 2.6.7 and 2.7.2
32
49
  - Fixes headers to reduce warning messages
33
50
  - Fixes for multiple mis-set named user urls
34
51
  - Fix to automatically convert an integer named user to a string so it can be successfully submitted
35
52
  - Adds attribute support for named users
36
53
 
37
- --------------------
38
- 7.0.0
39
- --------------------
54
+ ---
55
+
56
+ ## 7.0.0
57
+
40
58
  - Refactors base url naming
41
59
 
42
- --------------------
43
- 6.0.0
44
- --------------------
60
+ ---
61
+
62
+ ## 6.0.0
63
+
45
64
  - Creates custom base url, and refactors urls within classes
46
65
  - Adds support for sending custom events
47
66
 
48
- --------------------
49
- 5.9.0
50
- --------------------
67
+ ---
68
+
69
+ ## 5.9.0
70
+
51
71
  - Adds support for bearer token auth
52
72
  - Updates broken code for static lists
53
- - Adds support for update sms channel
73
+ - Adds support for update sms channel
74
+
75
+ ---
76
+
77
+ ## 5.8.0
54
78
 
55
- --------------------
56
- 5.8.0
57
- --------------------
58
79
  - Adds scheudling support for PTSO
59
- - Adds attribute support
80
+ - Adds attribute support
81
+
82
+ ---
83
+
84
+ ## 5.7.0
60
85
 
61
- --------------------
62
- 5.7.0
63
- --------------------
64
86
  - Adds Automation support
65
87
  - Adds A/B test support
66
88
 
67
- --------------------
68
- 5.6.1
69
- --------------------
70
- - Updates EmailNotification templating
89
+ ---
90
+
91
+ ## 5.6.1
92
+
93
+ - Updates EmailNotification templating
94
+
95
+ ---
96
+
97
+ ## 5.6.0
71
98
 
72
- --------------------
73
- 5.6.0
74
- --------------------
75
99
  - Refactors EmailNotification class
76
100
  - Adds Create and Send implementation to Open Channel class
77
101
 
78
- --------------------
79
- 5.5.1
80
- --------------------
81
- - Updates validate_url method
102
+ ---
103
+
104
+ ## 5.5.1
105
+
106
+ - Updates validate_url method
107
+
108
+ ---
109
+
110
+ ## 5.5.0
82
111
 
83
- --------------------
84
- 5.5.0
85
- --------------------
86
112
  - Add Create and Send Functionality for Email
87
113
  - Add endpoints for Create and Send Validation and Scheduling
88
114
  - Add Create and Send Functionality for SMS
89
115
  - Update Rake version from 10.0 to 12.3.3
90
116
 
91
- --------------------
92
- 5.4.0
93
- --------------------
117
+ ---
118
+
119
+ ## 5.4.0
120
+
94
121
  - Change BASE_URL to go.airship.com
95
122
 
96
- --------------------
97
- 5.3.0
98
- --------------------
123
+ ---
124
+
125
+ ## 5.3.0
126
+
99
127
  - Updates Sphinx version on Ruby Lib docs
100
128
  - Fixes date in footer
101
129
  - Updates instances of 'Urbain Airship' to 'Airship' excluding method names
102
130
 
103
- --------------------
104
- 5.2.0
105
- --------------------
131
+ ---
132
+
133
+ ## 5.2.0
134
+
106
135
  - Updates automatic timeout for API request from 5 seconds to 60
107
136
  - Adds SMS Register implementation. Register, Opt-out, Uninstall, Lookup
108
137
  - Adds SMS Send functionality for Notification object
@@ -110,36 +139,42 @@ bearer token auth in the README.
110
139
  - Adds Email Send support
111
140
  - Adds Email Registration support
112
141
 
113
- --------------------
114
- 5.1.0
115
- --------------------
142
+ ---
143
+
144
+ ## 5.1.0
145
+
116
146
  - Adds functionality for custom logger
117
147
 
118
- --------------------
119
- 5.0.1
120
- --------------------
148
+ ---
149
+
150
+ ## 5.0.1
151
+
121
152
  - Fix bug with named user association/disassociation
122
153
 
123
- --------------------
124
- 5.0.0
125
- --------------------
154
+ ---
155
+
156
+ ## 5.0.0
157
+
126
158
  - Add support for Web Notify, expand Open Platform support
127
159
  - Removing support for Feedback API (EOL July 2018)
128
160
  - Removing support for Device Token Count (also EOL in 2018)
129
161
 
130
- --------------------
131
- 4.1.1
132
- --------------------
162
+ ---
163
+
164
+ ## 4.1.1
165
+
133
166
  - Added configuration value for timeout.
134
167
 
135
- --------------------
136
- 4.1.0
137
- --------------------
168
+ ---
169
+
170
+ ## 4.1.0
171
+
138
172
  - Added support for Open Channels
139
173
 
140
- --------------------
141
- 4.0.0
142
- --------------------
174
+ ---
175
+
176
+ ## 4.0.0
177
+
143
178
  - Added support for in-app messages
144
179
  - Added support for iOS priority
145
180
  - Added config class, allowing you to define log level and log location
@@ -149,41 +184,48 @@ bearer token auth in the README.
149
184
  - Removed support for Blackberry and MPNS platforms
150
185
  - Removed support for per-push reports
151
186
 
152
- --------------------
153
- 3.2.4
154
- --------------------
187
+ ---
188
+
189
+ ## 3.2.4
190
+
155
191
  - Replace unirest dependency with rest-client
156
192
 
157
- --------------------
158
- 3.2.3
159
- --------------------
193
+ ---
194
+
195
+ ## 3.2.3
196
+
160
197
  - Added support for named user audience selector
161
198
 
162
- --------------------
163
- 3.2.2
164
- --------------------
199
+ ---
200
+
201
+ ## 3.2.2
202
+
165
203
  - Bug fix: only open a single copy of the log file
166
204
 
167
- --------------------
168
- 3.2.1
169
- --------------------
205
+ ---
206
+
207
+ ## 3.2.1
208
+
170
209
  - Bug fix: allow audience tag selector to specify tag group if desired
171
210
 
172
- --------------------
173
- 3.2.0
174
- --------------------
211
+ ---
212
+
213
+ ## 3.2.0
214
+
175
215
  - Added support for static lists
176
216
  - Added support for device tokens, APIDs, and Blackberry PINs
177
217
  - Added support for locations
178
218
 
179
- --------------------
180
- 3.1.1
181
- --------------------
219
+ ---
220
+
221
+ ## 3.1.1
222
+
182
223
  - Changed UA to Urbanairship in client.rb to fix aliasing issue
183
224
 
184
- --------------------
185
- 3.1.0
186
- --------------------
225
+ ---
226
+
227
+ ## 3.1.0
228
+
187
229
  - Added documentation files
188
230
  - Added support for ChannelInfo and ChannelList
189
231
  - Added support for segments
@@ -193,19 +235,22 @@ bearer token auth in the README.
193
235
  - Added support for named user
194
236
  - Added support for reports
195
237
 
196
- --------------------
197
- 3.0.2
198
- --------------------
238
+ ---
239
+
240
+ ## 3.0.2
241
+
199
242
  - Resolve compatibility issues with Rails ActiveSupport
200
243
 
201
- --------------------
202
- 3.0.1
203
- --------------------
244
+ ---
245
+
246
+ ## 3.0.1
247
+
204
248
  - Updating Gemspec to show required Ruby Version correctly
205
249
 
206
- --------------------
207
- 3.0.0
208
- --------------------
250
+ ---
251
+
252
+ ## 3.0.0
253
+
209
254
  - added CHANGELOG
210
255
  - rewrite with v3 support for push and scheduled push
211
256
  - backwards incompatible with previous versions of library
data/README.rst CHANGED
@@ -66,7 +66,8 @@ In your app initialization, you can do something like the following:
66
66
  require 'urbanairship'
67
67
 
68
68
  Urbanairship.configure do |config|
69
- config.server = 'go.airship.eu'
69
+ config.server = 'api.asnapieu.com'
70
+ config.oauth_server = 'oauth2.asnapieu.com'
70
71
  config.log_path = '/path/to/your/logfile'
71
72
  config.log_level = Logger::WARN
72
73
  config.timeout = 60
@@ -87,10 +88,11 @@ If you want to use a custom logger (e.g Rails.logger), you can do:
87
88
  Available Configurations
88
89
  ------------------------
89
90
 
90
- - **log_path**: Allows to define the folder where the log file will be created (the default is nil).
91
- - **log_level**: Allows to define the log level and only messages at that level or higher will be printed (the default is INFO).
92
- - **server**: Allow to define the Airship server you want to use ("go.airship.eu" or "go.urbanairship.com")
93
- - **timeout**: Allows to define the request timeout in seconds (the default is 5).
91
+ - **log_path**: Allows you to define the folder where the log file will be created (the default is nil).
92
+ - **log_level**: Allows you to define the log level and only messages at that level or higher will be printed (the default is INFO).
93
+ - **server**: Allows you to define the Airship server you want to use ("api.asnapieu.com" for EU or "api.asnapius.com" for US)
94
+ - **oauth_server** Allows you to define the Airship Oauth server you want to use ("oauth2.asnapieu.com" for EU or "oauth2.asnapius.com" for US)
95
+ - **timeout**: Allows you to define the request timeout in seconds (the default is 5).
94
96
 
95
97
 
96
98
  Usage
@@ -140,7 +142,7 @@ Simple Tag Push
140
142
 
141
143
  Specify the Airship server used to make your requests
142
144
  -----------------------------------------------------
143
- By default, the request will be sent to the 'go.urbanairship.com' server:
145
+ By default, the request will be sent to the 'api.asnapius.com' server:
144
146
 
145
147
  .. code-block:: ruby
146
148
 
@@ -155,11 +157,11 @@ You can change the server globally in the Urbanairship configuration:
155
157
  require 'urbanairship'
156
158
 
157
159
  Urbanairship.configure do |config|
158
- config.server = 'go.airship.eu'
160
+ config.server = 'api.asnapieu.com'
159
161
  end
160
162
 
161
163
  Urbanairship::Client.new(key:'application_key', secret:'master_secret')
162
- # request will be sent to the 'go.airship.eu' server
164
+ # request will be sent to the 'api.asnapieu.com' server
163
165
 
164
166
  Finally, you can change the targeted server on a request basis:
165
167
 
@@ -168,12 +170,12 @@ Finally, you can change the targeted server on a request basis:
168
170
  require 'urbanairship'
169
171
 
170
172
  Urbanairship.configure do |config|
171
- config.server = 'go.airship.eu'
173
+ config.server = 'api.asnapieu.com'
172
174
  end
173
175
 
174
- Urbanairship::Client.new(key:'application_key', secret:'master_secret', server: 'go.urbanairship.com')
176
+ Urbanairship::Client.new(key:'application_key', secret:'master_secret', server: 'api.asnapius.com')
175
177
  # The Urbanairship configuration is overridden by the client and the
176
- # request will be sent to the 'go.urbanairship.com' server
178
+ # request will be sent to the 'api.asnapius.com' server
177
179
 
178
180
  Using Bearer Token Auth
179
181
  -----------------------
@@ -191,6 +193,32 @@ will use bearer token auth. Bearer token auth is required for some
191
193
  endpoints, but not supported by others. Please check `the Airship
192
194
  docs site <https://docs.airship.com/>`_ to see where it is supported.
193
195
 
196
+ Using Oauth
197
+ -----------
198
+ .. code-block:: ruby
199
+
200
+ require 'urbanairship'
201
+
202
+ UA = Urbanairship
203
+ app_key = 'application_key'
204
+
205
+ oauth = UA::Oauth.new(
206
+ client_id: 'client_id',
207
+ key: app_key,
208
+ assertion_private_key: 'your_private_key',
209
+ scopes: ['psh', 'chn'], # Optional
210
+ ip_addresses: ['23.74.131.15/22'], # Optional
211
+ oauth_server: 'api.asnapieu.com' # Optional
212
+ )
213
+ airship = UA::Client.new(key: app_key, oauth: oauth)
214
+ # Then continue as you would otherwise
215
+
216
+ **Note**: You can not use both Oauth and bearer token auth
217
+ at the same time. Oauth also cannot be used with the older
218
+ 'api.urbanairship.com' and 'api.airship.eu' base URLs. Lastly
219
+ there are some endpoints in which Oauth is not supported.
220
+ Please check `the Airship docs site <https://docs.airship.com/>`_ to see where it is supported.
221
+
194
222
  Contributing
195
223
  ============
196
224
 
@@ -1,11 +1,12 @@
1
1
  require 'json'
2
2
  require 'rest-client'
3
3
  require 'urbanairship'
4
+ require 'jwt'
4
5
 
5
6
 
6
7
  module Urbanairship
7
8
  class Client
8
- attr_accessor :key, :secret
9
+ attr_accessor :key, :secret, :token
9
10
  include Urbanairship::Common
10
11
  include Urbanairship::Loggable
11
12
 
@@ -13,15 +14,21 @@ module Urbanairship
13
14
  #
14
15
  # @param [Object] key Application Key
15
16
  # @param [Object] secret Application Secret
16
- # @param [String] server Airship server to use ("go.airship.eu" or "go.urbanairship.com").
17
+ # @param [String] server Airship server to use ("api.asnapieu.com" for EU or "api.asnapius.com" for US).
17
18
  # Used only when the request is sent with a "path", not an "url".
18
19
  # @param [String] token Application Auth Token
20
+ # @param [Object] oauth Oauth object
19
21
  # @return [Object] Client
20
- def initialize(key: required('key'), secret: nil, server: Urbanairship.configuration.server, token: nil)
22
+ def initialize(key: required('key'), secret: nil, server: Urbanairship.configuration.server, token: nil, oauth: nil)
21
23
  @key = key
22
24
  @secret = secret
23
25
  @server = server
24
26
  @token = token
27
+ @oauth = oauth
28
+
29
+ if @oauth != nil && @token != nil
30
+ raise ArgumentError.new("oauth and token can't both be used at the same time.")
31
+ end
25
32
  end
26
33
 
27
34
  # Send a request to Airship's API
@@ -56,6 +63,16 @@ module Urbanairship
56
63
  headers['Content-Type'] = content_type unless content_type.nil?
57
64
  headers['Content-Encoding'] = encoding unless encoding.nil?
58
65
 
66
+ unless @oauth.nil?
67
+ begin
68
+ @token = @oauth.get_token
69
+ rescue RestClient::Exception => e
70
+ new_error = RestClient::Exception.new(e.response, e.response.code)
71
+ new_error.message = "error while getting oauth token: #{e.message}"
72
+ raise new_error
73
+ end
74
+ end
75
+
59
76
  if @token != nil
60
77
  auth_type = :bearer
61
78
  end
@@ -1,9 +1,10 @@
1
1
  module Urbanairship
2
2
  class Configuration
3
- attr_accessor :custom_logger, :log_path, :log_level, :server, :timeout
3
+ attr_accessor :custom_logger, :log_path, :log_level, :server, :oauth_server, :timeout
4
4
 
5
5
  def initialize
6
- @server = 'go.urbanairship.com'
6
+ @server = 'api.asnapius.com'
7
+ @oauth_server = 'oauth2.asnapius.com'
7
8
  @custom_logger = nil
8
9
  @log_path = nil
9
10
  @log_level = Logger::INFO
@@ -0,0 +1,129 @@
1
+ require 'urbanairship'
2
+ require 'base64'
3
+ require 'rest-client'
4
+
5
+ module Urbanairship
6
+ class Oauth
7
+ attr_accessor :client_id, :sub, :assertion_private_key, :ip_addresses, :scopes, :oauth_server
8
+
9
+ # Initialize Oauth class
10
+ #
11
+ # @param [String] client_id The Client ID found when creating Oauth credentials in the dashboard.
12
+ # @param [String] key The app key for the project.
13
+ # @param [String] assertion_private_key The private key found when creating Oauth credentials in the dashboard. Used for assertion token auth.
14
+ # @param [Array<String>] ip_addresses A list of CIDR representations of valid IP addresses to which the issued token is restricted. Example: ['24.20.40.0/22', '34.17.3.0/22']
15
+ # @param [Array<String>] scopes A list of scopes to which the issued token will be entitled. Example: ['psh', 'lst']
16
+ # @param [String] oauth_server The server to send Oauth token requests to. By default is 'oauth2.asnapius.com', but can be set to 'oauth2.asnapieu.com' if using the EU server.
17
+ # @return [Object] Oauth object
18
+ def initialize(client_id:, key:, assertion_private_key:, ip_addresses: [], scopes: [], oauth_server: Urbanairship.configuration.oauth_server)
19
+ @grant_type = 'client_credentials'
20
+ @client_id = client_id
21
+ @assertion_private_key = assertion_private_key
22
+ @ip_addresses = ip_addresses
23
+ @scopes = scopes
24
+ @sub = "app:#{key}"
25
+ @oauth_server = oauth_server
26
+ @token = nil
27
+ end
28
+
29
+ # Get an Oauth token from Airship Oauth servers.
30
+ #
31
+ # @return [String] JSON web token to be used in further Airship API requests.
32
+ def get_token
33
+ unless @token.nil?
34
+ decoded_jwt = JWT.decode(@token, nil, false)
35
+ current_time = Time.now.to_i
36
+ expiry_time = decoded_jwt[0]['exp']
37
+
38
+ if current_time < expiry_time
39
+ return @token
40
+ end
41
+ end
42
+
43
+ assertion_jwt = build_assertion_jwt
44
+
45
+ url = "https://#{@oauth_server}/token"
46
+ headers = {
47
+ 'Host': @oauth_server,
48
+ 'Content-Type': 'application/x-www-form-urlencoded',
49
+ 'Accept': 'application/json'
50
+ }
51
+
52
+ params = {
53
+ method: :post,
54
+ url: url,
55
+ headers: headers,
56
+ payload: {
57
+ grant_type: @grant_type,
58
+ assertion: assertion_jwt
59
+ },
60
+ timeout: 60
61
+ }
62
+
63
+ retries = 0
64
+ max_retries = 3
65
+ begin
66
+ response = RestClient::Request.execute(params)
67
+ @token = JSON.parse(response.body)['access_token']
68
+ return @token
69
+ rescue RestClient::ExceptionWithResponse => e
70
+ if [400, 401, 406].include?(e.response.code)
71
+ raise e
72
+ else
73
+ retries += 1
74
+ if retries <= max_retries
75
+ sleep(retries ** 2)
76
+ retry
77
+ else
78
+ new_error = RestClient::Exception.new(e.response, e.response.code)
79
+ new_error.message = "failed after 3 attempts with error: #{e}"
80
+ raise new_error
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ # Build an assertion JWT
87
+ #
88
+ # @return [String] Assertion JWT to be used when requesting an Oauth token from Airship servers.
89
+ def build_assertion_jwt
90
+ assertion_expiration = 61
91
+ private_key = OpenSSL::PKey::EC.new(@assertion_private_key)
92
+
93
+ headers = {
94
+ alg: 'ES384',
95
+ kid: @client_id
96
+ }
97
+
98
+ claims = {
99
+ aud: "https://#{@oauth_server}/token",
100
+ exp: Time.now.to_i + assertion_expiration,
101
+ iat: Time.now.to_i,
102
+ iss: @client_id,
103
+ nonce: SecureRandom.uuid,
104
+ sub: @sub
105
+ }
106
+
107
+ claims[:scope] = @scopes.join(' ') if @scopes.any?
108
+ claims[:ipaddr] = @ip_addresses.join(' ') if @ip_addresses.any?
109
+
110
+ JWT.encode(claims, private_key, 'ES384', headers)
111
+ end
112
+
113
+ # Verify a public key
114
+ #
115
+ # @param [String] key_id The key ID ('kid') found in the header when decoding an Oauth token granted from Airship's servers.
116
+ # @return [String] The public key associated with the Key ID.
117
+ def verify_public_key(key_id)
118
+ url = "https://#{@oauth_server}/verify/public_key/#{key_id}"
119
+
120
+ headers = {
121
+ 'Host': @oauth_server,
122
+ 'Accept': 'text/plain'
123
+ }
124
+
125
+ response = RestClient.get(url, headers)
126
+ response.body
127
+ end
128
+ end
129
+ end
@@ -34,7 +34,7 @@ module Urbanairship
34
34
  def ios(alert: nil, badge: nil, sound: nil, content_available: nil,
35
35
  extra: nil, expiry: nil, priority: nil, category: nil,
36
36
  interactive: nil, mutable_content: nil, media_attachment: nil,
37
- title: nil, subtitle: nil, collapse_id: nil, thread_id: nil)
37
+ title: nil, subtitle: nil, collapse_id: nil, thread_id: nil, live_activity: nil)
38
38
  compact_helper({
39
39
  alert: alert,
40
40
  badge: badge,
@@ -50,7 +50,8 @@ module Urbanairship
50
50
  title: title,
51
51
  subtitle: subtitle,
52
52
  collapse_id: collapse_id,
53
- thread_id: thread_id
53
+ thread_id: thread_id,
54
+ live_activity: live_activity
54
55
  })
55
56
  end
56
57
 
@@ -77,7 +78,7 @@ module Urbanairship
77
78
  public_notification: nil, sound: nil, priority: nil, collapse_key: nil,
78
79
  time_to_live: nil, delivery_priority: nil, delay_while_idle: nil,
79
80
  local_only: nil, wearable: nil, background_image: nil, extra_pages: nil,
80
- interactive: nil)
81
+ interactive: nil, live_update: nil)
81
82
  compact_helper({
82
83
  title: title,
83
84
  alert: alert,
@@ -99,7 +100,8 @@ module Urbanairship
99
100
  delay_while_idle: delay_while_idle,
100
101
  local_only: local_only,
101
102
  wearable: wearable,
102
- interactive: interactive
103
+ interactive: interactive,
104
+ live_update: live_update
103
105
  })
104
106
  end
105
107
 
@@ -215,10 +217,26 @@ module Urbanairship
215
217
  types
216
218
  end
217
219
 
218
- # Expiry for a Rich Message
219
- def options(expiry: required('expiry'))
220
- { expiry: expiry }
221
- end
220
+ # Options for a message
221
+ def options(
222
+ expiry: nil,
223
+ bypass_frequency_limits: nil,
224
+ bypass_holdout_groups: nil,
225
+ no_throttle: nil,
226
+ omit_from_activity_log: nil,
227
+ personalization: nil,
228
+ redact_payload: nil
229
+ )
230
+ compact_helper(
231
+ expiry: expiry,
232
+ bypass_frequency_limits: bypass_frequency_limits,
233
+ bypass_holdout_groups: bypass_holdout_groups,
234
+ no_throttle: no_throttle,
235
+ omit_from_activity_log: omit_from_activity_log,
236
+ personalization: personalization,
237
+ redact_payload: redact_payload
238
+ )
239
+ end
222
240
 
223
241
  # Actions for a Push Notification Object
224
242
  def actions(add_tag: nil, remove_tag: nil, open_: nil, share: nil,
@@ -296,6 +314,57 @@ module Urbanairship
296
314
  interactive: interactive,
297
315
  })
298
316
  end
317
+
318
+ # iOS Live Activity
319
+ def live_activity(
320
+ event: required('event'),
321
+ alert: nil,
322
+ name: required('name'),
323
+ priority: nil,
324
+ content_state: nil,
325
+ relevance_score: nil,
326
+ stale_date: nil,
327
+ dismissal_date: nil,
328
+ timestamp: nil
329
+ )
330
+ valid_events = ['update', 'end']
331
+ fail ArgumentError, 'Invalid event type' unless valid_events.include?(event)
332
+ fail ArgumentError, 'priority must be 5 or 10' if priority && ![5, 10].include?(priority)
333
+
334
+ compact_helper({
335
+ event: event,
336
+ alert: alert,
337
+ name: name,
338
+ priority: priority,
339
+ content_state: content_state,
340
+ relevance_score: relevance_score,
341
+ stale_date: stale_date,
342
+ dismissal_date: dismissal_date,
343
+ timestamp: timestamp
344
+ })
345
+ end
346
+
347
+ # Android Live Update
348
+ def live_update(
349
+ event: required('event'),
350
+ name: required('name'),
351
+ content_state: nil,
352
+ type: nil,
353
+ dismissal_date: nil,
354
+ timestamp: nil
355
+ )
356
+ valid_events = ['start', 'update', 'end']
357
+ fail ArgumentError, 'Invalid event type' unless valid_events.include?(event)
358
+
359
+ compact_helper({
360
+ event: event,
361
+ name: name,
362
+ content_state: content_state,
363
+ type: type,
364
+ dismissal_date: dismissal_date,
365
+ timestamp: timestamp
366
+ })
367
+ end
299
368
  end
300
369
  end
301
370
  end
@@ -1,3 +1,3 @@
1
1
  module Urbanairship
2
- VERSION = '9.1.1'
2
+ VERSION = '9.3.0'
3
3
  end
data/lib/urbanairship.rb CHANGED
@@ -15,6 +15,7 @@ require 'urbanairship/devices/create_and_send'
15
15
  require 'urbanairship/devices/attribute'
16
16
  require 'urbanairship/devices/attributes'
17
17
  require 'urbanairship/client'
18
+ require 'urbanairship/oauth'
18
19
  require 'urbanairship/common'
19
20
  require 'urbanairship/configuration'
20
21
  require 'urbanairship/loggable'
data/urbanairship.gemspec CHANGED
@@ -28,8 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_runtime_dependency 'rest-client', '>= 1.4', '< 4.0'
31
+ spec.add_runtime_dependency 'jwt', '>= 2.0', '< 3.0'
31
32
 
32
- spec.add_development_dependency 'bundler', '>= 1'
33
+ spec.add_development_dependency 'bundler', '>= 1', '< 2.5'
33
34
  spec.add_development_dependency 'guard-rspec'
34
35
  spec.add_development_dependency 'pry', '~> 0'
35
36
  spec.add_development_dependency 'rake', '~> 12.3.3'
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: 9.1.1
4
+ version: 9.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airship
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-11 00:00:00.000000000 Z
11
+ date: 2024-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: jwt
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '2.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '3.0'
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: bundler
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -37,6 +57,9 @@ dependencies:
37
57
  - - ">="
38
58
  - !ruby/object:Gem::Version
39
59
  version: '1'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.5'
40
63
  type: :development
41
64
  prerelease: false
42
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,6 +67,9 @@ dependencies:
44
67
  - - ">="
45
68
  - !ruby/object:Gem::Version
46
69
  version: '1'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '2.5'
47
73
  - !ruby/object:Gem::Dependency
48
74
  name: guard-rspec
49
75
  requirement: !ruby/object:Gem::Requirement
@@ -202,6 +228,7 @@ files:
202
228
  - lib/urbanairship/devices/static_lists.rb
203
229
  - lib/urbanairship/devices/tag_lists.rb
204
230
  - lib/urbanairship/loggable.rb
231
+ - lib/urbanairship/oauth.rb
205
232
  - lib/urbanairship/push/audience.rb
206
233
  - lib/urbanairship/push/payload.rb
207
234
  - lib/urbanairship/push/push.rb
@@ -230,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
257
  - !ruby/object:Gem::Version
231
258
  version: '0'
232
259
  requirements: []
233
- rubygems_version: 3.4.10
260
+ rubygems_version: 3.1.6
234
261
  signing_key:
235
262
  specification_version: 4
236
263
  summary: Ruby Gem for using the Airship API