urbanairship 7.0.0 → 9.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: 5417adc316435f2d47f4962983571399b1bf4dea0015cd126ea12077260e50eb
4
+ data.tar.gz: ccbaafa7f7f6bb5820c3a9e1834c23b5a8972debc6b964a204a73cb7630dc2b8
5
5
  SHA512:
6
- metadata.gz: c39e8417e51bd08077a8658589cdee0db2639e5e5d60e6de2596aa361e9640f16cb25ff284cfa55da044dd814b1b01001b84bc7b1c1dbcbbdc441c1dab7b6405
7
- data.tar.gz: 209ebf90c4d266092557e387d0479ccaf8fbd3d07d05f12f78e74186c4fd0c32a00a83b306994c64de9961554cd7eb39b115dc32b5130cc9c2f564553df72eb5
6
+ metadata.gz: 36063a93db8505fa64180ef1980068112d3e14b6b0330e97fa772bd7081c25ab0500aaa7db442ba086a7b12ae8e2c588bbdce7f34144998287a242e401c49c6c
7
+ data.tar.gz: d0cccf9b2713aa344d268c8a997a549525166f88e98e78d63b2a16a12e4123ce999e9be430c0c63a167cf5ff09505cc846755fc02ec822504b898146389aa799
@@ -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.3
20
20
 
21
21
  ### Airship Contribution Agreement
22
22
  [Link here](https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform)
@@ -0,0 +1,23 @@
1
+ name: Ruby Build
2
+
3
+ on: [ push ]
4
+
5
+ jobs:
6
+ test:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ matrix:
12
+ ruby-version: [2.7.3, 2.6.7]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby ${{ matrix.ruby-version }}
17
+ uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ - name: Install dependencies
21
+ run: bundle install
22
+ - name: Run tests
23
+ run: bundle exec rake
@@ -0,0 +1,31 @@
1
+ name: Ruby Release
2
+
3
+ on:
4
+ release:
5
+ types: [released]
6
+
7
+ jobs:
8
+ test:
9
+
10
+ runs-on: ubuntu-latest
11
+
12
+ strategy:
13
+ matrix:
14
+ ruby-version: [2.7.3, 2.6.7]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby ${{ matrix.ruby-version }}
19
+ uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ - name: Install dependencies
23
+ run: bundle install
24
+ - name: Run tests
25
+ run: bundle exec rake
26
+ - name: Publish to RubyGems
27
+ uses: cadwallion/publish-rubygems-action@master
28
+ env:
29
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
30
+ GUTHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
31
+ RELEASE_COMMAND: rake release
data/.gitignore CHANGED
@@ -10,6 +10,7 @@
10
10
  /spec/reports/
11
11
  /tmp/
12
12
  /csv_file
13
+ .vscode/
13
14
 
14
15
  # App
15
16
  urbanairship.log
data/CHANGELOG CHANGED
@@ -1,3 +1,22 @@
1
+ 9.0.0
2
+ --------------------
3
+ - Adds Tag List API Support
4
+ - Removes location lookup endpoints
5
+ - Removes location-based audience selectors
6
+ --------------------
7
+ 8.0.1
8
+ --------------------
9
+ - Adds app key to user agent string on request
10
+
11
+ --------------------
12
+ 8.0.0
13
+ --------------------
14
+ - Updates officially supported versions to 2.6.7 and 2.7.2
15
+ - Fixes headers to reduce warning messages
16
+ - Fixes for multiple mis-set named user urls
17
+ - Fix to automatically convert an integer named user to a string so it can be successfully submitted
18
+ - Adds attribute support for named users
19
+
1
20
  --------------------
2
21
  7.0.0
3
22
  --------------------
data/README.rst CHANGED
@@ -1,6 +1,5 @@
1
- .. image:: https://travis-ci.org/urbanairship/ruby-library.svg?branch=master
2
- :target: https://travis-ci.org/urbanairship/ruby-library
3
-
1
+ .. image:: https://github.com/urbanairship/ruby-library/actions/workflows/ci.yaml/badge.svg
2
+ :target: https://github.com/urbanairship/ruby-library/
4
3
  About
