urbanairship 5.7.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +2 -2
- data/.travis.yml +2 -2
- data/CHANGELOG +33 -0
- data/README.rst +95 -38
- data/docs/attributes.rst +73 -0
- data/docs/index.rst +3 -0
- data/docs/named_user.rst +22 -0
- data/docs/push.rst +24 -0
- data/docs/sms.rst +19 -0
- data/docs/static_lists.rst +2 -2
- data/lib/urbanairship.rb +7 -0
- data/lib/urbanairship/ab_tests/ab_test.rb +8 -9
- data/lib/urbanairship/automations/automation.rb +11 -11
- data/lib/urbanairship/client.rb +34 -12
- 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/attribute.rb +54 -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 +10 -10
- data/lib/urbanairship/devices/create_and_send.rb +4 -4
- data/lib/urbanairship/devices/devicelist.rb +28 -7
- 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 +40 -9
- data/lib/urbanairship/devices/static_lists.rb +12 -12
- data/lib/urbanairship/push/location.rb +18 -18
- data/lib/urbanairship/push/push.rb +5 -5
- data/lib/urbanairship/push/schedule.rb +9 -0
- data/lib/urbanairship/reports/response_statistics.rb +42 -31
- data/lib/urbanairship/version.rb +1 -1
- data/urbanairship.gemspec +1 -0
- metadata +25 -6
@@ -10,7 +10,7 @@ module Urbanairship
|
|
10
10
|
class Push
|
11
11
|
attr_writer :client
|
12
12
|
|
13
|
-
attr_accessor :device_types,
|
13
|
+
attr_accessor :device_types,
|
14
14
|
:audience,
|
15
15
|
:notification,
|
16
16
|
:options,
|
@@ -52,7 +52,7 @@ module Urbanairship
|
|
52
52
|
response = @client.send_request(
|
53
53
|
method: 'POST',
|
54
54
|
body: JSON.dump(payload),
|
55
|
-
|
55
|
+
path: push_path,
|
56
56
|
content_type: 'application/json'
|
57
57
|
)
|
58
58
|
pr = PushResponse.new(http_response_body: response['body'], http_response_code: response['code'].to_s)
|
@@ -93,7 +93,7 @@ module Urbanairship
|
|
93
93
|
response = @client.send_request(
|
94
94
|
method: 'POST',
|
95
95
|
body: JSON.dump(payload),
|
96
|
-
|
96
|
+
path: schedules_path,
|
97
97
|
content_type: 'application/json'
|
98
98
|
)
|
99
99
|
pr = PushResponse.new(http_response_body: response['body'], http_response_code: response['code'].to_s)
|
@@ -170,7 +170,7 @@ module Urbanairship
|
|
170
170
|
'schedule_id must be a string' unless schedule_id.is_a? String
|
171
171
|
resp = @client.send_request(
|
172
172
|
method: 'GET',
|
173
|
-
|
173
|
+
path: schedules_path(schedule_id)
|
174
174
|
)
|
175
175
|
logger.info("Retrieved info for schedule_id #{schedule_id}")
|
176
176
|
resp
|
@@ -181,7 +181,7 @@ module Urbanairship
|
|
181
181
|
class ScheduledPushList < Urbanairship::Common::PageIterator
|
182
182
|
def initialize(client: required('client'))
|
183
183
|
super(client: client)
|
184
|
-
@
|
184
|
+
@next_page_path = schedules_path
|
185
185
|
@data_attribute = 'schedules'
|
186
186
|
end
|
187
187
|
end
|
@@ -14,6 +14,15 @@ module Urbanairship
|
|
14
14
|
payload(:local_scheduled_time, datetime)
|
15
15
|
end
|
16
16
|
|
17
|
+
# Uses predictive analysis to send push at optimal time
|
18
|
+
def optimal_scheduled_time(date)
|
19
|
+
{
|
20
|
+
'best_time': {
|
21
|
+
'send_date': date
|
22
|
+
}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
17
26
|
private
|
18
27
|
|
19
28
|
def payload(name, time)
|
@@ -4,22 +4,33 @@ require 'time'
|
|
4
4
|
module Urbanairship
|
5
5
|
module Reports
|
6
6
|
class Helper
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
precision_array = %w(HOURLY DAILY MONTHLY)
|
11
|
-
fail ArgumentError,
|
12
|
-
"Precision must be 'HOURLY', 'DAILY', or 'MONTHLY'" unless precision_array.include?(precision)
|
7
|
+
def get_period_params(start_date, end_date, precision)
|
8
|
+
validates_parameters_presence!(start_date, end_date, precision)
|
9
|
+
validates_precision_format!(precision)
|
13
10
|
|
14
11
|
begin
|
15
|
-
start_parsed = Time.parse(start_date)
|
16
|
-
end_parsed = Time.parse(end_date)
|
12
|
+
start_parsed = Time.parse(start_date).iso8601
|
13
|
+
end_parsed = Time.parse(end_date).iso8601
|
14
|
+
|
15
|
+
"?start=#{start_parsed}&end=#{end_parsed}&precision=#{precision}"
|
17
16
|
rescue ArgumentError
|
18
|
-
fail ArgumentError,
|
19
|
-
'start_date and end_date must be valid date strings'
|
17
|
+
fail ArgumentError, 'start_date and end_date must be valid date strings'
|
20
18
|
end
|
21
|
-
|
22
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def validates_parameters_presence!(start_date, end_date, precision)
|
24
|
+
return unless [start_date, end_date, precision].any?(&:nil?)
|
25
|
+
|
26
|
+
fail ArgumentError, 'the parameters cannot be set to nil'
|
27
|
+
end
|
28
|
+
|
29
|
+
AUTHORIZED_PRECISIONS = %w(HOURLY DAILY MONTHLY)
|
30
|
+
def validates_precision_format!(precision)
|
31
|
+
return if AUTHORIZED_PRECISIONS.include?(precision)
|
32
|
+
|
33
|
+
fail ArgumentError, 'Precision must be "HOURLY", "DAILY", or "MONTHLY"'
|
23
34
|
end
|
24
35
|
end
|
25
36
|
|
@@ -35,8 +46,8 @@ module Urbanairship
|
|
35
46
|
fail ArgumentError,
|
36
47
|
'push_id cannot be nil' if push_id.nil?
|
37
48
|
|
38
|
-
|
39
|
-
response = @client.send_request(method: 'GET',
|
49
|
+
path = reports_path('responses/' + push_id)
|
50
|
+
response = @client.send_request(method: 'GET', path: path)
|
40
51
|
logger.info("Retrieved info on push_id: #{push_id}")
|
41
52
|
response
|
42
53
|
end
|
@@ -60,10 +71,10 @@ module Urbanairship
|
|
60
71
|
fail ArgumentError,
|
61
72
|
'start_date and end_date must be valid date strings'
|
62
73
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@
|
74
|
+
path = reports_path('responses/list?start=' + start_parsed.iso8601 + '&end=' + end_parsed.iso8601)
|
75
|
+
path += '&limit' + limit.to_s unless limit.nil?
|
76
|
+
path += '&push_id_start&' + push_id_start unless push_id_start.nil?
|
77
|
+
@next_page_path = path
|
67
78
|
@data_attribute = 'pushes'
|
68
79
|
end
|
69
80
|
end
|
@@ -87,7 +98,7 @@ module Urbanairship
|
|
87
98
|
end
|
88
99
|
response = @client.send_request(
|
89
100
|
method: 'GET',
|
90
|
-
|
101
|
+
path: reports_path('devices/?date=' + date_parsed.iso8601)
|
91
102
|
)
|
92
103
|
logger.info("Retrieved device report for date #{date}")
|
93
104
|
response
|
@@ -98,8 +109,8 @@ module Urbanairship
|
|
98
109
|
def initialize(client: required('client'), start_date: required('start_date'),
|
99
110
|
end_date: required('end_date'), precision: required('precision'))
|
100
111
|
super(client: client)
|
101
|
-
|
102
|
-
@
|
112
|
+
period_params = Helper.new.get_period_params(start_date, end_date, precision)
|
113
|
+
@next_page_path = reports_path('optins/' + period_params)
|
103
114
|
@data_attribute = 'optins'
|
104
115
|
end
|
105
116
|
end
|
@@ -108,8 +119,8 @@ module Urbanairship
|
|
108
119
|
def initialize(client: required('client'), start_date: required('start_date'),
|
109
120
|
end_date: required('end_date'), precision: required('precision'))
|
110
121
|
super(client: client)
|
111
|
-
|
112
|
-
@
|
122
|
+
period_params = Helper.new.get_period_params(start_date, end_date, precision)
|
123
|
+
@next_page_path = reports_path('optouts/' + period_params)
|
113
124
|
@data_attribute = 'optouts'
|
114
125
|
end
|
115
126
|
end
|
@@ -118,8 +129,8 @@ module Urbanairship
|
|
118
129
|
def initialize(client: required('client'), start_date: required('start_date'),
|
119
130
|
end_date: required('end_date'), precision: required('precision'))
|
120
131
|
super(client: client)
|
121
|
-
|
122
|
-
@
|
132
|
+
period_params = Helper.new.get_period_params(start_date, end_date, precision)
|
133
|
+
@next_page_path = reports_path('sends/' + period_params)
|
123
134
|
@data_attribute = 'sends'
|
124
135
|
end
|
125
136
|
end
|
@@ -128,8 +139,8 @@ module Urbanairship
|
|
128
139
|
def initialize(client: required('client'), start_date: required('start_date'),
|
129
140
|
end_date: required('end_date'), precision: required('precision'))
|
130
141
|
super(client: client)
|
131
|
-
|
132
|
-
@
|
142
|
+
period_params = Helper.new.get_period_params(start_date, end_date, precision)
|
143
|
+
@next_page_path = reports_path('responses/' + period_params)
|
133
144
|
@data_attribute = 'responses'
|
134
145
|
end
|
135
146
|
end
|
@@ -138,8 +149,8 @@ module Urbanairship
|
|
138
149
|
def initialize(client: required('client'), start_date: required('start_date'),
|
139
150
|
end_date: required('end_date'), precision: required('precision'))
|
140
151
|
super(client: client)
|
141
|
-
|
142
|
-
@
|
152
|
+
period_params = Helper.new.get_period_params(start_date, end_date, precision)
|
153
|
+
@next_page_path = reports_path('opens/' + period_params)
|
143
154
|
@data_attribute = 'opens'
|
144
155
|
end
|
145
156
|
end
|
@@ -148,8 +159,8 @@ module Urbanairship
|
|
148
159
|
def initialize(client: required('client'), start_date: required('start_date'),
|
149
160
|
end_date: required('end_date'), precision: required('precision'))
|
150
161
|
super(client: client)
|
151
|
-
|
152
|
-
@
|
162
|
+
period_params = Helper.new.get_period_params(start_date, end_date, precision)
|
163
|
+
@next_page_path = reports_path('timeinapp/' + period_params)
|
153
164
|
@data_attribute = 'timeinapp'
|
154
165
|
end
|
155
166
|
end
|
data/lib/urbanairship/version.rb
CHANGED
data/urbanairship.gemspec
CHANGED
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:
|
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:
|
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:
|
@@ -139,6 +153,7 @@ files:
|
|
139
153
|
- bin/setup
|
140
154
|
- docs/Makefile
|
141
155
|
- docs/ab_tests.rst
|
156
|
+
- docs/attributes.rst
|
142
157
|
- docs/automations.rst
|
143
158
|
- docs/channel_uninstall.rst
|
144
159
|
- docs/conf.py
|
@@ -167,6 +182,10 @@ files:
|
|
167
182
|
- lib/urbanairship/client.rb
|
168
183
|
- lib/urbanairship/common.rb
|
169
184
|
- lib/urbanairship/configuration.rb
|
185
|
+
- lib/urbanairship/custom_events/custom_event.rb
|
186
|
+
- lib/urbanairship/custom_events/payload.rb
|
187
|
+
- lib/urbanairship/devices/attribute.rb
|
188
|
+
- lib/urbanairship/devices/attributes.rb
|
170
189
|
- lib/urbanairship/devices/channel_tags.rb
|
171
190
|
- lib/urbanairship/devices/channel_uninstall.rb
|
172
191
|
- lib/urbanairship/devices/create_and_send.rb
|
@@ -195,7 +214,7 @@ licenses:
|
|
195
214
|
- Apache-2.0
|
196
215
|
metadata:
|
197
216
|
allowed_push_host: https://rubygems.org
|
198
|
-
post_install_message:
|
217
|
+
post_install_message:
|
199
218
|
rdoc_options: []
|
200
219
|
require_paths:
|
201
220
|
- lib
|
@@ -210,8 +229,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
229
|
- !ruby/object:Gem::Version
|
211
230
|
version: '0'
|
212
231
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
214
|
-
signing_key:
|
232
|
+
rubygems_version: 3.1.4
|
233
|
+
signing_key:
|
215
234
|
specification_version: 4
|
216
235
|
summary: Ruby Gem for using the Airship API
|
217
236
|
test_files: []
|