urbanairship 5.6.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +30 -0
  3. data/README.rst +1 -0
  4. data/docs/ab_tests.rst +162 -0
  5. data/docs/attributes.rst +52 -0
  6. data/docs/automations.rst +212 -0
  7. data/docs/index.rst +3 -0
  8. data/docs/push.rst +24 -0
  9. data/docs/sms.rst +19 -0
  10. data/docs/static_lists.rst +2 -2
  11. data/lib/urbanairship.rb +12 -0
  12. data/lib/urbanairship/ab_tests/ab_test.rb +88 -0
  13. data/lib/urbanairship/ab_tests/experiment.rb +45 -0
  14. data/lib/urbanairship/ab_tests/variant.rb +34 -0
  15. data/lib/urbanairship/automations/automation.rb +105 -0
  16. data/lib/urbanairship/automations/pipeline.rb +52 -0
  17. data/lib/urbanairship/client.rb +22 -9
  18. data/lib/urbanairship/common.rb +63 -16
  19. data/lib/urbanairship/configuration.rb +2 -1
  20. data/lib/urbanairship/custom_events/custom_event.rb +60 -0
  21. data/lib/urbanairship/custom_events/payload.rb +89 -0
  22. data/lib/urbanairship/devices/attribute.rb +54 -0
  23. data/lib/urbanairship/devices/channel_tags.rb +1 -1
  24. data/lib/urbanairship/devices/channel_uninstall.rb +10 -10
  25. data/lib/urbanairship/devices/create_and_send.rb +4 -4
  26. data/lib/urbanairship/devices/devicelist.rb +28 -7
  27. data/lib/urbanairship/devices/email.rb +5 -5
  28. data/lib/urbanairship/devices/email_notification.rb +11 -4
  29. data/lib/urbanairship/devices/named_user.rb +6 -6
  30. data/lib/urbanairship/devices/open_channel.rb +22 -23
  31. data/lib/urbanairship/devices/segment.rb +5 -5
  32. data/lib/urbanairship/devices/sms.rb +40 -9
  33. data/lib/urbanairship/devices/static_lists.rb +12 -12
  34. data/lib/urbanairship/push/location.rb +7 -7
  35. data/lib/urbanairship/push/push.rb +23 -13
  36. data/lib/urbanairship/push/schedule.rb +9 -0
  37. data/lib/urbanairship/reports/response_statistics.rb +9 -9
  38. data/lib/urbanairship/version.rb +1 -1
  39. metadata +16 -5
@@ -13,16 +13,16 @@ module Urbanairship
13
13
  @client = client
14
14
  end
15
15
 
16
- def create(description: nil, extras: nil)
16
+ def create(description: nil, extra: nil)
17
17
  fail ArgumentError, 'Name must be set' if name.nil?
18
18
  payload = {'name': name}
19
19
  payload['description'] = description unless description.nil?
20
- payload['extras'] = extras unless extras.nil?
20
+ payload['extra'] = extra unless extra.nil?
21
21
 
22
22
  response = @client.send_request(
23
23
  method: 'POST',
24
24
  body: JSON.dump(payload),
25
- url: LISTS_URL,
25
+ url: lists_url,
26
26
  content_type: 'application/json'
27
27
  )
28
28
  logger.info("Created static list for #{@name}")
@@ -35,7 +35,7 @@ module Urbanairship
35
35
  response = @client.send_request(
36
36
  method: 'PUT',
37
37
  body: csv_file,
38
- url: LISTS_URL + @name + '/csv/',
38
+ url: lists_url(@name + '/csv/'),
39
39
  content_type: 'text/csv',
40
40
  encoding: gzip
41
41
  )
@@ -43,7 +43,7 @@ module Urbanairship
43
43
  response = @client.send_request(
44
44
  method: 'PUT',
45
45
  body: csv_file,
46
- url: LISTS_URL + @name + '/csv/',
46
+ url: lists_url(@name + '/csv/'),
47
47
  content_type: 'text/csv'
48
48
  )
49
49
  end
@@ -51,17 +51,17 @@ module Urbanairship
51
51
  response
52
52
  end
53
53
 
54
- def update(description: nil, extras: nil)
54
+ def update(description: nil, extra: nil)
55
55
  fail ArgumentError, 'Name must be set' if name.nil?
56
56
  fail ArgumentError,
57
- 'Either description or extras must be set to a value' if description.nil? and extras.nil?
57
+ 'Either description or extras must be set to a value' if description.nil? and extra.nil?
58
58
  payload = {}
59
59
  payload['description'] = description unless description.nil?
