urbanairship 5.6.1 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +30 -0
- data/README.rst +91 -34
- data/docs/ab_tests.rst +162 -0
- data/docs/attributes.rst +52 -0
- data/docs/automations.rst +212 -0
- data/docs/index.rst +3 -0
- data/docs/push.rst +24 -0
- data/docs/sms.rst +19 -0
- data/docs/static_lists.rst +2 -2
- data/lib/urbanairship.rb +12 -0
- data/lib/urbanairship/ab_tests/ab_test.rb +88 -0
- data/lib/urbanairship/ab_tests/experiment.rb +45 -0
- data/lib/urbanairship/ab_tests/variant.rb +34 -0
- data/lib/urbanairship/automations/automation.rb +105 -0
- data/lib/urbanairship/automations/pipeline.rb +52 -0
- data/lib/urbanairship/client.rb +32 -10
- data/lib/urbanairship/common.rb +108 -42
- 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/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 +6 -6
- 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 +23 -13
- data/lib/urbanairship/push/schedule.rb +9 -0
- data/lib/urbanairship/reports/response_statistics.rb +42 -31
- data/lib/urbanairship/version.rb +1 -1
- metadata +16 -5
@@ -15,7 +15,7 @@ module Urbanairship
|
|
15
15
|
@add_group = {}
|
16
16
|
@remove_group = {}
|
17
17
|
@set_group = {}
|
18
|
-
@
|
18
|
+
@path = channel_path('tags/')
|
19
19
|
end
|
20
20
|
|
21
21
|
def set_audience(ios: nil, android: nil, amazon: nil)
|
@@ -62,7 +62,7 @@ module Urbanairship
|
|
62
62
|
response = @client.send_request(
|
63
63
|
method: 'POST',
|
64
64
|
body: JSON.dump(payload),
|
65
|
-
|
65
|
+
path: @path,
|
66
66
|
content_type: 'application/json'
|
67
67
|
)
|
68
68
|
logger.info("Set tags for audience: #{@audience}")
|
@@ -23,7 +23,7 @@ module Urbanairship
|
|
23
23
|
response = @client.send_request(
|
24
24
|
method: 'POST',
|
25
25
|
body: JSON.dump(channels),
|
26
|
-
|
26
|
+
path: channel_path('uninstall/'),
|
27
27
|
content_type: 'application/json'
|
28
28
|
)
|
29
29
|
|
@@ -31,33 +31,33 @@ module Urbanairship
|
|
31
31
|
response
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
35
|
-
|
34
|
+
|
35
|
+
|
36
36
|
class OpenChannelUninstall
|
37
37
|
include Urbanairship::Common
|
38
38
|
include Urbanairship::Loggable
|
39
39
|
attr_reader :client
|
40
|
-
|
40
|
+
|
41
41
|
def initialize(client: required('client'))
|
42
42
|
@client = client
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def uninstall(address: required('address'),
|
46
46
|
open_platform: required('open_platform'))
|
47
|
-
|
47
|
+
|
48
48
|
body = {
|
49
49
|
address: address,
|
50
50
|
open_platform_name: open_platform
|
51
51
|
}
|
52
|
-
|
52
|
+
|
53
53
|
response = @client.send_request(
|
54
54
|
method: 'POST',
|
55
55
|
body: JSON.dump(body),
|
56
|
-
|
56
|
+
path: open_channel_path('uninstall/'),
|
57
57
|
content_type: 'application/json'
|
58
58
|
)
|
59
|
-
|
60
|
-
logger.info { "Successfully
|
59
|
+
|
60
|
+
logger.info { "Successfully uninstalled open channel with address: #{address}"}
|
61
61
|
response
|
62
62
|
end
|
63
63
|
end
|
@@ -44,7 +44,7 @@ module Urbanairship
|
|
44
44
|
campaign_object = {'categories': campaigns}
|
45
45
|
full_payload[:campaigns] = campaign_object
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
full_payload
|
49
49
|
end
|
50
50
|
|
@@ -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: create_and_send_path,
|
56
56
|
content_type: 'application/json'
|
57
57
|
)
|
58
58
|
logger.info("Running create and send for addresses #{@addresses}")
|
@@ -63,7 +63,7 @@ module Urbanairship
|
|
63
63
|
response = @client.send_request(
|
64
64
|
method: 'POST',
|
65
65
|
body: JSON.dump(payload),
|
66
|
-
|
66
|
+
path: create_and_send_path('validate'),
|
67
67
|
content_type: 'application/json'
|
68
68
|
)
|
69
69
|
logger.info("Validating payload for create and send")
|
@@ -84,7 +84,7 @@ module Urbanairship
|
|
84
84
|
response = @client.send_request(
|
85
85
|
method: 'POST',
|
86
86
|
body: JSON.dump(scheduled_payload),
|
87
|
-
|
87
|
+
path: schedules_path('create-and-send'),
|
88
88
|
content_type: 'application/json'
|
89
89
|
)
|
90
90
|
logger.info("Scheduling create and send operation with name #{@name}")
|
@@ -7,6 +7,8 @@ module Urbanairship
|
|
7
7
|
include Urbanairship::Common
|
8
8
|
include Urbanairship::Loggable
|
9
9
|
attr_writer :client
|
10
|
+
attr_accessor :audience,
|
11
|
+
:attributes
|
10
12
|
|
11
13
|
def initialize(client: required('client'))
|
12
14
|
@client = client
|
@@ -15,17 +17,36 @@ module Urbanairship
|
|
15
17
|
def lookup(uuid: required('uuid'))
|
16
18
|
response = @client.send_request(
|
17
19
|
method: 'GET',
|
18
|
-
|
20
|
+
path: channel_path(uuid)
|
19
21
|
)
|
20
22
|
logger.info("Retrieved channel information for #{uuid}")
|
21
23
|
response['body']['channel']
|
22
24
|
end
|
25
|
+
|
26
|
+
def payload
|
27
|
+
{
|
28
|
+
'audience': audience,
|
29
|
+
'attributes': [
|
30
|
+
attributes
|
31
|
+
]
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_attributes
|
36
|
+
response = @client.send_request(
|
37
|
+
method: 'POST',
|
38
|
+
body: JSON.dump(payload),
|
39
|
+
path: channel_path('attributes'),
|
40
|
+
content_type: 'application/json'
|
41
|
+
)
|
42
|
+
response
|
43
|
+
end
|
23
44
|
end
|
24
45
|
|
25
46
|
class ChannelList < Urbanairship::Common::PageIterator
|
26
47
|
def initialize(client: required('client'))
|
27
48
|
super(client: client)
|
28
|
-
@
|
49
|
+
@next_page_path = channel_path
|
29
50
|
@data_attribute = 'channels'
|
30
51
|
end
|
31
52
|
end
|
@@ -43,7 +64,7 @@ module Urbanairship
|
|
43
64
|
|
44
65
|
resp = @client.send_request(
|
45
66
|
method: 'GET',
|
46
|
-
|
67
|
+
path: device_token_path(token)
|
47
68
|
)
|
48
69
|
logger.info("Looking up info on device token #{token}")
|
49
70
|
resp
|
@@ -56,7 +77,7 @@ module Urbanairship
|
|
56
77
|
|
57
78
|
def initialize(client: required('client'))
|
58
79
|
super(client: client)
|
59
|
-
@
|
80
|
+
@next_page_path = device_token_path
|
60
81
|
@data_attribute = 'device_tokens'
|
61
82
|
end
|
62
83
|
end
|
@@ -74,7 +95,7 @@ module Urbanairship
|
|
74
95
|
|
75
96
|
resp = @client.send_request(
|
76
97
|
method: 'GET',
|
77
|
-
|
98
|
+
path: apid_path(apid)
|
78
99
|
)
|
79
100
|
logger.info("Retrieved info on apid #{apid}")
|
80
101
|
resp
|
@@ -84,9 +105,9 @@ module Urbanairship
|
|
84
105
|
class APIDList < Urbanairship::Common::PageIterator
|
85
106
|
def initialize(client: required('client'))
|
86
107
|
super(client: client)
|
87
|
-
@
|
108
|
+
@next_page_path = apid_path
|
88
109
|
@data_attribute = 'apids'
|
89
110
|
end
|
90
111
|
end
|
91
112
|
end
|
92
|
-
end
|
113
|
+
end
|
@@ -41,7 +41,7 @@ module Urbanairship
|
|
41
41
|
response = @client.send_request(
|
42
42
|
method: 'POST',
|
43
43
|
body: JSON.dump(payload),
|
44
|
-
|
44
|
+
path: channel_path('email'),
|
45
45
|
content_type: 'application/json'
|
46
46
|
)
|
47
47
|
logger.info("Registering email channel with address #{address}")
|
@@ -58,7 +58,7 @@ module Urbanairship
|
|
58
58
|
response = @client.send_request(
|
59
59
|
method: 'POST',
|
60
60
|
body: JSON.dump(payload),
|
61
|
-
|
61
|
+
path: channel_path('email/uninstall'),
|
62
62
|
content_type: 'application/json'
|
63
63
|
)
|
64
64
|
logger.info("Uninstalling email channel with address #{address}")
|
@@ -70,7 +70,7 @@ module Urbanairship
|
|
70
70
|
|
71
71
|
response = @client.send_request(
|
72
72
|
method: 'GET',
|
73
|
-
|
73
|
+
path: channel_path('email/' + address)
|
74
74
|
)
|
75
75
|
logger.info("Looking up email channel with address #{address}")
|
76
76
|
response
|
@@ -95,7 +95,7 @@ module Urbanairship
|
|
95
95
|
|
96
96
|
response = @client.send_request(
|
97
97
|
method: 'PUT',
|
98
|
-
|
98
|
+
path: channel_path('email/' + channel_id),
|
99
99
|
body: JSON.dump(payload),
|
100
100
|
content_type: 'application/json'
|
101
101
|
)
|
@@ -109,7 +109,7 @@ module Urbanairship
|
|
109
109
|
|
110
110
|
def initialize(client: required('client'))
|
111
111
|
super(client: client)
|
112
|
-
@
|
112
|
+
@path = channel_path('email/tags')
|
113
113
|
end
|
114
114
|
|
115
115
|
def set_audience(email_address: required('email_address'))
|
@@ -25,7 +25,7 @@ module Urbanairship
|
|
25
25
|
response = @client.send_request(
|
26
26
|
method: 'POST',
|
27
27
|
body: JSON.dump(payload),
|
28
|
-
|
28
|
+
path: named_users_path('/associate'),
|
29
29
|
content_type: 'application/json'
|
30
30
|
)
|
31
31
|
logger.info { "Associated channel_id #{channel_id} with named_user #{@named_user_id}" }
|
@@ -40,7 +40,7 @@ module Urbanairship
|
|
40
40
|
response = @client.send_request(
|
41
41
|
method: 'POST',
|
42
42
|
body: JSON.dump(payload),
|
43
|
-
|
43
|
+
path: named_users_path('/disassociate'),
|
44
44
|
content_type: 'application/json'
|
45
45
|
)
|
46
46
|
logger.info { "Dissociated channel_id #{channel_id}" }
|
@@ -52,7 +52,7 @@ module Urbanairship
|
|
52
52
|
'named_user_id is required for lookup' if @named_user_id.nil?
|
53
53
|
response = @client.send_request(
|
54
54
|
method: 'GET',
|
55
|
-
|
55
|
+
path: named_users_path('?id=' + @named_user_id),
|
56
56
|
)
|
57
57
|
logger.info { "Retrieved information on named_user_id #{@named_user_id}" }
|
58
58
|
response
|
@@ -65,7 +65,7 @@ module Urbanairship
|
|
65
65
|
|
66
66
|
def initialize(client: required('client'))
|
67
67
|
super(client: client)
|
68
|
-
@
|
68
|
+
@path = named_users_path('tags/')
|
69
69
|
end
|
70
70
|
|
71
71
|
def set_audience(user_ids: required('user_ids'))
|
@@ -79,7 +79,7 @@ module Urbanairship
|
|
79
79
|
|
80
80
|
def initialize(client: required('client'))
|
81
81
|
super(client: client)
|
82
|
-
@
|
82
|
+
@next_page_path = named_users_path
|
83
83
|
@data_attribute = 'named_users'
|
84
84
|
end
|
85
85
|
end
|
@@ -101,7 +101,7 @@ module Urbanairship
|
|
101
101
|
response = @client.send_request(
|
102
102
|
method: 'POST',
|
103
103
|
body: JSON.dump(payload),
|
104
|
-
|
104
|
+
path: named_users_path('/uninstall'),
|
105
105
|
content_type: 'application/json'
|
106
106
|
)
|
107
107
|
logger.info { "Uninstalled named_user_ids #{@named_user_ids} " }
|
@@ -5,11 +5,11 @@ module Urbanairship
|
|
5
5
|
class OpenChannel
|
6
6
|
include Urbanairship::Common
|
7
7
|
include Urbanairship::Loggable
|
8
|
-
attr_accessor :channel_id,
|
9
|
-
:open_platform,
|
10
|
-
:opt_in,
|
8
|
+
attr_accessor :channel_id,
|
9
|
+
:open_platform,
|
10
|
+
:opt_in,
|
11
11
|
:address,
|
12
|
-
:tags,
|
12
|
+
:tags,
|
13
13
|
:identifiers,
|
14
14
|
:template_id,
|
15
15
|
:alert,
|
@@ -21,16 +21,16 @@ module Urbanairship
|
|
21
21
|
:fields,
|
22
22
|
:interactive,
|
23
23
|
:platform_alert
|
24
|
-
|
24
|
+
|
25
25
|
def initialize(client: required('client'))
|
26
26
|
@client = client
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def create()
|
30
30
|
fail TypeError, 'address must be set to create open channel' unless address.is_a? String
|
31
31
|
fail TypeError, 'open_platform must be set to create open channel' unless open_platform.is_a? String
|
32
32
|
fail TypeError, 'opt_in must be boolean' unless [true, false].include? opt_in
|
33
|
-
|
33
|
+
|
34
34
|
channel_data = {
|
35
35
|
'type': 'open',
|
36
36
|
'open': {:open_platform_name => open_platform},
|
@@ -38,21 +38,21 @@ module Urbanairship
|
|
38
38
|
'address': address,
|
39
39
|
'tags': tags
|
40
40
|
}.delete_if {|key, value| value.nil?} #this removes the nil key value pairs
|
41
|
-
|
41
|
+
|
42
42
|
set_identifiers
|
43
|
-
|
43
|
+
|
44
44
|
body = {'channel': channel_data}
|
45
|
-
|
45
|
+
|
46
46
|
response = @client.send_request(
|
47
47
|
method: 'POST',
|
48
|
-
|
48
|
+
path: open_channel_path,
|
49
49
|
body: JSON.dump(body),
|
50
50
|
content_type: 'application/json'
|
51
51
|
)
|
52
52
|
logger.info("Registering open channel with address: #{address}")
|
53
53
|
response
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def update(set_tags: required('set_tags'))
|
57
57
|
fail ArgumentError, 'set_tags must be boolean' unless [true, false].include? set_tags
|
58
58
|
fail ArgumentError, 'set_tags cannot be true when tags are not set' unless set_tags == true && tags != nil
|
@@ -60,7 +60,7 @@ module Urbanairship
|
|
60
60
|
fail TypeError, 'address or channel_id must not be nil' unless address.is_a? String || channel_id.is_a?(String)
|
61
61
|
fail TypeError, 'open_platform cannot be nil' unless open_platform.is_a? String
|
62
62
|
fail TypeErorr, 'address must not be nil if opt_in is true' unless opt_in.is_a? TrueClass
|
63
|
-
|
63
|
+
|
64
64
|
channel_data = {
|
65
65
|
'type': 'open',
|
66
66
|
'open': {'open_platform_name': open_platform},
|
@@ -70,34 +70,34 @@ module Urbanairship
|
|
70
70
|
'address': address,
|
71
71
|
'tags': tags
|
72
72
|
}.delete_if {|key, value| value.nil?} #this removes the nil key value pairs
|
73
|
-
|
73
|
+
|
74
74
|
set_identifiers
|
75
|
-
|
75
|
+
|
76
76
|
body = {'channel': channel_data}
|
77
|
-
|
77
|
+
|
78
78
|
response = @client.send_request(
|
79
79
|
method: 'POST',
|
80
|
-
|
80
|
+
path: open_channel_path,
|
81
81
|
body: JSON.dump(body),
|
82
82
|
content_type: 'application/json'
|
83
83
|
)
|
84
84
|
logger.info("Updating open channel with address #{address}")
|
85
85
|
response
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
def lookup(channel_id: required('channel_id'))
|
89
89
|
fail ArgumentError, 'channel_id needs to be a string' unless channel_id.is_a? String
|
90
|
-
|
90
|
+
|
91
91
|
response = @client.send_request(
|
92
92
|
method: 'GET',
|
93
|
-
|
93
|
+
path: channel_path(channel_id)
|
94
94
|
)
|
95
95
|
logger.info("Looking up info on device token #{channel_id}")
|
96
96
|
response
|
97
97
|
end
|
98
98
|
|
99
99
|
def notification_with_template_id
|
100
|
-
fail TypeError, 'open_platform cannot be nil' if open_platform.nil?
|
100
|
+
fail TypeError, 'open_platform cannot be nil' if open_platform.nil?
|
101
101
|
|
102
102
|
if alert
|
103
103
|
payload = {
|
@@ -124,7 +124,7 @@ module Urbanairship
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def open_channel_override
|
127
|
-
fail TypeError, 'open_platform cannot be nil' if open_platform.nil?
|
127
|
+
fail TypeError, 'open_platform cannot be nil' if open_platform.nil?
|
128
128
|
payload = {
|
129
129
|
'alert': platform_alert,
|
130
130
|
'extra': extra,
|
@@ -147,4 +147,3 @@ module Urbanairship
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
150
|
-
|
@@ -28,7 +28,7 @@ module Urbanairship
|
|
28
28
|
response = @client.send_request(
|
29
29
|
method: 'POST',
|
30
30
|
body: JSON.dump(payload),
|
31
|
-
|
31
|
+
path: segments_path,
|
32
32
|
content_type: 'application/json'
|
33
33
|
)
|
34
34
|
logger.info { "Successful segment creation: #{@display_name}" }
|
@@ -45,7 +45,7 @@ module Urbanairship
|
|
45
45
|
'id must be set to a valid string' if id.nil?
|
46
46
|
response = @client.send_request(
|
47
47
|
method: 'GET',
|
48
|
-
|
48
|
+
path: segments_path(id)
|
49
49
|
)
|
50
50
|
logger.info("Retrieved segment information for #{id}")
|
51
51
|
@id = id
|
@@ -69,7 +69,7 @@ module Urbanairship
|
|
69
69
|
response = @client.send_request(
|
70
70
|
method: 'PUT',
|
71
71
|
body: JSON.dump(data),
|
72
|
-
|
72
|
+
path: segments_path(@id),
|
73
73
|
content_type: 'application/json'
|
74
74
|
)
|
75
75
|
logger.info { "Successful segment update: #{@display_name}" }
|
@@ -80,13 +80,11 @@ module Urbanairship
|
|
80
80
|
#
|
81
81
|
# @ returns [Object] response HTTP response
|
82
82
|
def delete
|
83
|
-
fail ArgumentError,
|
84
|
-
'id cannot be nil' if id.nil?
|
83
|
+
fail ArgumentError, 'id cannot be nil' if id.nil?
|
85
84
|
|
86
|
-
url = SEGMENTS_URL + id
|
87
85
|
response = @client.send_request(
|
88
86
|
method: 'DELETE',
|
89
|
-
|
87
|
+
path: segments_path(id)
|
90
88
|
)
|
91
89
|
logger.info { "Successful segment deletion: #{@display_name}" }
|
92
90
|
response
|
@@ -98,7 +96,7 @@ module Urbanairship
|
|
98
96
|
|
99
97
|
def initialize(client: required('client'))
|
100
98
|
super(client: client)
|
101
|
-
@
|
99
|
+
@next_page_path = segments_path
|
102
100
|
@data_attribute = 'segments'
|
103
101
|
end
|
104
102
|
end
|