5
4
  =====
6
5
 
@@ -14,16 +13,16 @@ Requirements
14
13
 
15
14
  We officially support the following Ruby versions::
16
15
 
17
- 2.2.5
18
- 2.3.1
16
+ 2.6.7
17
+ 2.7.2
19
18
 
20
- Newer versions should work as well.
19
+ Newer 2.x versions should work as well.
21
20
 
22
21
 
23
22
  Functionality
24
23
  =============
25
24
 
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.
25
+ 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
26
 
28
27
 
29
28
  Questions
@@ -120,7 +119,7 @@ Broadcast to All Devices
120
119
  p = airship.create_push
121
120
  p.audience = UA.all
122
121
  p.notification = UA.notification(alert: 'Hello')
123
- p.device_types = UA.all
122
+ p.device_types = UA.device_types(['ios','android'])
124
123
  p.send_push
125
124
 
126
125
  Simple Tag Push
@@ -136,12 +135,12 @@ Simple Tag Push
136
135
  p = airship.create_push
137
136
  p.audience = UA.tag('some_tag')
138
137
  p.notification = UA.notification(alert: 'Hello')
139
- p.device_types = UA.all
138
+ p.device_types = UA.device_types(['ios','android'])
140
139
  p.send_push
141
140
 
142
141
  Specify the Airship server used to make your requests
143
142
  -----------------------------------------------------
144
- By default, the request will be sent to the 'go.airship.us' server:
143
+ By default, the request will be sent to the 'go.urbanairship.com' server:
145
144
 
146
145
  .. code-block:: ruby
147
146
 
@@ -172,9 +171,9 @@ Finally, you can change the targeted server on a request basis:
172
171
  config.server = 'go.airship.eu'
173
172
  end
174
173
 
175
- Urbanairship::Client.new(key:'application_key', secret:'master_secret', server: 'go.airship.us')
174
+ Urbanairship::Client.new(key:'application_key', secret:'master_secret', server: 'go.urbanairship.com')
176
175
  # The Urbanairship configuration is overridden by the client and the
177
- # request will be sent to the 'go.airship.us' server
176
+ # request will be sent to the 'go.urbanairship.com' server
178
177
 
179
178
  Contributing
180
179
  ============
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/examples.rst CHANGED
@@ -18,7 +18,7 @@ Simple broadcast to all devices
18
18
  push = airship.create_push
19
19
  push.audience = UA.all
20
20
  push.notification = UA.notification(alert: "Hello, world!")
21
- push.device_types = UA.all
21
+ push.device_types = UA.device_types(['ios','android'])
22
22
  push.send_push
23
23
 
24
24
 
@@ -92,7 +92,7 @@ Rich Push with extra and without notification
92
92
 
93
93
  push = airship.create_push
94
94
  push.audience = UA.all