60
- payload['extras'] = extras unless extras.nil?
60
+ payload['extra'] = extra unless extra.nil?
61
61
  response = @client.send_request(
62
62
  method: 'PUT',
63
63
  body: JSON.dump(payload),
64
- url: LISTS_URL + @name,
64
+ url: lists_url(@name),
65
65
  content_type: 'application/json'
66
66
  )
67
67
  logger.info("Updating the metadata for list #{@name}")
@@ -72,7 +72,7 @@ module Urbanairship
72
72
  fail ArgumentError, 'Name must be set' if name.nil?
73
73
  response = @client.send_request(
74
74
  method: 'GET',
75
- url: LISTS_URL + @name
75
+ url: lists_url(@name)
76
76
  )
77
77
  logger.info("Retrieving info for list #{@name}")
78
78
  response
@@ -82,7 +82,7 @@ module Urbanairship
82
82
  fail ArgumentError, 'Name must be set' if name.nil?
83
83
  response = @client.send_request(
84
84
  method: 'DELETE',
85
- url: LISTS_URL + @name
85
+ url: lists_url(@name)
86
86
  )
87
87
  logger.info("Deleted list #{@name}")
88
88
  response
@@ -92,7 +92,7 @@ module Urbanairship
92
92
  class StaticLists < Urbanairship::Common::PageIterator
93
93
  def initialize(client: required('client'))
94
94
  super(client: client)
95
- @next_page = LISTS_URL
95
+ @next_page = lists_url
96
96
  @data_attribute = 'lists'
97
97
  end
98
98
  end
@@ -14,7 +14,7 @@ module Urbanairship
14
14
  def name_lookup(name: required('name'), type: nil)
15
15
  fail ArgumentError, 'name needs to be a string' unless name.is_a? String
16
16
  fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
17
- url = LOCATION_URL + '?q=' + name
17
+ url = location_url('?q=' + name)
18
18
  url += '&type=' + type unless type.nil?
