urbanairship 5.6.1 → 5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/docs/ab_tests.rst +162 -0
- data/docs/automations.rst +212 -0
- data/lib/urbanairship.rb +7 -0
- data/lib/urbanairship/ab_tests/ab_test.rb +89 -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/common.rb +1 -0
- data/lib/urbanairship/push/push.rb +19 -9
- data/lib/urbanairship/version.rb +1 -1
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d4dc107770392a93c88c327e14122fc56cb6ec8fbd17f58984df43d2661d630
|
4
|
+
data.tar.gz: 75c8ff88b54de9ad97fa3dbf503333bc49cd29c0fcfea2e937fe7cce5a4f3c92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6203f67400dd7581568c1307c688ae842c32c1b67532ead780a62cd3ca9aa9256511a5d6a7f0b9e68f58acc5a3e56bfc4172f5ec4bf24c622285f94f04d4bd3
|
7
|
+
data.tar.gz: 4c6660cdd60ed9628151f19a448ecbbdde3b43a0bff521c95ef1903874f17610c3194c467623bd37a67f95f9fea9139e1b60acaf818aa2899f0ba7f6c022591d
|
data/CHANGELOG
CHANGED
data/docs/ab_tests.rst
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
A/B Tests
|
2
|
+
=========
|
3
|
+
|
4
|
+
In this client, we format A/B tests with three nesting components. The first is the Variant,
|
5
|
+
the difference between one kind of push and another. The Variant is a part of the Experiment
|
6
|
+
object, with many variants in an array. Lastly. AbTest handles what Experiments along with their Variants
|
7
|
+
get sent to the various API endpoints. Basic pushes can be added straight to the Variant object
|
8
|
+
on the push instance variable, or a Push object can be created, and the payload applied to the
|
9
|
+
Variant object. For more information on this please visit: https://docs.airship.com/api/ua/#tag/a/b-tests
|
10
|
+
|
11
|
+
List Existing A/B Tests
|
12
|
+
-----------------------
|
13
|
+
|
14
|
+
This endpoint will return the existing A/B tests on a project.
|
15
|
+
|
16
|
+
.. code-block:: ruby
|
17
|
+
|
18
|
+
require 'urbanairship'
|
19
|
+
UA = Urbanairship
|
20
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
21
|
+
ab_test = UA::AbTest.new(client: airship)
|
22
|
+
ab_test.limit = 5
|
23
|
+
ab_test.list_ab_test
|
24
|
+
|
25
|
+
.. note::
|
26
|
+
|
27
|
+
Should return a 200 HTTP status code as well as a list of existing A/B tests with a
|
28
|
+
default offset and a limit of 5. The limit and offset are optional here.
|
29
|
+
|
30
|
+
Create A/B Test
|
31
|
+
----------------
|
32
|
+
|
33
|
+
As described above, the creation of an A/B Test consists of creating a few objects, grabbing
|
34
|
+
pertinent data out of them, and creating an A/B Test that is as complicated or as simple as you
|
35
|
+
like. In some cases, it might be easier to assign the payload values yourself, but as pushes,
|
36
|
+
and the tests themselves get more complicated, it is easier to let the objects do the work for you.
|
37
|
+
|
38
|
+
|
39
|
+
.. code-block:: ruby
|
40
|
+
|
41
|
+
require 'urbanairship'
|
42
|
+
UA = Urbanairship
|
43
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
44
|
+
variant_one = UA::Variant.new(client: airship)
|
45
|
+
variant_one.push = {
|
46
|
+
"notification": {
|
47
|
+
"alert": "I love cereal"
|
48
|
+
}
|
49
|
+
}
|
50
|
+
variant_two = UA::Variant.new(client: airship)
|
51
|
+
variant_two.push = {
|
52
|
+
"notification": {
|
53
|
+
"alert": "I prefer oatmeal"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
experiment = UA::Experiment.new(client: airship)
|
57
|
+
experiment.name = 'Neat experiment'
|
58
|
+
experiment.description = 'See how neat we can get'
|
59
|
+
experiment.audience = 'all'
|
60
|
+
experiment.device_types = 'all'
|
61
|
+
experiment.variants << variant_one.payload
|
62
|
+
experiment.variants << variant_two.payload
|
63
|
+
ab_test = UA::AbTest.new(client: airship)
|
64
|
+
ab_test.experiment_object = experiment.payload
|
65
|
+
ab_test.create_ab_test
|
66
|
+
|
67
|
+
.. note::
|
68
|
+
|
69
|
+
Should return a 201 HTTP status code as well as other information detailing specific
|
70
|
+
information (such as push_id) for the newly created A/B Test.
|
71
|
+
|
72
|
+
List Scheduled A/B Tests
|
73
|
+
------------------------
|
74
|
+
|
75
|
+
This will list all the scheduled A/B Tests for a project.
|
76
|
+
|
77
|
+
.. code-block:: ruby
|
78
|
+
|
79
|
+
require 'urbanairship'
|
80
|
+
UA = Urbanairship
|
81
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
82
|
+
ab_test = UA::AbTest.new(client: airship)
|
83
|
+
ab_test.list_scheduled_ab_test
|
84
|
+
|
85
|
+
.. note::
|
86
|
+
|
87
|
+
Should return a 200 HTTP status code. Here, you can also apply limit and offset by assigning
|
88
|
+
values to the instance variables on the AbTest object.
|
89
|
+
|
90
|
+
Delete A/B Test
|
91
|
+
----------------
|
92
|
+
|
93
|
+
This will delete an A/B Test with a given experiment ID.
|
94
|
+
|
95
|
+
.. code-block:: ruby
|
96
|
+
|
97
|
+
require 'urbanairship'
|
98
|
+
UA = Urbanairship
|
99
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
100
|
+
ab_test = UA::AbTest.new(client: airship)
|
101
|
+
ab_test.experiment_id = '<experiment_id>'
|
102
|
+
ab_test.delete_ab_test
|
103
|
+
|
104
|
+
.. note::
|
105
|
+
|
106
|
+
Response should be a 200 HTTP Response
|
107
|
+
|
108
|
+
Validate A/B Test
|
109
|
+
------------------
|
110
|
+
|
111
|
+
Very similar to the create A/B Test endpoint, this will validate an A/B Test to
|
112
|
+
see if it is formatted properly.
|
113
|
+
|
114
|
+
.. code-block:: ruby
|
115
|
+
|
116
|
+
require 'urbanairship'
|
117
|
+
UA = Urbanairship
|
118
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
119
|
+
variant_one = UA::Variant.new(client: airship)
|
120
|
+
variant_one.push = {
|
121
|
+
"notification": {
|
122
|
+
"alert": "I love cereal"
|
123
|
+
}
|
124
|
+
}
|
125
|
+
variant_two = UA::Variant.new(client: airship)
|
126
|
+
variant_two.push = {
|
127
|
+
"notification": {
|
128
|
+
"alert": "I prefer oatmeal"
|
129
|
+
}
|
130
|
+
}
|
131
|
+
experiment = UA::Experiment.new(client: airship)
|
132
|
+
experiment.name = 'Neat experiment'
|
133
|
+
experiment.description = 'See how neat we can get'
|
134
|
+
experiment.audience = 'all'
|
135
|
+
experiment.device_types = 'all'
|
136
|
+
experiment.variants << variant_one.payload
|
137
|
+
experiment.variants << variant_two.payload
|
138
|
+
ab_test = UA::AbTest.new(client: airship)
|
139
|
+
ab_test.experiment_object = experiment.payload
|
140
|
+
ab_test.validate_ab_test
|
141
|
+
|
142
|
+
.. note::
|
143
|
+
|
144
|
+
Should return a 200 HTTP status code.
|
145
|
+
|
146
|
+
Individual A/B Test Lookup
|
147
|
+
--------------------------
|
148
|
+
|
149
|
+
This will lookup a specific A/B Test with a given experiment_id
|
150
|
+
|
151
|
+
.. code-block:: ruby
|
152
|
+
|
153
|
+
require 'urbanairship'
|
154
|
+
UA = Urbanairship
|
155
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
156
|
+
ab_test = UA::AbTest.new(client: airship)
|
157
|
+
ab_test.experiment_id = '<experiment_id>'
|
158
|
+
ab_test.lookup_ab_test
|
159
|
+
|
160
|
+
.. note::
|
161
|
+
|
162
|
+
Should return a 200 HTTP status code
|
@@ -0,0 +1,212 @@
|
|
1
|
+
Automations
|
2
|
+
===========
|
3
|
+
|
4
|
+
The Automation class harnesses the Pipeline class in order to provide functionality
|
5
|
+
for creating, listing, validating, updating, and deleting pipelines. There are a lot
|
6
|
+
of moving parts that go into creating a pipeline, so please view our docs on that
|
7
|
+
topic here: https://docs.airship.com/api/ua/#schemas%2fpipelineobject
|
8
|
+
|
9
|
+
List Existing Automations
|
10
|
+
-------------------------
|
11
|
+
|
12
|
+
This is for viewing existing pipeleines for a project. There are optional parameters
|
13
|
+
that can be passed into the URI to have control over what pipelines are returned. In the
|
14
|
+
following example a limit query of 5 will be added to the URI.
|
15
|
+
|
16
|
+
.. code-block:: ruby
|
17
|
+
|
18
|
+
require 'urbanairship'
|
19
|
+
UA = Urbanairship
|
20
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
21
|
+
automation = UA::Automation.new(client: airship)
|
22
|
+
automation.limit = 5
|
23
|
+
automation.list_automations
|
24
|
+
|
25
|
+
.. note::
|
26
|
+
|
27
|
+
Should return a 200 HTTP status code, and 5 of the most recent Automations
|
28
|
+
|
29
|
+
Create Automation
|
30
|
+
-----------------
|
31
|
+
|
32
|
+
This will use the Pipeline model to create an automation. You may add several
|
33
|
+
pipelines objects to create several automations/pipelines at once. The example
|
34
|
+
below adds two. If you would like to just add one pipeline, forgo the array,
|
35
|
+
and assign the pipeline payload directly to automation.pipeline_object.
|
36
|
+
|
37
|
+
.. code-block:: ruby
|
38
|
+
|
39
|
+
require 'urbanairship'
|
40
|
+
UA = Urbanairship
|
41
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<app_secret>')
|
42
|
+
pipeline_one = UA::Pipeline.new(client: airship)
|
43
|
+
pipeline_one.enabled = true
|
44
|
+
pipeline_one.immediate_trigger = {
|
45
|
+
"tag_added": {
|
46
|
+
"tag": "new_customer",
|
47
|
+
"group": "crm"
|
48
|
+
}
|
49
|
+
}
|
50
|
+
pipeline_one.outcome = {
|
51
|
+
"push": {
|
52
|
+
"audience": "triggered",
|
53
|
+
"device_types": "all",
|
54
|
+
"notification": {
|
55
|
+
"alert": "Hello new customer!"
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
pipeline_two = UA::Pipeline.new(client: airship)
|
60
|
+
pipeline_two.enabled = true
|
61
|
+
pipeline_two.immediate_trigger = {
|
62
|
+
"tag_added": {
|
63
|
+
"tag": "new_customer",
|
64
|
+
"group": "crm"
|
65
|
+
}
|
66
|
+
}
|
67
|
+
pipeline_two.outcome = {
|
68
|
+
"push": {
|
69
|
+
"audience": "triggered",
|
70
|
+
"device_types": "all",
|
71
|
+
"notification": {
|
72
|
+
"alert": "Here is a different second alert!"
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
pipelines = [pipeline_one.payload, pipeline_two.payload]
|
77
|
+
automation = UA::Automation.new(client: airship)
|
78
|
+
automation.pipeline_object = pipelines
|
79
|
+
automation.create_automation
|
80
|
+
|
81
|
+
.. note::
|
82
|
+
|
83
|
+
Should return a 201 HTTP status code.
|
84
|
+
|
85
|
+
List Deleted Automations
|
86
|
+
------------------------
|
87
|
+
|
88
|
+
This is for viewing deleted pipeleines for a project. The optional param here is for "start";
|
89
|
+
a timestamp of the starting element for paginating results in the format of YYYY-MM-DD.
|
90
|
+
|
91
|
+
.. code-block:: ruby
|
92
|
+
|
93
|
+
require 'urbanairship'
|
94
|
+
UA = Urbanairship
|
95
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
96
|
+
automation = UA::Automation.new(client: airship)
|
97
|
+
automation.start = 2020-02-20
|
98
|
+
automation.list_deleted_automations
|
99
|
+
|
100
|
+
.. note::
|
101
|
+
|
102
|
+
Should return a 200 HTTP status code, and the deleted automations from either most current
|
103
|
+
or from a given start date.
|
104
|
+
|
105
|
+
Validate Automation
|
106
|
+
-------------------
|
107
|
+
|
108
|
+
This endpoint is a lot like the create automation endpoint, the basic set up is the same,
|
109
|
+
only difference here is the method selected.
|
110
|
+
|
111
|
+
.. code-block:: ruby
|
112
|
+
|
113
|
+
require 'urbanairship'
|
114
|
+
UA = Urbanairship
|
115
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<app_secret>')
|
116
|
+
pipeline = UA::Pipeline.new(client: airship)
|
117
|
+
pipeline.enabled = true
|
118
|
+
pipeline.immediate_trigger = {
|
119
|
+
"tag_added": {
|
120
|
+
"tag": "new_customer",
|
121
|
+
"group": "crm"
|
122
|
+
}
|
123
|
+
}
|
124
|
+
pipeline.outcome = {
|
125
|
+
"push": {
|
126
|
+
"audience": "triggered",
|
127
|
+
"device_types": "all",
|
128
|
+
"notification": {
|
129
|
+
"alert": "Hello new customer!"
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}
|
133
|
+
automation = UA::Automation.new(client: airship)
|
134
|
+
automation.pipeline_object = pipeline.payload
|
135
|
+
automation.validate_automation
|
136
|
+
|
137
|
+
.. note::
|
138
|
+
|
139
|
+
Should return a 200 HTTP status code.
|
140
|
+
|
141
|
+
Individual Automation Lookup
|
142
|
+
----------------------------
|
143
|
+
|
144
|
+
This is for looking up a single automation with a given ID.
|
145
|
+
|
146
|
+
.. code-block:: ruby
|
147
|
+
|
148
|
+
require 'urbanairship'
|
149
|
+
UA = Urbanairship
|
150
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
151
|
+
automation = UA::Automation.new(client: airship)
|
152
|
+
automation.pipeline_id = '86ad9239-373d-d0a5-d5d8-04fed18f79bc'
|
153
|
+
automation.lookup_automation
|
154
|
+
|
155
|
+
.. note::
|
156
|
+
|
157
|
+
Should return a 200 HTTP status code, and the payload for the automation in question.
|
158
|
+
|
159
|
+
Update Automation
|
160
|
+
-----------------
|
161
|
+
|
162
|
+
This is for updating an existing automation. You must include the full payload from a POST
|
163
|
+
response, with the updates that you want to make within the payload.
|
164
|
+
|
165
|
+
.. code-block:: ruby
|
166
|
+
|
167
|
+
require 'urbanairship'
|
168
|
+
UA = Urbanairship
|
169
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
170
|
+
pipeline = UA::Pipeline.new(client: airship)
|
171
|
+
pipeline.enabled = true
|
172
|
+
pipeline.immediate_trigger = {
|
173
|
+
"tag_added": {
|
174
|
+
"tag": "new_tag_update",
|
175
|
+
"group": "Locale"
|
176
|
+
}
|
177
|
+
}
|
178
|
+
pipeline.outcome = {
|
179
|
+
"push": {
|
180
|
+
"audience": "triggered",
|
181
|
+
"device_types": "all",
|
182
|
+
"notification": {
|
183
|
+
"alert": "Newly created alert message!"
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
automation = UA::Automation.new(client: airship)
|
188
|
+
automation.pipeline_id = '0f927674-918c-31ef-51ca-e96fdd234da4'
|
189
|
+
automation.pipeline_object = pipeline.payload
|
190
|
+
automation.update_automation
|
191
|
+
|
192
|
+
.. note::
|
193
|
+
|
194
|
+
Should return a 200 HTTP status code.
|
195
|
+
|
196
|
+
Delete Automation
|
197
|
+
-----------------
|
198
|
+
|
199
|
+
This is for deleting a pipeline with a given ID.
|
200
|
+
|
201
|
+
.. code-block:: ruby
|
202
|
+
|
203
|
+
require 'urbanairship'
|
204
|
+
UA = Urbanairship
|
205
|
+
airship = UA::Client.new(key:'<app_key>', secret:'<secret_key>')
|
206
|
+
automation = UA::Automation.new(client: airship)
|
207
|
+
automation.pipeline_id = '86ad9239-373d-d0a5-d5d8-04fed18f79bc'
|
208
|
+
automation.delete_automation
|
209
|
+
|
210
|
+
.. note::
|
211
|
+
|
212
|
+
Response should be a 204 No Content
|
data/lib/urbanairship.rb
CHANGED
@@ -23,6 +23,11 @@ require 'urbanairship/devices/open_channel'
|
|
23
23
|
require 'urbanairship/reports/response_statistics'
|
24
24
|
require 'urbanairship/devices/static_lists'
|
25
25
|
require 'urbanairship/push/location'
|
26
|
+
require 'urbanairship/automations/pipeline'
|
27
|
+
require 'urbanairship/automations/automation'
|
28
|
+
require 'urbanairship/ab_tests/variant'
|
29
|
+
require 'urbanairship/ab_tests/experiment'
|
30
|
+
require 'urbanairship/ab_tests/ab_test'
|
26
31
|
|
27
32
|
module Urbanairship
|
28
33
|
extend Urbanairship::Push::Audience
|
@@ -32,6 +37,8 @@ module Urbanairship
|
|
32
37
|
include Urbanairship::Devices
|
33
38
|
include Urbanairship::Reports
|
34
39
|
include Urbanairship::Push
|
40
|
+
include Urbanairship::Automations
|
41
|
+
include Urbanairship::AbTests
|
35
42
|
|
36
43
|
class << self
|
37
44
|
attr_accessor :configuration
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'urbanairship'
|
3
|
+
require 'urbanairship/ab_tests/experiment'
|
4
|
+
|
5
|
+
module Urbanairship
|
6
|
+
module AbTests
|
7
|
+
class AbTest
|
8
|
+
include Urbanairship::Common
|
9
|
+
include Urbanairship::Loggable
|
10
|
+
attr_accessor :limit,
|
11
|
+
:offset,
|
12
|
+
:experiment_object,
|
13
|
+
:experiment_id
|
14
|
+
|
15
|
+
def initialize(client: required('client'))
|
16
|
+
@client = client
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_ab_test
|
20
|
+
response = @client.send_request(
|
21
|
+
method: 'GET',
|
22
|
+
url: EXPERIMENTS_URL + format_url_with_params
|
23
|
+
)
|
24
|
+
logger.info("Looking up A/B Tests for project")
|
25
|
+
response
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_ab_test
|
29
|
+
response = @client.send_request(
|
30
|
+
method: 'POST',
|
31
|
+
body: JSON.dump(experiment_object),
|
32
|
+
url: EXPERIMENTS_URL,
|
33
|
+
content_type: 'application/json'
|
34
|
+
)
|
35
|
+
logger.info("Created A/B Test")
|
36
|
+
response
|
37
|
+
end
|
38
|
+
|
39
|
+
def list_scheduled_ab_test
|
40
|
+
response = @client.send_request(
|
41
|
+
method: 'GET',
|
42
|
+
url: EXPERIMENTS_URL + 'scheduled' + format_url_with_params
|
43
|
+
)
|
44
|
+
logger.info("Looking up scheduled A/B Tests for project")
|
45
|
+
response
|
46
|
+
end
|
47
|
+
|
48
|
+
def delete_ab_test
|
49
|
+
fail ArgumentError, 'experiment_id must be set to delete individual A/B test' if @experiment_id.nil?
|
50
|
+
response = @client.send_request(
|
51
|
+
method: 'DELETE',
|
52
|
+
url: EXPERIMENTS_URL + 'scheduled/' + experiment_id
|
53
|
+
)
|
54
|
+
logger.info("Deleting A/B test with ID #{experiment_id}")
|
55
|
+
response
|
56
|
+
end
|
57
|
+
|
58
|
+
def validate_ab_test
|
59
|
+
response = @client.send_request(
|
60
|
+
method: 'POST',
|
61
|
+
body: JSON.dump(experiment_object),
|
62
|
+
url: EXPERIMENTS_URL + 'validate',
|
63
|
+
content_type: 'application/json'
|
64
|
+
)
|
65
|
+
logger.info("Validating A/B Test")
|
66
|
+
response
|
67
|
+
end
|
68
|
+
|
69
|
+
def lookup_ab_test
|
70
|
+
fail ArgumentError, 'experiment_id must be set to lookup individual A/B Test' if @experiment_id.nil?
|
71
|
+
response = @client.send_request(
|
72
|
+
method: 'GET',
|
73
|
+
url: EXPERIMENTS_URL + experiment_id
|
74
|
+
)
|
75
|
+
logger.info("Looking up A/B test with ID #{experiment_id}")
|
76
|
+
response
|
77
|
+
end
|
78
|
+
|
79
|
+
def format_url_with_params
|
80
|
+
params = []
|
81
|
+
params << ['limit', limit] if limit
|
82
|
+
params << ['offset', offset] if offset
|
83
|
+
query = URI.encode_www_form(params)
|
84
|
+
'?' + query
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'urbanairship'
|
2
|
+
|
3
|
+
module Urbanairship
|
4
|
+
module AbTests
|
5
|
+
class Experiment
|
6
|
+
include Urbanairship::Common
|
7
|
+
include Urbanairship::Loggable
|
8
|
+
attr_accessor :audience,
|
9
|
+
:campaigns,
|
10
|
+
:control,
|
11
|
+
:created_at,
|
12
|
+
:description,
|
13
|
+
:device_types,
|
14
|
+
:id,
|
15
|
+
:name,
|
16
|
+
:push_id,
|
17
|
+
:variants
|
18
|
+
|
19
|
+
def initialize(client: required('client'))
|
20
|
+
@client = client
|
21
|
+
@variants = []
|
22
|
+
end
|
23
|
+
|
24
|
+
def payload
|
25
|
+
fail ArgumentError, 'audience is required for experiment' if @audience.nil?
|
26
|
+
fail ArgumentError, 'device_types is required for experiment' if @device_types.nil?
|
27
|
+
fail ArgumentError, 'variant cannot be empty for experiment' if @variants.empty?
|
28
|
+
|
29
|
+
{
|
30
|
+
'name': name,
|
31
|
+
'description': description,
|
32
|
+
'control': control,
|
33
|
+
'audience': audience,
|
34
|
+
'device_types': device_types,
|
35
|
+
'campaigns': campaigns,
|
36
|
+
'variants': variants,
|
37
|
+
'id': id,
|
38
|
+
'created_at': created_at,
|
39
|
+
'push_id': push_id
|
40
|
+
}.delete_if {|key, value| value.nil?} #this removes the nil key value pairs
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'urbanairship'
|
2
|
+
|
3
|
+
module Urbanairship
|
4
|
+
module AbTests
|
5
|
+
class Variant
|
6
|
+
include Urbanairship::Common
|
7
|
+
include Urbanairship::Loggable
|
8
|
+
attr_accessor :description,
|
9
|
+
:id,
|
10
|
+
:name,
|
11
|
+
:push,
|
12
|
+
:schedule,
|
13
|
+
:weight
|
14
|
+
|
15
|
+
def initialize(client: required('client'))
|
16
|
+
@client = client
|
17
|
+
end
|
18
|
+
|
19
|
+
def payload
|
20
|
+
fail ArgumentError, 'a push must be added to create a variant' if @push.nil?
|
21
|
+
|
22
|
+
{
|
23
|
+
'description': description,
|
24
|
+
'id': id,
|
25
|
+
'name': name,
|
26
|
+
'push': push,
|
27
|
+
'schedule': schedule,
|
28
|
+
'weight': weight
|
29
|
+
}.delete_if {|key, value| value.nil?} #this removes the nil key value pairs
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'urbanairship'
|
3
|
+
require 'urbanairship/automations/pipeline'
|
4
|
+
|
5
|
+
module Urbanairship
|
6
|
+
module Automations
|
7
|
+
class Automation
|
8
|
+
include Urbanairship::Common
|
9
|
+
include Urbanairship::Loggable
|
10
|
+
attr_accessor :limit,
|
11
|
+
:enabled,
|
12
|
+
:offset,
|
13
|
+
:start,
|
14
|
+
:pipeline_id,
|
15
|
+
:pipeline_object
|
16
|
+
|
17
|
+
def initialize(client: required('client'))
|
18
|
+
@client = client
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_automation
|
22
|
+
response = @client.send_request(
|
23
|
+
method: 'POST',
|
24
|
+
body: JSON.dump(pipeline_object),
|
25
|
+
url: PIPELINES_URL,
|
26
|
+
content_type: 'application/json'
|
27
|
+
)
|
28
|
+
logger.info("Created Automation")
|
29
|
+
response
|
30
|
+
end
|
31
|
+
|
32
|
+
def list_automations
|
33
|
+
response = @client.send_request(
|
34
|
+
method: 'GET',
|
35
|
+
url: PIPELINES_URL + format_url_with_params
|
36
|
+
)
|
37
|
+
logger.info("Looking up automations for project")
|
38
|
+
response
|
39
|
+
end
|
40
|
+
|
41
|
+
def list_deleted_automations
|
42
|
+
response = @client.send_request(
|
43
|
+
method: 'GET',
|
44
|
+
url: PIPELINES_URL + 'deleted' + format_url_with_params
|
45
|
+
)
|
46
|
+
logger.info("Looking up deleted automations for project")
|
47
|
+
response
|
48
|
+
end
|
49
|
+
|
50
|
+
def validate_automation
|
51
|
+
response = @client.send_request(
|
52
|
+
method: 'POST',
|
53
|
+
body: JSON.dump(pipeline_object),
|
54
|
+
url: PIPELINES_URL + 'validate',
|
55
|
+
content_type: 'application/json'
|
56
|
+
)
|
57
|
+
logger.info("Validating Automation")
|
58
|
+
response
|
59
|
+
end
|
60
|
+
|
61
|
+
def lookup_automation
|
62
|
+
fail ArgumentError, 'pipeline_id must be set to lookup individual automation' if @pipeline_id.nil?
|
63
|
+
response = @client.send_request(
|
64
|
+
method: 'GET',
|
65
|
+
url: PIPELINES_URL + pipeline_id
|
66
|
+
)
|
67
|
+
logger.info("Looking up automation with id #{pipeline_id}")
|
68
|
+
response
|
69
|
+
end
|
70
|
+
|
71
|
+
def update_automation
|
72
|
+
fail ArgumentError, 'pipeline_id must be set to update individual automation' if @pipeline_id.nil?
|
73
|
+
|
74
|
+
response = @client.send_request(
|
75
|
+
method: 'PUT',
|
76
|
+
body: JSON.dump(pipeline_object),
|
77
|
+
url: PIPELINES_URL + pipeline_id,
|
78
|
+
content_type: 'application/json'
|
79
|
+
)
|
80
|
+
logger.info("Validating Automation")
|
81
|
+
response
|
82
|
+
end
|
83
|
+
|
84
|
+
def delete_automation
|
85
|
+
fail ArgumentError, 'pipeline_id must be set to delete individual automation' if @pipeline_id.nil?
|
86
|
+
response = @client.send_request(
|
87
|
+
method: 'DELETE',
|
88
|
+
url: PIPELINES_URL + pipeline_id
|
89
|
+
)
|
90
|
+
logger.info("Deleting automation with id #{pipeline_id}")
|
91
|
+
response
|
92
|
+
end
|
93
|
+
|
94
|
+
def format_url_with_params
|
95
|
+
params = []
|
96
|
+
params << ['limit', limit] if limit
|
97
|
+
params << ['enabled', enabled] if enabled
|
98
|
+
params << ['offset', offset] if offset
|
99
|
+
params << ['start', start] if start
|
100
|
+
query = URI.encode_www_form(params)
|
101
|
+
'?' + query
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'urbanairship'
|
2
|
+
|
3
|
+
module Urbanairship
|
4
|
+
module Automations
|
5
|
+
class Pipeline
|
6
|
+
include Urbanairship::Common
|
7
|
+
include Urbanairship::Loggable
|
8
|
+
attr_accessor :activation_time,
|
9
|
+
:cancellation_trigger,
|
10
|
+
:condition,
|
11
|
+
:constraint,
|
12
|
+
:creation_time,
|
13
|
+
:deactivation_time,
|
14
|
+
:historical_trigger,
|
15
|
+
:immediate_trigger,
|
16
|
+
:last_modified_time,
|
17
|
+
:name,
|
18
|
+
:status,
|
19
|
+
:timing,
|
20
|
+
:url,
|
21
|
+
:enabled,
|
22
|
+
:outcome
|
23
|
+
|
24
|
+
def initialize(client: required('client'))
|
25
|
+
@client = client
|
26
|
+
end
|
27
|
+
|
28
|
+
def payload
|
29
|
+
fail ArgumentError, 'enabled must be set to create pipeline payload' if @enabled.nil?
|
30
|
+
fail ArgumentError, 'outcome must be set to create pipeline payload' if @outcome.nil?
|
31
|
+
{
|
32
|
+
activation_time: activation_time,
|
33
|
+
cancellation_trigger: cancellation_trigger,
|
34
|
+
condition: condition,
|
35
|
+
constraint: constraint,
|
36
|
+
creation_time: creation_time,
|
37
|
+
deactivation_time: deactivation_time,
|
38
|
+
enabled: enabled,
|
39
|
+
historical_trigger: historical_trigger,
|
40
|
+
immediate_trigger: immediate_trigger,
|
41
|
+
last_modified_time: last_modified_time,
|
42
|
+
name: name,
|
43
|
+
outcome: outcome,
|
44
|
+
status: status,
|
45
|
+
timing: timing,
|
46
|
+
url: url
|
47
|
+
}.delete_if {|key, value| value.nil?} #this removes the nil key value pairs
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/urbanairship/common.rb
CHANGED
@@ -20,6 +20,7 @@ module Urbanairship
|
|
20
20
|
FEEDS_URL = BASE_URL + '/feeds/'
|
21
21
|
LOCATION_URL = BASE_URL + '/location/'
|
22
22
|
CREATE_AND_SEND_URL = BASE_URL + '/create-and-send/'
|
23
|
+
EXPERIMENTS_URL = BASE_URL + '/experiments/'
|
23
24
|
|
24
25
|
# Helper method for required keyword args in Ruby 2.0 that is compatible with 2.1+
|
25
26
|
# @example
|
@@ -8,9 +8,17 @@ module Urbanairship
|
|
8
8
|
|
9
9
|
# A Push Notification.
|
10
10
|
class Push
|
11
|
-
attr_writer :client
|
12
|
-
|
13
|
-
|
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:
|
27
|
-
notification:
|
28
|
-
options:
|
29
|
-
device_types:
|
30
|
-
message:
|
31
|
-
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
|
|
data/lib/urbanairship/version.rb
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: 5.
|
4
|
+
version: 5.7.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-
|
11
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -138,6 +138,8 @@ files:
|
|
138
138
|
- bin/console
|
139
139
|
- bin/setup
|
140
140
|
- docs/Makefile
|
141
|
+
- docs/ab_tests.rst
|
142
|
+
- docs/automations.rst
|
141
143
|
- docs/channel_uninstall.rst
|
142
144
|
- docs/conf.py
|
143
145
|
- docs/create_and_send.rst
|
@@ -157,6 +159,11 @@ files:
|
|
157
159
|
- docs/tags.rst
|
158
160
|
- example/pusher.rb
|
159
161
|
- lib/urbanairship.rb
|
162
|
+
- lib/urbanairship/ab_tests/ab_test.rb
|
163
|
+
- lib/urbanairship/ab_tests/experiment.rb
|
164
|
+
- lib/urbanairship/ab_tests/variant.rb
|
165
|
+
- lib/urbanairship/automations/automation.rb
|
166
|
+
- lib/urbanairship/automations/pipeline.rb
|
160
167
|
- lib/urbanairship/client.rb
|
161
168
|
- lib/urbanairship/common.rb
|
162
169
|
- lib/urbanairship/configuration.rb
|
@@ -188,7 +195,7 @@ licenses:
|
|
188
195
|
- Apache-2.0
|
189
196
|
metadata:
|
190
197
|
allowed_push_host: https://rubygems.org
|
191
|
-
post_install_message:
|
198
|
+
post_install_message:
|
192
199
|
rdoc_options: []
|
193
200
|
require_paths:
|
194
201
|
- lib
|
@@ -204,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
211
|
version: '0'
|
205
212
|
requirements: []
|
206
213
|
rubygems_version: 3.0.1
|
207
|
-
signing_key:
|
214
|
+
signing_key:
|
208
215
|
specification_version: 4
|
209
216
|
summary: Ruby Gem for using the Airship API
|
210
217
|
test_files: []
|