urbanairship 7.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fffdb1489ab1f833e816db52d94b9aea7dac527f07bde6507af1dee57f491140
4
- data.tar.gz: 2255e7731044332f60b883568929e197905a690c45d905d0a75214806163434a
3
+ metadata.gz: 8c91f31ef623a57075fe0acde9fe467d17dc2b0bbb634070c8da11cad54b08f5
4
+ data.tar.gz: eefb6b294cd953148c27fa91bae207888cbb163c6ec620301aa41b243046b46a
5
5
  SHA512:
6
- metadata.gz: c39e8417e51bd08077a8658589cdee0db2639e5e5d60e6de2596aa361e9640f16cb25ff284cfa55da044dd814b1b01001b84bc7b1c1dbcbbdc441c1dab7b6405
7
- data.tar.gz: 209ebf90c4d266092557e387d0479ccaf8fbd3d07d05f12f78e74186c4fd0c32a00a83b306994c64de9961554cd7eb39b115dc32b5130cc9c2f564553df72eb5
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,12 @@
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
+
1
10
  --------------------
2
11
  7.0.0
3
12
  --------------------
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
@@ -141,7 +141,7 @@ Simple Tag Push
141
141
 
142
142
  Specify the Airship server used to make your requests
143
143
  -----------------------------------------------------
144
- By default, the request will be sent to the 'go.airship.us' server:
144
+ By default, the request will be sent to the 'go.urbanairship.com' server:
145
145
 
146
146
  .. code-block:: ruby
147
147
 
@@ -172,9 +172,9 @@ Finally, you can change the targeted server on a request basis:
172
172
  config.server = 'go.airship.eu'
173
173
  end
174
174
 
175
- Urbanairship::Client.new(key:'application_key', secret:'master_secret', server: 'go.airship.us')
175
+ Urbanairship::Client.new(key:'application_key', secret:'master_secret', server: 'go.urbanairship.com')
176
176
  # The Urbanairship configuration is overridden by the client and the
177
- # request will be sent to the 'go.airship.us' server
177
+ # request will be sent to the 'go.urbanairship.com' server
178
178
 
179
179
  Contributing
180
180
  ============
data/docs/attributes.rst CHANGED
@@ -24,6 +24,27 @@ The following will set an attribute for a given channel ID.
24
24
 
25
25
  This should return a 200 response
26
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
+
27
48
  Send Push to Audience with Attribute Specifications
28
49
  ---------------------------------------------------
29
50
 
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/lib/urbanairship.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'urbanairship/custom_events/custom_event'
1
2
  require 'urbanairship/custom_events/payload'
2
3
  require 'urbanairship/push/audience'
3
4
  require 'urbanairship/push/payload'
@@ -12,6 +13,7 @@ require 'urbanairship/devices/sms_notification'
12
13
  require 'urbanairship/devices/mms_notification'
13
14
  require 'urbanairship/devices/create_and_send'
14
15
  require 'urbanairship/devices/attribute'
16
+ require 'urbanairship/devices/attributes'
15
17
  require 'urbanairship/client'
16
18
  require 'urbanairship/common'
17
19
  require 'urbanairship/configuration'
@@ -52,9 +52,9 @@ module Urbanairship
52
52
 
53
53
  raise ArgumentError.new("path and url can't be both nil") if path.nil? && url.nil?
54
54
 
55
- headers = {'User-agent' => 'UARubyLib/' + Urbanairship::VERSION}
55
+ headers = {'User-Agent' => 'UARubyLib/' + Urbanairship::VERSION}
56
56
  headers['Accept'] = 'application/vnd.urbanairship+json; version=3'
57
- headers['Content-type'] = content_type unless content_type.nil?
57
+ headers['Content-Type'] = content_type unless content_type.nil?
58
58
  headers['Content-Encoding'] = encoding unless encoding.nil?
59
59
 
60
60
  if auth_type == :bearer
@@ -4,6 +4,8 @@ require 'urbanairship/loggable'
4
4
  module Urbanairship
5
5
  # Features mixed in to all classes
6
6
  module Common
7
+ CONTENT_TYPE = 'application/json'
8
+
7
9
  def apid_path(path='')
8
10
  "/apids/#{path}"
9
11
  end
@@ -0,0 +1,53 @@
1
+
2
+ module Urbanairship
3
+ module Devices
4
+ class Attributes
5
+
6
+ SET = 'set'
7
+ REMOVE = 'remove'
8
+
9
+ def initialize(attributes)
10
+ @attributes = attributes
11
+ end
12
+
13
+ def payload
14
+ @payload ||= { attributes: attributes_list }
15
+ end
16
+
17
+ private
18
+
19
+ def attributes_list
20
+ @attributes.map{ |attribute| attribute_payload(attribute) }
21
+ end
22
+
23
+ def attribute_payload(attribute)
24
+ if REMOVE == attribute[:action]
25
+ remove_payload(attribute)
26
+ else
27
+ set_payload(attribute)
28
+ end
29
+ end
30
+
31
+ def set_payload(attribute)
32
+ {
33
+ action: SET,
34
+ key: attribute[:key],
35
+ value: attribute[:value],
36
+ timestamp: (attribute[:timestamp] || timestamp).iso8601,
37
+ }
38
+ end
39
+
40
+ def remove_payload(attribute)
41
+ {
42
+ action: REMOVE,
43
+ key: attribute[:key],
44
+ timestamp: (attribute[:timestamp] || timestamp).iso8601,
45
+ }
46
+ end
47
+
48
+ def timestamp
49
+ @timestamp ||= Time.now.utc
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,6 +1,5 @@
1
1
  require 'urbanairship'