19
19
  resp = @client.send_request(
20
20
  method: 'GET',
@@ -28,7 +28,7 @@ module Urbanairship
28
28
  fail ArgumentError,
29
29
  'latitude and longitude need to be numbers' unless latitude.is_a? Numeric and longitude.is_a? Numeric
30
30
  fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
31
- url = LOCATION_URL + latitude.to_s + ',' + longitude.to_s
31
+ url = location_url(latitude.to_s + ',' + longitude.to_s)
32
32
  url += '?type=' + type unless type.nil?
33
33
  resp = @client.send_request(
34
34
  method: 'GET',
@@ -45,7 +45,7 @@ module Urbanairship
45
45
  'lat1, long1, lat2, and long2 need to be numbers' unless lat1.is_a? Numeric and long2.is_a? Numeric\
46
46
  and lat2.is_a? Numeric and long2.is_a? Numeric
47
47
  fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
48
- url = LOCATION_URL + lat1.to_s + ',' + long1.to_s + ',' + lat2.to_s + ',' + long2.to_s
48
+ url = location_url(lat1.to_s + ',' + long1.to_s + ',' + lat2.to_s + ',' + long2.to_s)
49
49
  url += '?type=' + type unless type.nil?
50
50
  resp = @client.send_request(
51
51
  method: 'GET',
@@ -58,7 +58,7 @@ module Urbanairship
58
58
 
59
59
  def alias_lookup(from_alias: required('from_alias'))
60
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
- url = LOCATION_URL + 'from-alias?'
61
+ url = location_url('from-alias?')
62
62
  if from_alias.is_a? Array
63
63
  from_alias.each do |a|
64
64
  fail ArgumentError, 'from_alias needs to be a string or an array of strings' unless a.is_a? String
@@ -81,7 +81,7 @@ module Urbanairship
81
81
  fail ArgumentError, 'polygon_id needs to be a string' unless polygon_id.is_a? String
82
82
  fail ArgumentError, 'zoom needs to be an integer' unless zoom.is_a? Integer
83
83
 
84
- url = LOCATION_URL + polygon_id + '?zoom=' + zoom.to_s
84
+ url = location_url(polygon_id + '?zoom=' + zoom.to_s)
85
85
  resp = @client.send_request(
86
86
  method: 'GET',
87
87
  url: url
@@ -93,11 +93,11 @@ module Urbanairship
93
93
  def date_ranges
94
94
  resp = @client.send_request(
95
95
  method: 'GET',
96
- url: SEGMENTS_URL + 'dates/'
96
+ url: segments_url('dates/')
97
97
  )
98
98
  logger.info('Retrieved location date ranges')
99
99
  resp
100
100
  end
101
101
  end
102
102
  end
103
- end
103
+ end
@@ -8,9 +8,17 @@ module Urbanairship
8
8
 
9
9
  # A Push Notification.
10
10
  class Push
11
- attr_writer :client, :audience, :notification, :options,
12
- :device_types, :message, :in_app
13
- attr_reader :device_types, :audience
11
+ attr_writer :client
12
+
13
+ attr_accessor :device_types,
14
+ :audience,
15
+ :notification,
16
+ :options,
17
+ :message,
18
+ :in_app,
19
+ :campaigns,
20
+ :localizations
21
+
14
22
  include Urbanairship::Common
15
23
  include Urbanairship::Loggable
16
24
 
@@ -23,12 +31,14 @@ module Urbanairship
23
31
 
24
32
  def payload
25
33
  compact_helper({
26
- audience: @audience,
27
- notification: @notification,
28
- options: @options,
29
- device_types: @device_types,
30
- message: @message,
31
- in_app: @in_app
34
+ audience: audience,
35
+ notification: notification,
36
+ options: options,
37
+ device_types: device_types,
38
+ message: message,
39
+ in_app: in_app,
40
+ campaigns: campaigns,
41
+ localizations: localizations
32
42
  })
33
43
  end
34
44
 
@@ -42,7 +52,7 @@ module Urbanairship
42
52
  response = @client.send_request(
43
53
  method: 'POST',
44
54
  body: JSON.dump(payload),
45
- url: PUSH_URL,
55
+ url: push_url,
46
56
  content_type: 'application/json'
47
57
  )
48
58
  pr = PushResponse.new(http_response_body: response['body'], http_response_code: response['code'].to_s)
@@ -83,7 +93,7 @@ module Urbanairship
83
93
  response = @client.send_request(
84
94
  method: 'POST',
85
95
  body: JSON.dump(payload),
86
- url: SCHEDULES_URL,
96
+ url: schedules_url,
87
97
  content_type: 'application/json'
88
98
  )
89
99
  pr = PushResponse.new(http_response_body: response['body'], http_response_code: response['code'].to_s)
@@ -160,7 +170,7 @@ module Urbanairship
160
170
  'schedule_id must be a string' unless schedule_id.is_a? String
161
171
  resp = @client.send_request(
162
172
  method: 'GET',
163
- url: SCHEDULES_URL + schedule_id
173
+ url: schedules_url(schedule_id)
164
174
  )
165
175
  logger.info("Retrieved info for schedule_id #{schedule_id}")
166
176
  resp
@@ -171,7 +181,7 @@ module Urbanairship
171
181
  class ScheduledPushList < Urbanairship::Common::PageIterator
172
182
  def initialize(client: required('client'))
173
183
  super(client: client)
174
- @next_page = SCHEDULES_URL
184
+ @next_page = schedules_url
175
185
  @data_attribute = 'schedules'
176
186
  end
177
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)
@@ -35,7 +35,7 @@ module Urbanairship
35
35
  fail ArgumentError,
36
36
  'push_id cannot be nil' if push_id.nil?
37
37
 
38
- url = REPORTS_URL + 'responses/' + push_id
38
+ url = reports_url('responses/' + push_id)
39
39
  response = @client.send_request(method: 'GET', url: url)
40
40
  logger.info("Retrieved info on push_id: #{push_id}")
41
41
  response
@@ -60,7 +60,7 @@ module Urbanairship
60
60
  fail ArgumentError,
61
61
  'start_date and end_date must be valid date strings'
62
62
  end
63
- url = REPORTS_URL + 'responses/list?start=' + start_parsed.iso8601 + '&end=' + end_parsed.iso8601
63
+ url = reports_url('responses/list?start=' + start_parsed.iso8601 + '&end=' + end_parsed.iso8601)
64
64
  url += '&limit' + limit.to_s unless limit.nil?
65
65
  url += '&push_id_start&' + push_id_start unless push_id_start.nil?
66
66
  @next_page = url
@@ -87,7 +87,7 @@ module Urbanairship
87
87
  end
88
88
  response = @client.send_request(
89
89
  method: 'GET',
90
- url: REPORTS_URL + 'devices/?date=' + date_parsed.iso8601
90
+ url: reports_url('devices/?date=' + date_parsed.iso8601)
91
91
  )
92
92
  logger.info("Retrieved device report for date #{date}")
93
93
  response
@@ -99,7 +99,7 @@ module Urbanairship
99
99
  end_date: required('end_date'), precision: required('precision'))
100
100
  super(client: client)
101
101
  url = Helper.new.get_url(start_date, end_date, precision)
102
- @next_page = REPORTS_URL + 'optins/' + url
102
+ @next_page = reports_url('optins/' + url)
103
103
  @data_attribute = 'optins'
104
104
  end
105
105
  end
@@ -109,7 +109,7 @@ module Urbanairship
109
109
  end_date: required('end_date'), precision: required('precision'))
110
110
  super(client: client)
111
111
  url = Helper.new.get_url(start_date, end_date, precision)
112
- @next_page = REPORTS_URL + 'optouts/' + url
112
+ @next_page = reports_url('optouts/' + url)
113
113
  @data_attribute = 'optouts'
114
114
  end
115
115
  end
@@ -119,7 +119,7 @@ module Urbanairship
119
119
  end_date: required('end_date'), precision: required('precision'))