95
- push.device_types = UA.all
95
+ push.device_types = UA.device_types(['ios','android'])
96
96
  push.message = UA.message(
97
97
  title: "Your package is on its way!",
98
98
  body: "<h1>Would you please complete our customer survey?</h1>",
data/docs/index.rst CHANGED
@@ -27,7 +27,7 @@ Using the library
27
27
 
28
28
  The library is intended to be used with the small footprint of a single
29
29
  import. To get started, import the package, and create an
30
- :rb:class:`Airship` object representing a single UA application.
30
+ :rb:class:`Airship` object representing a single Airship project.
31
31
 
32
32
  Note that channels are preferred over ``device_token`` and ``apid``. See:
33
33
  `documentation on channels <channels>`_.
@@ -40,7 +40,7 @@ Note that channels are preferred over ``device_token`` and ``apid``. See:
40
40
  p = airship.create_push
41
41
  p.audience = UA.all
42
42
  p.notification = UA.notification(alert: 'Hello')
43
- p.device_types = UA.all
43
+ p.device_types = UA.device_types(['ios','android'])
44
44
  p.send_push
45
45
 
46
46
  The library uses `unirest`_ for communication with the UA API.
@@ -66,7 +66,7 @@ Contents:
66
66
  named_user.rst
67
67
  reports.rst
68
68
  static_lists.rst
69
- location.rst
69
+ tag_lists.rst
70
70
  exceptions.rst
71
71
  examples.rst
72
72
  create_and_send.rst
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
@@ -22,7 +22,7 @@ and device types:
22
22
  push = airship.create_push
23
23
  push.audience = UA.all
24
24
  push.notification = UA.notification(alert: 'Hello')
25
- push.device_types = UA.all
25
+ push.device_types = UA.device_types(['ios','android'])
26
26
  push.send_push
27
27
 
28
28
 
@@ -443,12 +443,6 @@ types you wish to target with a list of strings:
443
443
 
444
444
  push.device_types = UA.device_types(['ios', 'android', 'web', 'open::example'])
445
445
 
446
- or with the ``all`` shortcut.
447
-
448
- .. code-block:: ruby
449
-
450
- push.device_types = UA.all
451
-
452
446
 
453
447
  Delivery
454
448
  --------
@@ -0,0 +1,76 @@
1
+ Tag Lists
2
+ =========
3
+
4
+ Bulk add and/or remove tags by uploading a CSV file of Airship users. For more
5
+ information about the use of this endpoint, incluiding CSV file formatting requirements
6
+ please see `the Airship Tag Lists API documentation
7
+ <https://docs.airship.com/api/ua/#tag-tag-lists>`__
8
+
9
+
10
+ Create List
11
+ -----------
12
+
13
+ Add tags to your contacts by creating a list and uploading CSV file with user identifiers.
14
+ The body of the request contains the name, description, and optional metadata for the
15
+ list. After you define a list, you populate it with a call to the Upload Tag List method.
16
+
17
+ .. code-block:: ruby
18
+
19
+ require 'urbanairship'
20
+ UA = Urbanairship
21
+ airship = UA::Client.new(key: 'app_key', secret: 'master_secret')
22
+ tags = {'tag_group_name': ['tag1', 'tag2']}
23
+
24
+ tag_list = UA::TagList.new(client: airship)
25
+ tag_list.name = 'ua_tags_list_name'
26
+ tag_list.create(description: 'description', extra: {'key': 'value'}, add: tags)
27
+
28
+
29
+ Upload List
30
+ -----------
31
+
32
+ Upload a CSV that will set tag values on the specified channels or named users. See `the
33
+ Airship API documentation <https://docs.airship.com/api/ua/#operation-api-tag-lists-list_name-csv-put>`__ for CSV formatting requirements. Set
34
+ the optional `gzip` parameter to `true` if your file is gzip compressed.
35
+
36
+ .. code-block:: ruby
37
+
38
+ require 'urbanairship'
39
+ UA = Urbanairship
40
+ airship = UA::Client.new(key: 'app_key', secret: 'master_secret')
41
+
42
+ tag_list = UA::TagList.new(client: airship)
43
+ tag_list.name = 'ua_tags_list_name'
44
+ tag_list.upload(csv_file: 'file_content', gzip: true)
45
+
46
+
47
+ Dowload List Errors
48
+ -------------------
49
+
50
+ During processing, after a list is uploaded, errors can occur. Depending on the type
51
+ of list processing, an error file may be created, showing a user exactly what went wrong.
52
+
53
+ .. code-block:: ruby
54
+
55
+ require 'urbanairship'
56
+ UA = Urbanairship
57
+ airship = UA::Client.new(key: 'app_key', secret: 'master_secret')
58
+
59
+ tag_list = UA::TagList.new(client: airship)
60
+ error_csv = tag_list.errors
61
+
62
+
63
+ Retrieve All Tag Lists
64
+ ----------------------
65
+
66
+ Retrieve information about all tag lists. This call returns a list of metadata that
67
+ will not contain the actual lists of users.
68
+
69
+ .. code-block:: ruby
70
+
71
+ require 'urbanairship'
72
+ UA = Urbanairship
73
+ airship = UA::Client.new(key: 'app_key', secret: 'master_secret')
74
+
75
+ tag_list = UA::TagList.new(client: airship)
76
+ list_response = tag_list.list
data/example/pusher.rb CHANGED
@@ -3,19 +3,15 @@ class Pusher
3
3
  require 'urbanairship'
4
4
  UA = Urbanairship
5
5
 
6
- def send_message
6
+ def send_broadcast_message
7
7
  airship = UA::Client.new(key:'app_key', secret:'master_secret')
8
8
  p = airship.create_push
9
9
  p.audience = UA.all
10
10
  p.notification = UA.notification(alert: 'Hello')
11
- p.device_types = UA.all
12
- p.in_app = UA.in_app(
13
- alert: 'This is a test message!',
14
- display_type: 'banner'
15
- )
11
+ p.device_types = UA.device_types(['ios','android'])
16
12
  p.send_push
17
13
  end
18
14
 
19
15
  end
20
16
 
21
- Pusher.new.send_message
17
+ Pusher.new.send_broadcast_message
@@ -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 + ' ' + @key}
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
@@ -32,10 +34,6 @@ module Urbanairship
32
34
  "/lists/#{path}"