2
2
 
3
-
4
3
  module Urbanairship
5
4
  module Devices
6
5
  class NamedUser
@@ -13,6 +12,17 @@ module Urbanairship
13
12
  @named_user_id = nil
14
13
  end
15
14
 
15
+ def update_attributes(attributes: required('attributes'))
16
+ response = @client.send_request(
17
+ method: 'POST',
18
+ body: Urbanairship::Attributes.new(attributes).payload.to_json,
19
+ path: named_users_path("#{@named_user_id}/attributes"),
20
+ content_type: CONTENT_TYPE,
21
+ )
22
+ logger.info { "Updated attributes for named_user #{@named_user_id}" }
23
+ response
24
+ end
25
+
16
26
  def associate(channel_id: required('channel_id'), device_type: nil)
17
27
  fail ArgumentError,
18
28
  'named_user_id is required for association' if @named_user_id.nil?
@@ -20,13 +30,13 @@ module Urbanairship
20
30
  payload = {}
21
31
  payload['channel_id'] = channel_id
22
32
  payload['device_type'] = device_type unless device_type.nil?
23
- payload['named_user_id'] = @named_user_id
33
+ payload['named_user_id'] = @named_user_id.to_s
24
34
 
25
35
  response = @client.send_request(
26
36
  method: 'POST',
27
37
  body: JSON.dump(payload),
28
- path: named_users_path('/associate'),
29
- content_type: 'application/json'
38
+ path: named_users_path('associate'),
39
+ content_type: CONTENT_TYPE
30
40
  )
31
41
  logger.info { "Associated channel_id #{channel_id} with named_user #{@named_user_id}" }
32
42
  response
@@ -40,8 +50,8 @@ module Urbanairship
40
50
  response = @client.send_request(
41
51
  method: 'POST',
42
52
  body: JSON.dump(payload),
43
- path: named_users_path('/disassociate'),
44
- content_type: 'application/json'
53
+ path: named_users_path('disassociate'),
54
+ content_type: CONTENT_TYPE
45
55
  )
46
56
  logger.info { "Dissociated channel_id #{channel_id}" }
47
57
  response
@@ -51,8 +61,8 @@ module Urbanairship
51
61
  fail ArgumentError,
52
62
  'named_user_id is required for lookup' if @named_user_id.nil?
53
63
  response = @client.send_request(
54
- method: 'GET',
55
- path: named_users_path('?id=' + @named_user_id),
64
+ method: 'GET',
65
+ path: named_users_path('?id=' + @named_user_id),
56
66
  )
57
67
  logger.info { "Retrieved information on named_user_id #{@named_user_id}" }
58
68
  response
@@ -101,8 +111,8 @@ module Urbanairship
101
111
  response = @client.send_request(
102
112
  method: 'POST',
103
113
  body: JSON.dump(payload),
104
- path: named_users_path('/uninstall'),
105
- content_type: 'application/json'
114
+ path: named_users_path('uninstall'),
115
+ content_type: CONTENT_TYPE
106
116
  )
107
117
  logger.info { "Uninstalled named_user_ids #{@named_user_ids} " }
108
118
  response
@@ -1,3 +1,3 @@
1
1
  module Urbanairship
2
- VERSION = '7.0.0'
2
+ VERSION = '8.0.0'
3
3
  end
data/urbanairship.gemspec CHANGED
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'rake', '~> 12.3.3'
36
36
  spec.add_development_dependency 'rspec', '~> 3'
37
37
  spec.add_development_dependency 'terminal-notifier-guard', '~> 1'
38
+ spec.add_development_dependency 'timecop'
38
39
  end
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: 7.0.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airship
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -114,6 +114,20 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '1'
117
+ - !ruby/object:Gem::Dependency
118
+ name: timecop
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
117
131
  description: A Ruby Library for using the Airship web service API for push notifications
118
132
  and rich app pages.
119
133
  email:
@@ -171,6 +185,7 @@ files:
171
185
  - lib/urbanairship/custom_events/custom_event.rb
172
186
  - lib/urbanairship/custom_events/payload.rb
173
187
  - lib/urbanairship/devices/attribute.rb
188
+ - lib/urbanairship/devices/attributes.rb
174
189
  - lib/urbanairship/devices/channel_tags.rb
175
190
  - lib/urbanairship/devices/channel_uninstall.rb
176
191
  - lib/urbanairship/devices/create_and_send.rb
@@ -199,7 +214,7 @@ licenses:
199
214
  - Apache-2.0
200
215
  metadata:
201
216
  allowed_push_host: https://rubygems.org
202
- post_install_message:
217
+ post_install_message:
203
218
  rdoc_options: []
204
219
  require_paths:
205
220
  - lib
@@ -214,8 +229,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
229
  - !ruby/object:Gem::Version
215
230
  version: '0'
216
231
  requirements: []
217
- rubygems_version: 3.0.1
218
- signing_key:
232
+ rubygems_version: 3.1.4
233
+ signing_key:
219
234
  specification_version: 4
220
235
  summary: Ruby Gem for using the Airship API
221
236
  test_files: []