120
120
  super(client: client)
121
121
  url = Helper.new.get_url(start_date, end_date, precision)
122
- @next_page = REPORTS_URL + 'sends/' + url
122
+ @next_page = reports_url('sends/' + url)
123
123
  @data_attribute = 'sends'
124
124
  end
125
125
  end
@@ -129,7 +129,7 @@ module Urbanairship
129
129
  end_date: required('end_date'), precision: required('precision'))
130
130
  super(client: client)
131
131
  url = Helper.new.get_url(start_date, end_date, precision)
132
- @next_page = REPORTS_URL + 'responses/' + url
132
+ @next_page = reports_url('responses/' + url)
133
133
  @data_attribute = 'responses'
134
134
  end
135
135
  end
@@ -139,7 +139,7 @@ module Urbanairship
139
139
  end_date: required('end_date'), precision: required('precision'))
140
140
  super(client: client)
141
141
  url = Helper.new.get_url(start_date, end_date, precision)
142
- @next_page = REPORTS_URL + 'opens/' + url
142
+ @next_page = reports_url('opens/' + url)
143
143
  @data_attribute = 'opens'
144
144
  end
145
145
  end
@@ -149,7 +149,7 @@ module Urbanairship
149
149
  end_date: required('end_date'), precision: required('precision'))
150
150
  super(client: client)
151
151
  url = Helper.new.get_url(start_date, end_date, precision)
152
- @next_page = REPORTS_URL + 'timeinapp/' + url
152
+ @next_page = reports_url('timeinapp/' + url)
153
153
  @data_attribute = 'timeinapp'
154
154
  end
155
155
  end
@@ -1,3 +1,3 @@
1
1
  module Urbanairship
2
- VERSION = '5.6.0'
2
+ VERSION = '6.0.0'
3
3
  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: 5.6.0
4
+ version: 6.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: 2020-05-11 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -138,6 +138,9 @@ files:
138
138
  - bin/console
139
139
  - bin/setup
140
140
  - docs/Makefile
141
+ - docs/ab_tests.rst
142
+ - docs/attributes.rst
143
+ - docs/automations.rst
141
144
  - docs/channel_uninstall.rst
142
145
  - docs/conf.py
143
146
  - docs/create_and_send.rst
@@ -157,9 +160,17 @@ files:
157
160
  - docs/tags.rst
158
161
  - example/pusher.rb
159
162
  - lib/urbanairship.rb
163
+ - lib/urbanairship/ab_tests/ab_test.rb
164
+ - lib/urbanairship/ab_tests/experiment.rb
165
+ - lib/urbanairship/ab_tests/variant.rb
166
+ - lib/urbanairship/automations/automation.rb
167
+ - lib/urbanairship/automations/pipeline.rb
160
168
  - lib/urbanairship/client.rb
161
169
  - lib/urbanairship/common.rb
162
170
  - lib/urbanairship/configuration.rb
171
+ - lib/urbanairship/custom_events/custom_event.rb
172
+ - lib/urbanairship/custom_events/payload.rb
173
+ - lib/urbanairship/devices/attribute.rb
163
174
  - lib/urbanairship/devices/channel_tags.rb
164
175
  - lib/urbanairship/devices/channel_uninstall.rb
165
176
  - lib/urbanairship/devices/create_and_send.rb
@@ -188,7 +199,7 @@ licenses:
188
199
  - Apache-2.0
189
200
  metadata:
190
201
  allowed_push_host: https://rubygems.org
191
- post_install_message:
202
+ post_install_message:
192
203
  rdoc_options: []
193
204
  require_paths:
194
205
  - lib
@@ -204,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
215
  version: '0'
205
216
  requirements: []
206
217
  rubygems_version: 3.0.1
207
- signing_key:
218
+ signing_key:
208
219
  specification_version: 4
209
220
  summary: Ruby Gem for using the Airship API
210
221
  test_files: []