33
35
  end
34
36
 
35
- def location_path(path='')
36
- "/location/#{path}"
37
- end
38
-
39
37
  def named_users_path(path='')
40
38
  "/named_users/#{path}"
41
39
  end
@@ -64,6 +62,10 @@ module Urbanairship
64
62
  "/segments/#{path}"
65
63
  end
66
64
 
65
+ def tag_lists_path(path='')
66
+ "/tag-lists/#{path}"
67
+ end
68
+
67
69
  # Helper method for required keyword args in Ruby 2.0 that is compatible with 2.1+
68
70
  # @example
69
71
  # def say(greeting: required('greeting'))
@@ -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
@@ -0,0 +1,82 @@
1
+ require 'urbanairship'
2
+ require 'tempfile'
3
+
4
+ module Urbanairship
5
+ module Devices
6
+ class TagList
7
+ include Urbanairship::Common
8
+ include Urbanairship::Loggable
9
+ attr_accessor :name
10
+
11
+ def initialize(client: required('client'))
12
+ fail ArgumentError, 'Client cannot be set to nil' if client.nil?
13
+ @client = client
14
+ end
15
+
16
+ def create(description: nil, extra: nil, add:nil, remove: nil, set: nil)
17
+ fail ArgumentError, 'Name must be set' if name.nil?
18
+ payload = {'name': name}
19
+ payload['description'] = description unless description.nil?
20
+ payload['extra'] = extra unless extra.nil?
21
+ payload['add'] = add unless add.nil?
22
+ payload['remove'] = remove unless remove.nil?
23
+ payload['set'] = set unless set.nil?
24
+
25
+ response = @client.send_request(
26
+ method: 'POST',
27
+ body: JSON.dump(payload),
28
+ path: tag_lists_path,
29
+ content_type: 'application/json'
30
+ )
31
+ logger.info("Created Tag List for #{@name}")
32
+ response
33
+ end
34
+
35
+ def upload(csv_file: required('csv_file'), gzip: false)
36
+ fail ArgumentError, 'Name must be set' if name.nil?
37
+
38
+ if gzip
39
+ response = @client.send_request(
40
+ method: 'PUT',
41
+ body: csv_file,
42
+ path: tag_lists_path(@name + '/csv/'),
43
+ content_type: 'text/csv',
44
+ encoding: gzip
45
+ )
46
+ else
47
+ response = @client.send_request(
48
+ method: 'PUT',
49
+ body: csv_file,
50
+ path: tag_lists_path(@name + '/csv/'),
51
+ content_type: 'text/csv'
52
+ )
53
+ end
54
+
55
+ logger.info("Uploaded a tag list for #{@name}")
56
+ response
57
+ end
58
+
59
+ def errors
60
+ fail ArgumentError, 'Name must be set' if name.nil?
61
+
62
+ response = @client.send_request(
63
+ method: 'GET',
64
+ path: tag_lists_path(@name + '/errors/')
65
+ )
66
+ logger.info("Got error CSV for tag list #{@name}")
67
+ response
68
+ end
69
+
70
+ def list
71
+ fail ArgumentError, 'Name must be set' if name.nil?
72
+
73
+ response = @client.send_request(
74
+ method: 'GET',
75
+ path: tag_lists_path
76
+ )
77
+ logger.info("Got tag lists listing")
78
+ response
79
+ end
80
+ end
81
+ end
82
+ end
@@ -78,67 +78,6 @@ module Urbanairship
78
78
  { not: child }
