urbanairship 5.9.0 → 8.0.1
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 +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +2 -2
- data/.github/workflows/ci.yaml +23 -0
- data/.gitignore +1 -0
- data/CHANGELOG +25 -0
- data/README.rst +97 -41
- data/docs/attributes.rst +21 -0
- data/docs/named_user.rst +22 -0
- data/lib/urbanairship/ab_tests/ab_test.rb +8 -9
- data/lib/urbanairship/automations/automation.rb +11 -11
- data/lib/urbanairship/client.rb +14 -5
- data/lib/urbanairship/common.rb +110 -43
- data/lib/urbanairship/configuration.rb +2 -1
- data/lib/urbanairship/custom_events/custom_event.rb +60 -0
- data/lib/urbanairship/custom_events/payload.rb +89 -0
- data/lib/urbanairship/devices/attributes.rb +53 -0
- data/lib/urbanairship/devices/channel_tags.rb +2 -2
- data/lib/urbanairship/devices/channel_uninstall.rb +9 -9
- data/lib/urbanairship/devices/create_and_send.rb +4 -4
- data/lib/urbanairship/devices/devicelist.rb +8 -8
- data/lib/urbanairship/devices/email.rb +5 -5
- data/lib/urbanairship/devices/named_user.rb +22 -12
- data/lib/urbanairship/devices/open_channel.rb +22 -23
- data/lib/urbanairship/devices/segment.rb +6 -8
- data/lib/urbanairship/devices/sms.rb +8 -8
- data/lib/urbanairship/devices/static_lists.rb +7 -7
- data/lib/urbanairship/push/location.rb +18 -18
- data/lib/urbanairship/push/push.rb +5 -5
- data/lib/urbanairship/reports/response_statistics.rb +42 -31
- data/lib/urbanairship/version.rb +1 -1
- data/lib/urbanairship.rb +6 -0
- data/urbanairship.gemspec +1 -0
- metadata +24 -7
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a1da985a2097fce219436538dbaa215aae47b9649ae658dd5ae16af3c3675bd8
|
|
4
|
+
data.tar.gz: ecf18938527e132580ed887081a89db81aab4665286431b06d268c3a2a6b7505
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3f2dad9fb10c281a0e10c1eacddb2fd26f0ec76af4c1a6a4fe0da3ddf83648f29e6762b0cbd756d81a2fadf2a0499fb8ead0c2a873d199ec2df05f16449edea
|
|
7
|
+
data.tar.gz: 4ec1e9d2b3f145446e6a6f5bbbb1d13bc79676186335aad7e5b36779f76a34ee41fff2e48cb15eac6dbf89013a27d71ad66742534999dba654f8c656811bcc05
|
|
@@ -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.
|
|
19
|
-
- [ ] 2.3
|
|
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
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
--------------------
|
|
2
|
+
8.0.1
|
|
3
|
+
--------------------
|
|
4
|
+
- Adds app key to user agent string on request
|
|
5
|
+
|
|
6
|
+
--------------------
|
|
7
|
+
8.0.0
|
|
8
|
+
--------------------
|
|
9
|
+
- Updates officially supported versions to 2.6.7 and 2.7.2
|
|
10
|
+
- Fixes headers to reduce warning messages
|
|
11
|
+
- Fixes for multiple mis-set named user urls
|
|
12
|
+
- Fix to automatically convert an integer named user to a string so it can be successfully submitted
|
|
13
|
+
- Adds attribute support for named users
|
|
14
|
+
|
|
15
|
+
--------------------
|
|
16
|
+
7.0.0
|
|
17
|
+
--------------------
|
|
18
|
+
- Refactors base url naming
|
|
19
|
+
|
|
20
|
+
--------------------
|
|
21
|
+
6.0.0
|
|
22
|
+
--------------------
|
|
23
|
+
- Creates custom base url, and refactors urls within classes
|
|
24
|
+
- Adds support for sending custom events
|
|
25
|
+
|
|
1
26
|
--------------------
|
|
2
27
|
5.9.0
|
|
3
28
|
--------------------
|
data/README.rst
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
.. image:: https://
|
|
2
|
-
:target: https://
|
|
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.
|
|
18
|
-
2.
|
|
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
|
|
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
|
|
@@ -38,17 +37,23 @@ Installation
|
|
|
38
37
|
|
|
39
38
|
If you have the ``bundler`` gem (if not you can get it with
|
|
40
39
|
``$ gem install bundler``) add this line to your application's
|
|
41
|
-
Gemfile
|
|
40
|
+
Gemfile:
|
|
41
|
+
|
|
42
|
+
.. code-block::
|
|
43
|
+
|
|
44
|
+
>>> $ gem 'urbanairship'
|
|
45
|
+
|
|
46
|
+
And then execute:
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
.. code-block::
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
>>> $ bundle
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
OR install it yourself as:
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
.. code-block::
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
>>> $ gem install urbanairship
|
|
52
57
|
|
|
53
58
|
|
|
54
59
|
Configuration
|
|
@@ -56,27 +61,35 @@ Configuration
|
|
|
56
61
|
|
|
57
62
|
In your app initialization, you can do something like the following:
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
.. code-block:: ruby
|
|
65
|
+
|
|
66
|
+
require 'urbanairship'
|
|
67
|
+
|
|
68
|
+
Urbanairship.configure do |config|
|
|
69
|
+
config.server = 'go.airship.eu'
|
|
70
|
+
config.log_path = '/path/to/your/logfile'
|
|
71
|
+
config.log_level = Logger::WARN
|
|
72
|
+
config.timeout = 60
|
|
73
|
+
end
|
|
74
|
+
|
|
65
75
|
|
|
66
76
|
If you want to use a custom logger (e.g Rails.logger), you can do:
|
|
67
77
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
.. code-block:: ruby
|
|
79
|
+
|
|
80
|
+
require 'urbanairship'
|
|
81
|
+
|
|
82
|
+
Urbanairship.configure do |config|
|
|
83
|
+
config.custom_logger = Rails.logger
|
|
84
|
+
config.log_level = Logger::WARN
|
|
85
|
+
end
|
|
74
86
|
|
|
75
87
|
Available Configurations
|
|
76
88
|
------------------------
|
|
77
89
|
|
|
78
90
|
- **log_path**: Allows to define the folder where the log file will be created (the default is nil).
|
|
79
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")
|
|
80
93
|
- **timeout**: Allows to define the request timeout in seconds (the default is 5).
|
|
81
94
|
|
|
82
95
|
|
|
@@ -96,28 +109,71 @@ information.
|
|
|
96
109
|
Broadcast to All Devices
|
|
97
110
|
------------------------
|
|
98
111
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
>>> p.notification = UA.notification(alert: 'Hello')
|
|
105
|
-
>>> p.device_types = UA.all
|
|
106
|
-
>>> p.send_push
|
|
112
|
+
.. code-block:: ruby
|
|
113
|
+
|
|
114
|
+
require 'urbanairship'
|
|
115
|
+
|
|
116
|
+
UA = Urbanairship
|
|
107
117
|
|
|
118
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
119
|
+
p = airship.create_push
|
|
120
|
+
p.audience = UA.all
|
|
121
|
+
p.notification = UA.notification(alert: 'Hello')
|
|
122
|
+
p.device_types = UA.all
|
|
123
|
+
p.send_push
|
|
108
124
|
|
|
109
125
|
Simple Tag Push
|
|
110
126
|
---------------
|
|
111
127
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
.. code-block:: ruby
|
|
129
|
+
|
|
130
|
+
require 'urbanairship'
|
|
131
|
+
|
|
132
|
+
UA = Urbanairship
|
|
133
|
+
|
|
134
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
135
|
+
p = airship.create_push
|
|
136
|
+
p.audience = UA.tag('some_tag')
|
|
137
|
+
p.notification = UA.notification(alert: 'Hello')
|
|
138
|
+
p.device_types = UA.all
|
|
139
|
+
p.send_push
|
|
140
|
+
|
|
141
|
+
Specify the Airship server used to make your requests
|
|
142
|
+
-----------------------------------------------------
|
|
143
|
+
By default, the request will be sent to the 'go.urbanairship.com' server:
|
|
144
|
+
|
|
145
|
+
.. code-block:: ruby
|
|
146
|
+
|
|
147
|
+
require 'urbanairship'
|
|
148
|
+
|
|
149
|
+
Urbanairship::Client.new(key:'application_key', secret:'master_secret')
|
|
150
|
+
|
|
151
|
+
You can change the server globally in the Urbanairship configuration:
|
|
152
|
+
|
|
153
|
+
.. code-block:: ruby
|
|
154
|
+
|
|
155
|
+
require 'urbanairship'
|
|
156
|
+
|
|
157
|
+
Urbanairship.configure do |config|
|
|
158
|
+
config.server = 'go.airship.eu'
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
Urbanairship::Client.new(key:'application_key', secret:'master_secret')
|
|
162
|
+
# request will be sent to the 'go.airship.eu' server
|
|
163
|
+
|
|
164
|
+
Finally, you can change the targeted server on a request basis:
|
|
165
|
+
|
|
166
|
+
.. code-block:: ruby
|
|
167
|
+
|
|
168
|
+
require 'urbanairship'
|
|
169
|
+
|
|
170
|
+
Urbanairship.configure do |config|
|
|
171
|
+
config.server = 'go.airship.eu'
|
|
172
|
+
end
|
|
120
173
|
|
|
174
|
+
Urbanairship::Client.new(key:'application_key', secret:'master_secret', server: 'go.urbanairship.com')
|
|
175
|
+
# The Urbanairship configuration is overridden by the client and the
|
|
176
|
+
# request will be sent to the 'go.urbanairship.com' server
|
|
121
177
|
|
|
122
178
|
Contributing
|
|
123
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/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'.
|
|
@@ -11,7 +11,7 @@ module Urbanairship
|
|
|
11
11
|
:offset,
|
|
12
12
|
:experiment_object,
|
|
13
13
|
:experiment_id
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
def initialize(client: required('client'))
|
|
16
16
|
@client = client
|
|
17
17
|
end
|
|
@@ -19,7 +19,7 @@ module Urbanairship
|
|
|
19
19
|
def list_ab_test
|
|
20
20
|
response = @client.send_request(
|
|
21
21
|
method: 'GET',
|
|
22
|
-
|
|
22
|
+
path: experiments_path(format_url_with_params)
|
|
23
23
|
)
|
|
24
24
|
logger.info("Looking up A/B Tests for project")
|
|
25
25
|
response
|
|
@@ -29,7 +29,7 @@ module Urbanairship
|
|
|
29
29
|
response = @client.send_request(
|
|
30
30
|
method: 'POST',
|
|
31
31
|
body: JSON.dump(experiment_object),
|
|
32
|
-
|
|
32
|
+
path: experiments_path,
|
|
33
33
|
content_type: 'application/json'
|
|
34
34
|
)
|
|
35
35
|
logger.info("Created A/B Test")
|
|
@@ -39,7 +39,7 @@ module Urbanairship
|
|
|
39
39
|
def list_scheduled_ab_test
|
|
40
40
|
response = @client.send_request(
|
|
41
41
|
method: 'GET',
|
|
42
|
-
|
|
42
|
+
path: experiments_path('scheduled' + format_url_with_params)
|
|
43
43
|
)
|
|
44
44
|
logger.info("Looking up scheduled A/B Tests for project")
|
|
45
45
|
response
|
|
@@ -49,7 +49,7 @@ module Urbanairship
|
|
|
49
49
|
fail ArgumentError, 'experiment_id must be set to delete individual A/B test' if @experiment_id.nil?
|
|
50
50
|
response = @client.send_request(
|
|
51
51
|
method: 'DELETE',
|
|
52
|
-
|
|
52
|
+
path: experiments_path('scheduled/' + experiment_id)
|
|
53
53
|
)
|
|
54
54
|
logger.info("Deleting A/B test with ID #{experiment_id}")
|
|
55
55
|
response
|
|
@@ -59,7 +59,7 @@ module Urbanairship
|
|
|
59
59
|
response = @client.send_request(
|
|
60
60
|
method: 'POST',
|
|
61
61
|
body: JSON.dump(experiment_object),
|
|
62
|
-
|
|
62
|
+
path: experiments_path('validate'),
|
|
63
63
|
content_type: 'application/json'
|
|
64
64
|
)
|
|
65
65
|
logger.info("Validating A/B Test")
|
|
@@ -70,7 +70,7 @@ module Urbanairship
|
|
|
70
70
|
fail ArgumentError, 'experiment_id must be set to lookup individual A/B Test' if @experiment_id.nil?
|
|
71
71
|
response = @client.send_request(
|
|
72
72
|
method: 'GET',
|
|
73
|
-
|
|
73
|
+
path: experiments_path(experiment_id)
|
|
74
74
|
)
|
|
75
75
|
logger.info("Looking up A/B test with ID #{experiment_id}")
|
|
76
76
|
response
|
|
@@ -85,5 +85,4 @@ module Urbanairship
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
|
-
end
|
|
89
|
-
|
|
88
|
+
end
|
|
@@ -22,7 +22,7 @@ module Urbanairship
|
|
|
22
22
|
response = @client.send_request(
|
|
23
23
|
method: 'POST',
|
|
24
24
|
body: JSON.dump(pipeline_object),
|
|
25
|
-
|
|
25
|
+
path: pipelines_path,
|
|
26
26
|
content_type: 'application/json'
|
|
27
27
|
)
|
|
28
28
|
logger.info("Created Automation")
|
|
@@ -32,7 +32,7 @@ module Urbanairship
|
|
|
32
32
|
def list_automations
|
|
33
33
|
response = @client.send_request(
|
|
34
34
|
method: 'GET',
|
|
35
|
-
|
|
35
|
+
path: pipelines_path(format_url_with_params)
|
|
36
36
|
)
|
|
37
37
|
logger.info("Looking up automations for project")
|
|
38
38
|
response
|
|
@@ -41,7 +41,7 @@ module Urbanairship
|
|
|
41
41
|
def list_deleted_automations
|
|
42
42
|
response = @client.send_request(
|
|
43
43
|
method: 'GET',
|
|
44
|
-
|
|
44
|
+
path: pipelines_path('deleted' + format_url_with_params)
|
|
45
45
|
)
|
|
46
46
|
logger.info("Looking up deleted automations for project")
|
|
47
47
|
response
|
|
@@ -51,18 +51,18 @@ module Urbanairship
|
|
|
51
51
|
response = @client.send_request(
|
|
52
52
|
method: 'POST',
|
|
53
53
|
body: JSON.dump(pipeline_object),
|
|
54
|
-
|
|
54
|
+
path: pipelines_path('validate'),
|
|
55
55
|
content_type: 'application/json'
|
|
56
56
|
)
|
|
57
57
|
logger.info("Validating Automation")
|
|
58
58
|
response
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
def lookup_automation
|
|
61
|
+
def lookup_automation
|
|
62
62
|
fail ArgumentError, 'pipeline_id must be set to lookup individual automation' if @pipeline_id.nil?
|
|
63
63
|
response = @client.send_request(
|
|
64
64
|
method: 'GET',
|
|
65
|
-
|
|
65
|
+
path: pipelines_path(pipeline_id)
|
|
66
66
|
)
|
|
67
67
|
logger.info("Looking up automation with id #{pipeline_id}")
|
|
68
68
|
response
|
|
@@ -70,22 +70,22 @@ module Urbanairship
|
|
|
70
70
|
|
|
71
71
|
def update_automation
|
|
72
72
|
fail ArgumentError, 'pipeline_id must be set to update individual automation' if @pipeline_id.nil?
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
response = @client.send_request(
|
|
75
75
|
method: 'PUT',
|
|
76
76
|
body: JSON.dump(pipeline_object),
|
|
77
|
-
|
|
77
|
+
path: pipelines_path(pipeline_id),
|
|
78
78
|
content_type: 'application/json'
|
|
79
79
|
)
|
|
80
80
|
logger.info("Validating Automation")
|
|
81
81
|
response
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
def delete_automation
|
|
84
|
+
def delete_automation
|
|
85
85
|
fail ArgumentError, 'pipeline_id must be set to delete individual automation' if @pipeline_id.nil?
|
|
86
86
|
response = @client.send_request(
|
|
87
87
|
method: 'DELETE',
|
|
88
|
-
|
|
88
|
+
path: pipelines_path(pipeline_id)
|
|
89
89
|
)
|
|
90
90
|
logger.info("Deleting automation with id #{pipeline_id}")
|
|
91
91
|
response
|
|
@@ -102,4 +102,4 @@ module Urbanairship
|
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
|
-
end
|
|
105
|
+
end
|
data/lib/urbanairship/client.rb
CHANGED
|
@@ -13,11 +13,15 @@ module Urbanairship
|
|
|
13
13
|
#
|
|
14
14
|
# @param [Object] key Application Key
|
|
15
15
|
# @param [Object] secret Application Secret
|
|
16
|
+
# @param [String] server Airship server to use ("go.airship.eu" or "go.urbanairship.com").
|
|
17
|
+
# Used only when the request is sent with a "path", not an "url".
|
|
16
18
|
# @param [String] token Application Auth Token (for custom events endpoint)
|
|
17
19
|
# @return [Object] Client
|
|
18
|
-
def initialize(key: required('key'), secret: required('secret'),
|
|
20
|
+
def initialize(key: required('key'), secret: required('secret'),
|
|
21
|
+
server: Urbanairship.configuration.server, token: nil)
|
|
19
22
|
@key = key
|
|
20
23
|
@secret = secret
|
|
24
|
+
@server = server
|
|
21
25
|
@token = token
|
|
22
26
|
end
|
|
23
27
|
|
|
@@ -25,12 +29,13 @@ module Urbanairship
|
|
|
25
29
|
#
|
|
26
30
|
# @param [Object] method HTTP Method
|
|
27
31
|
# @param [Object] body Request Body
|
|
32
|
+
# @param [Object] path Request path
|
|
28
33
|
# @param [Object] url Request URL
|
|
29
34
|
# @param [Object] content_type Content-Type
|
|
30
35
|
# @param [Object] encoding Encoding
|
|
31
36
|
# @param [Symbol] auth_type (:basic|:bearer)
|
|
32
37
|
# @return [Object] Push Response
|
|
33
|
-
def send_request(method: required('method'), url:
|
|
38
|
+
def send_request(method: required('method'), path: nil, url: nil, body: nil,
|
|
34
39
|
content_type: nil, encoding: nil, auth_type: :basic)
|
|
35
40
|
req_type = case method
|
|
36
41
|
when 'GET'
|
|
@@ -45,17 +50,21 @@ module Urbanairship
|
|
|
45
50
|
fail 'Method was not "GET" "POST" "PUT" or "DELETE"'
|
|
46
51
|
end
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
raise ArgumentError.new("path and url can't be both nil") if path.nil? && url.nil?
|
|
54
|
+
|
|
55
|
+
headers = {'User-Agent' => 'UARubyLib/' + Urbanairship::VERSION + ' ' + @key}
|
|
49
56
|
headers['Accept'] = 'application/vnd.urbanairship+json; version=3'
|
|
50
|
-
headers['Content-
|
|
57
|
+
headers['Content-Type'] = content_type unless content_type.nil?
|
|
51
58
|
headers['Content-Encoding'] = encoding unless encoding.nil?
|
|
52
|
-
|
|
59
|
+
|
|
53
60
|
if auth_type == :bearer
|
|
54
61
|
raise ArgumentError.new('token must be provided as argument if auth_type=bearer') if @token.nil?
|
|
55
62
|
headers['X-UA-Appkey'] = @key
|
|
56
63
|
headers['Authorization'] = "Bearer #{@token}"
|
|
57
64
|
end
|
|
58
65
|
|
|
66
|
+
url = "https://#{@server}/api#{path}" unless path.nil?
|
|
67
|
+
|
|
59
68
|
debug = "Making #{method} request to #{url}.\n"+ "\tHeaders:\n"
|
|
60
69
|
debug += "\t\tcontent-type: #{content_type}\n" unless content_type.nil?
|
|
61
70
|
debug += "\t\tcontent-encoding: gzip\n" unless encoding.nil?
|