79
79
  end
80
80
 
81
- # Select a recent date range for a location selector.
82
- # Valid selectors are:
83
- # :minutes :hours :days :weeks :months :years
84
- #
85
- # @example
86
- # recent_date(months: 6) # => { recent: { months: 6 }}
87
- # recent_date(weeks: 3) # => { recent: { weeks: 3 }}
88
- def recent_date(**params)
89
- fail ArgumentError, 'Only one range allowed' if params.size != 1
90
- k, v = params.first
91
- unless DATE_TERMS.include?(k)
92
- fail ArgumentError, "#{k} not in #{DATE_TERMS}"
93
- end
94
- { recent: { k => v } }
95
- end
96
-
97
- # Select an absolute date range for a location selector.
98
- #
99
- # @param resolution [Symbol] Time resolution specifier, one of
100
- # :minutes :hours :days :weeks :months :years
101
- # @param start [String] UTC start time in ISO 8601 format.
102
- # @param the_end [String] UTC end time in ISO 8601 format.
103
- #
104
- # @example
105
- # absolute_date(resolution: :months, start: '2013-01', the_end: '2013-06')
106
- # #=> {months: {end: '2013-06', start: '2013-01'}}
107
- #
108
- # absolute_date(resolution: :minutes, start: '2012-01-01 12:00',
109
- # the_end: '2012-01-01 12:45')
110
- # #=> {minutes: {end: '2012-01-01 12:45', start: '2012-01-01 12:00'}}
111
- def absolute_date(resolution: required('resolution'), start: required('start'), the_end: required('the_end'))
112
- unless DATE_TERMS.include?(resolution)
113
- fail ArgumentError, "#{resolution} not in #{DATE_TERMS}"
114
- end
115
- { resolution => { start: start, end: the_end } }
116
- end
117
-
118
- # Select a location expression.
119
- #
120
- # Location selectors are made up of either an id or an alias and a date
121
- # period specifier. Use a date specification function to generate the time
122
- # period specifier.
123
- #
124
- # @example ID location
125
- # location(id: '4oFkxX7RcUdirjtaenEQIV', date: recent_date(days: 4))
126
- # #=> {location: {date: {recent: {days: 4}},
127
- # id: '4oFkxX7RcUdirjtaenEQIV'}}
128
- #
129
- # @example Alias location
130
- # location(us_zip: '94103', date: absolute_date(
131
- # resolution: 'days', start: '2012-01-01', end: '2012-01-15'))
132
- # #=> {location: {date: {days: {end: '2012-01-15',
133
- # start: '2012-01-01'}}, us_zip: '94103'}}
134
- def location(date: required('date'), **params)
135
- unless params.size == 1
136
- fail ArgumentError, 'One location specifier required'
137
- end
138
- params[:date] = date
139
- { location: params }
140
- end
141
-
142
81
  private
143
82
 
144
83
  # Clean up a UUID for use in the library
@@ -1,3 +1,3 @@
1
1
  module Urbanairship
2
- VERSION = '7.0.0'
2
+ VERSION = '9.0.0'
3
3
  end
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'
@@ -24,7 +26,7 @@ require 'urbanairship/devices/named_user'
24
26
  require 'urbanairship/devices/open_channel'
25
27
  require 'urbanairship/reports/response_statistics'
26
28
  require 'urbanairship/devices/static_lists'
27
- require 'urbanairship/push/location'
29
+ require 'urbanairship/devices/tag_lists'
28
30
  require 'urbanairship/automations/pipeline'
29
31
  require 'urbanairship/automations/automation'
30
32
  require 'urbanairship/ab_tests/variant'
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: 9.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: 2022-03-04 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:
@@ -126,9 +140,10 @@ files:
126
140
  - ".github/ISSUE_TEMPLATE.md"
127
141
  - ".github/PULL_REQUEST_TEMPLATE.md"
128
142
  - ".github/SUPPORT.md"
143
+ - ".github/workflows/ci.yaml"
144
+ - ".github/workflows/release.yaml"
129
145
  - ".gitignore"
130
146
  - ".rspec"
131
- - ".travis.yml"
132
147
  - CHANGELOG
133
148
  - Gemfile
134
149
  - Guardfile
@@ -149,7 +164,6 @@ files:
149
164
  - docs/examples.rst
150
165
  - docs/exceptions.rst
151
166
  - docs/index.rst
152
- - docs/location.rst
153
167
  - docs/named_user.rst
154
168
  - docs/open_channels.rst
155
169
  - docs/push.rst
@@ -157,6 +171,7 @@ files:
157
171
  - docs/segment.rst
158
172
  - docs/sms.rst
159
173
  - docs/static_lists.rst
174
+ - docs/tag_lists.rst
160
175
  - docs/tags.rst
161
176
  - example/pusher.rb
162
177
  - lib/urbanairship.rb
@@ -171,6 +186,7 @@ files:
171
186
  - lib/urbanairship/custom_events/custom_event.rb
172
187
  - lib/urbanairship/custom_events/payload.rb
173
188
  - lib/urbanairship/devices/attribute.rb
189
+ - lib/urbanairship/devices/attributes.rb
174
190
  - lib/urbanairship/devices/channel_tags.rb
175
191
  - lib/urbanairship/devices/channel_uninstall.rb
176
192
  - lib/urbanairship/devices/create_and_send.rb
@@ -184,9 +200,9 @@ files:
184
200
  - lib/urbanairship/devices/sms.rb
185
201
  - lib/urbanairship/devices/sms_notification.rb
186
202
  - lib/urbanairship/devices/static_lists.rb
203
+ - lib/urbanairship/devices/tag_lists.rb
187
204
  - lib/urbanairship/loggable.rb
188
205
  - lib/urbanairship/push/audience.rb
189
- - lib/urbanairship/push/location.rb
190
206
  - lib/urbanairship/push/payload.rb
191
207
  - lib/urbanairship/push/push.rb
192
208
  - lib/urbanairship/push/schedule.rb
@@ -199,7 +215,7 @@ licenses:
199
215
  - Apache-2.0
200
216
  metadata:
201
217
  allowed_push_host: https://rubygems.org
202
- post_install_message:
218
+ post_install_message:
203
219
  rdoc_options: []
204
220
  require_paths:
205
221
  - lib
@@ -214,8 +230,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
230
  - !ruby/object:Gem::Version
215
231
  version: '0'
216
232
  requirements: []
217
- rubygems_version: 3.0.1
218
- signing_key:
233
+ rubygems_version: 3.0.3.1
234
+ signing_key:
219
235
  specification_version: 4
220
236
  summary: Ruby Gem for using the Airship API
221
237
  test_files: []
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.5
4
- - 2.3.1
data/docs/location.rst DELETED
@@ -1,127 +0,0 @@
1
- Locations
2
- =========
3
-
4
- This class allows you to search for location information in
5
- various ways.
6
-
7
-
8
- Name Lookup
9
- -----------
10
-
11
- Search for a location boundary by name. The search primarily
12
- uses the location names, but you can also filter the results
13
- by boundary type. See `the API documentation on location
14
- <http://docs.airship.com/api/ua.html#location>`_
15
- for more information.
16
-
17
- .. code-block:: ruby
18
-
19
- require 'urbanairship'
20
- UA = Urbanairship
21
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
22
- location = UA::Location.new(client: airship)
23
- location.name_lookup(name: 'name', type: 'type')
24
-
25
- .. note::
26
-
27
- ``name`` is a required parameter, but ``type`` is optional
28
-
29
-
30
- Coordinates Lookup
31
- ------------------
32
-
33
- Search for a location by latitude and longitude coordinates. Type is
34
- an optional parameter. See `the API documentation on coordinates lookup
35
- <http://docs.airship.com/api/ua.html#lat-long-lookup>`_
36
- for more information.
37
-
38
- .. code-block:: ruby
39
-
40
- require 'urbanairship'
41
- UA = Urbanairship
42
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
43
- location = UA::Location.new(client: airship)
44
- location.coordinates_lookup(latitude: 123.45, longitude: 123.45, type: 'type')
45
-
46
- .. note::
47
-
48
- ``longitude`` and ``latitude`` are required parameters that must be numbers.
49
- ``Type`` is an optional parameter.
50
-
51
-
52
- Bounding Box Lookup
53
- -------------------
54
-
55
- Search for location using a bounding box. See `the documentation on
56
- bounding box lookup
57
- <http://docs.airship.com/api/ua.html#bounding-box-lookup>`_
58
- for more information.
59
-
60
- .. code-block:: ruby
61
-
62
- require 'urbanairship'
63
- UA = Urbanairship
64
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
65
- location = UA::Location.new(client: airship)
66
- location.bounding_box_lookup(lat1: 123.45, long1: 123.45,
67
- lat2: 321.45, long2: 321.45, type: 'type')
68
-
69
- .. note::
70
-
71
- ``lat1``, ``long1``, ``lat2``, and ``long2`` and are required parameters that must be numbers.
72
- ``Type`` is an optional parameter.
73
-
74
-
75
- Alias Lookup
76
- ------------
77
-
78
- Search for location by alias. See `the documentation on alias lookup
79
- <http://docs.airship.com/api/ua.html#alias-lookup>`_
80
-
81
- .. code-block:: ruby
82
-
83
- require 'urbanairship'
84
- UA = Urbanairship
85
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
86
- location = UA::Location.new(client: airship)
87
- location.alias_lookup(from_alias: 'us_state=CA')
88
-
89
- .. note::
90
-
91
- ``from_alias`` can either be a single alias or an array of aliases.
92
-
93
-
94
- Polygon Lookup
95
- --------------
96
-
97
- Search for location by polygon id. See `the documentation on polygon
98
- lookup <http://docs.airship.com/api/ua.html#polygon-lookup>`_
99
- for more information.
100
-
101
- .. code-block:: ruby
102
-
103
- require 'urbanairship'
104
- UA = Urbanairship
105
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
106
- location = UA::Location.new(client: airship)
107
- location.polygon_lookup(polygon_id: 'id', zoom: 1)
108
-
109
- .. note::
110
-
111
- ``polygon_id`` needs to be a string. ``Zoom`` is a number ranging from 1-20.
112
-
113
-
114
- Location Date Ranges
115
- --------------------
116
-
117
- Get the possible date ranges that can be used with location endpoints. See `the documentation
118
- on location date ranges <http://docs.airship.com/api/ua.html#location-date-ranges>`__
119
- for more information.
120
-
121
- .. code-block:: ruby
122
-
123
- require 'urbanairship'
124
- UA = Urbanairship
125
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
126
- l = UA::Location.new(client: airship)
127
- l.date_ranges
@@ -1,103 +0,0 @@
1
- require 'urbanairship'
2
-
3
-
4
- module Urbanairship
5
- module Push
6
- class Location
7
- include Urbanairship::Common
8
- include Urbanairship::Loggable
9
-
10
- def initialize(client: required('client'))
11
- @client = client
12
- end
13
-
14
- def name_lookup(name: required('name'), type: nil)
15
- fail ArgumentError, 'name needs to be a string' unless name.is_a? String
16
- fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
17
- path = location_path('?q=' + name)
18
- path += '&type=' + type unless type.nil?
19
- resp = @client.send_request(
20
- method: 'GET',
21
- path: path
22
- )
23
- logger.info("Retrieved location information for #{name}")
24
- resp
25
- end
26
-
27
- def coordinates_lookup(latitude: required('latitude'), longitude: required('longitude'), type: nil)
28
- fail ArgumentError,
29
- 'latitude and longitude need to be numbers' unless latitude.is_a? Numeric and longitude.is_a? Numeric
30
- fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
31
- path = location_path(latitude.to_s + ',' + longitude.to_s)
32
- path += '?type=' + type unless type.nil?
33
- resp = @client.send_request(
34
- method: 'GET',
35
- path: path
36
- )
37
- logger.info("Retrieved location information for latitude #{latitude} and longitude #{longitude}")
38
- resp
39
- end
40
-
41
- def bounding_box_lookup(lat1: required('lat1'), long1: required('long1'),
42
- lat2: required('lat2'), long2: required('long2'), type: nil)
43
-
44
- fail ArgumentError,
45
- 'lat1, long1, lat2, and long2 need to be numbers' unless lat1.is_a? Numeric and long2.is_a? Numeric\
46
- and lat2.is_a? Numeric and long2.is_a? Numeric
47
- fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
48
- path = location_path(lat1.to_s + ',' + long1.to_s + ',' + lat2.to_s + ',' + long2.to_s)
49
- path += '?type=' + type unless type.nil?
50
- resp = @client.send_request(
51
- method: 'GET',
52
- path: path
53
- )
54
- logger.info("Retrieved location information for bounding box with lat1 #{lat1}, long1 #{long1}," +
55
- " lat2 #{lat2}, and long2 #{long2}")
56
- resp
57
- end
58
-
59
- def alias_lookup(from_alias: required('from_alias'))
60
- fail ArgumentError, 'from_alias needs to be a string or an array of strings' unless from_alias.is_a? String or from_alias.is_a? Array
61
- path = location_path('from-alias?')
62
- if from_alias.is_a? Array
63
- from_alias.each do |a|
64
- fail ArgumentError, 'from_alias needs to be a string or an array of strings' unless a.is_a? String
65
- path += a + '&'
66
- end
67
- path = path.chop
68
- else
69
- path += from_alias
70
- end
71
-
72
- resp = @client.send_request(
73
- method: 'GET',
74
- path: path
75
- )
76
- logger.info("Retrieved location info from alias #{from_alias}")
77
- resp
78
- end
79
-
80
- def polygon_lookup(polygon_id: required('polygon_id'), zoom: required('zoom'))
81
- fail ArgumentError, 'polygon_id needs to be a string' unless polygon_id.is_a? String
82
- fail ArgumentError, 'zoom needs to be an integer' unless zoom.is_a? Integer
83
-
84
- path = location_path(polygon_id + '?zoom=' + zoom.to_s)
85
- resp = @client.send_request(
86
- method: 'GET',
87
- path: path
88
- )
89
- logger.info("Retrieved location info for polygon #{polygon_id} and zoom level #{zoom}")
90
- resp
91
- end
92
-
93
- def date_ranges
94
- resp = @client.send_request(
95
- method: 'GET',
96
- path: segments_path('dates/')
97
- )
98
- logger.info('Retrieved location date ranges')
99
- resp
100
- end
101
- end
102
- end
103
- end