urbanairship 5.7.0 → 5.8.0
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/CHANGELOG +6 -0
- data/docs/attributes.rst +52 -0
- data/docs/index.rst +3 -0
- data/docs/push.rst +24 -0
- data/lib/urbanairship.rb +1 -0
- data/lib/urbanairship/devices/attribute.rb +54 -0
- data/lib/urbanairship/devices/devicelist.rb +21 -0
- data/lib/urbanairship/push/schedule.rb +9 -0
- data/lib/urbanairship/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e4a3dfc0a925ebcaf22800eabbc1fec1c8c59f5fd52e26f24ca87ff7eec2d5c
|
|
4
|
+
data.tar.gz: 593f328489aaffcfad92e1da6c9a86351aabee461ab408bf94d66a374bef8625
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5441fa97e0611f195f39d06022e30fa7a32d55a6d8a6052c0d5f366d97a687f6e789e9de9c4ceebe0f6cc192414cf706a24a0b8572bf4d5b914e147acec94c39
|
|
7
|
+
data.tar.gz: ff5234432140b9cabac03ed2df6ef29d5398f6e8ea886d1a161fc31ee0f0c758bbc10647e736597d8524b43b9d34a1be17887af24f9a9376b1d1b75c11dd196c
|
data/CHANGELOG
CHANGED
data/docs/attributes.rst
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Attributes
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
Set Attribute for a Channel
|
|
5
|
+
---------------------------
|
|
6
|
+
|
|
7
|
+
The following will set an attribute for a given channel ID.
|
|
8
|
+
|
|
9
|
+
.. code-block:: ruby
|
|
10
|
+
|
|
11
|
+
require 'urbanairship'
|
|
12
|
+
UA = Urbanairship
|
|
13
|
+
airship = UA::Client.new(key:'app_key', secret:'secret_key')
|
|
14
|
+
channel_info = UA::ChannelInfo.new(client: airship)
|
|
15
|
+
channel_info.audience = {"ios_channel": "b8f9b663-0a3b-cf45-587a-be880946e881"}
|
|
16
|
+
channel_info.attributes = {
|
|
17
|
+
"action": "set",
|
|
18
|
+
"key": "favorite_food",
|
|
19
|
+
"value": "cake"
|
|
20
|
+
}
|
|
21
|
+
channel_info.set_attributes
|
|
22
|
+
|
|
23
|
+
.. note::
|
|
24
|
+
|
|
25
|
+
This should return a 200 response
|
|
26
|
+
|
|
27
|
+
Send Push to Audience with Attribute Specifications
|
|
28
|
+
---------------------------------------------------
|
|
29
|
+
|
|
30
|
+
This will send a push to an audience who meet the specifications of attribute we
|
|
31
|
+
set here. This example is using a text attribute where we are looking for audience
|
|
32
|
+
members whose favorite food includes 'apple'. Some examples of what this could return
|
|
33
|
+
would be 'apple', 'pineapple', or 'apple pie'.
|
|
34
|
+
|
|
35
|
+
.. code-block:: ruby
|
|
36
|
+
|
|
37
|
+
require 'urbanairship'
|
|
38
|
+
UA = Urbanairship
|
|
39
|
+
airship = UA::Client.new(key:'app_key', secret:'secret_key')
|
|
40
|
+
new_attribute = UA::Attribute.new(client: airship)
|
|
41
|
+
new_attribute.attribute = 'favorite_food'
|
|
42
|
+
new_attribute.operator = 'contains'
|
|
43
|
+
new_attribute.value = 'apple'
|
|
44
|
+
push = airship.create_push
|
|
45
|
+
push.audience = new_attribute.payload
|
|
46
|
+
push.notification = UA.notification(alert: 'Hello')
|
|
47
|
+
push.device_types = ['android', 'ios', 'web']
|
|
48
|
+
push.send_push
|
|
49
|
+
|
|
50
|
+
.. note::
|
|
51
|
+
|
|
52
|
+
This should return a 202 response
|
data/docs/index.rst
CHANGED
data/docs/push.rst
CHANGED
|
@@ -507,6 +507,30 @@ local time.
|
|
|
507
507
|
If the schedule is unsuccessful, an :rb:class:`AirshipFailure` exception
|
|
508
508
|
will be raised.
|
|
509
509
|
|
|
510
|
+
Scheduled Delivery for Optimal Send Time
|
|
511
|
+
----------------------------------------
|
|
512
|
+
|
|
513
|
+
Scheduled notifications build upon the Push object, and have two other
|
|
514
|
+
components: the scheduled time(s) and an optional name.
|
|
515
|
+
|
|
516
|
+
This example schedules the above notification delivery for optimal send time.
|
|
517
|
+
|
|
518
|
+
.. code-block:: ruby
|
|
519
|
+
|
|
520
|
+
schedule = airship.create_scheduled_push
|
|
521
|
+
schedule.push = push
|
|
522
|
+
schedule.name = "optional name for later reference"
|
|
523
|
+
schedule.schedule = UA.optimal_scheduled_time('2020-02-20')
|
|
524
|
+
response = schedule.send_push
|
|
525
|
+
print ("Created schedule. url: " + response.schedule_url)
|
|
526
|
+
|
|
527
|
+
If the schedule is unsuccessful, an :rb:class:`AirshipFailure` exception
|
|
528
|
+
will be raised.
|
|
529
|
+
|
|
530
|
+
.. note::
|
|
531
|
+
|
|
532
|
+
Make sure the time for UA.optimal_scheduled_time is a date versus a timestamp.
|
|
533
|
+
|
|
510
534
|
|
|
511
535
|
Updating or Canceling a Schedule
|
|
512
536
|
--------------------------------
|
data/lib/urbanairship.rb
CHANGED
|
@@ -10,6 +10,7 @@ require 'urbanairship/devices/email_notification'
|
|
|
10
10
|
require 'urbanairship/devices/sms_notification'
|
|
11
11
|
require 'urbanairship/devices/mms_notification'
|
|
12
12
|
require 'urbanairship/devices/create_and_send'
|
|
13
|
+
require 'urbanairship/devices/attribute'
|
|
13
14
|
require 'urbanairship/client'
|
|
14
15
|
require 'urbanairship/common'
|
|
15
16
|
require 'urbanairship/configuration'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'urbanairship'
|
|
2
|
+
|
|
3
|
+
module Urbanairship
|
|
4
|
+
module Devices
|
|
5
|
+
class Attribute
|
|
6
|
+
include Urbanairship::Common
|
|
7
|
+
include Urbanairship::Loggable
|
|
8
|
+
attr_accessor :attribute,
|
|
9
|
+
:operator,
|
|
10
|
+
:precision,
|
|
11
|
+
:value
|
|
12
|
+
|
|
13
|
+
def initialize(client: required('client'))
|
|
14
|
+
@client = client
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def payload
|
|
18
|
+
if precision
|
|
19
|
+
date_attribute
|
|
20
|
+
elsif value.is_a? String
|
|
21
|
+
text_attribute
|
|
22
|
+
elsif value.is_a? Integer
|
|
23
|
+
number_attribute
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def number_attribute
|
|
28
|
+
{
|
|
29
|
+
'attribute': attribute,
|
|
30
|
+
'operator': operator,
|
|
31
|
+
'value': value
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def text_attribute
|
|
36
|
+
{
|
|
37
|
+
'attribute': attribute,
|
|
38
|
+
'operator': operator,
|
|
39
|
+
'value': value
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def date_attribute
|
|
44
|
+
{
|
|
45
|
+
'attribute': attribute,
|
|
46
|
+
'operator': operator,
|
|
47
|
+
'precision': precision,
|
|
48
|
+
'value': value
|
|
49
|
+
}
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -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
|
|
@@ -20,6 +22,25 @@ module Urbanairship
|
|
|
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
|
+
url: CHANNEL_URL + 'attributes',
|
|
40
|
+
content_type: 'application/json'
|
|
41
|
+
)
|
|
42
|
+
response
|
|
43
|
+
end
|
|
23
44
|
end
|
|
24
45
|
|
|
25
46
|
class ChannelList < Urbanairship::Common::PageIterator
|
|
@@ -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)
|
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.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Airship
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-10-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|
|
@@ -139,6 +139,7 @@ files:
|
|
|
139
139
|
- bin/setup
|
|
140
140
|
- docs/Makefile
|
|
141
141
|
- docs/ab_tests.rst
|
|
142
|
+
- docs/attributes.rst
|
|
142
143
|
- docs/automations.rst
|
|
143
144
|
- docs/channel_uninstall.rst
|
|
144
145
|
- docs/conf.py
|
|
@@ -167,6 +168,7 @@ files:
|
|
|
167
168
|
- lib/urbanairship/client.rb
|
|
168
169
|
- lib/urbanairship/common.rb
|
|
169
170
|
- lib/urbanairship/configuration.rb
|
|
171
|
+
- lib/urbanairship/devices/attribute.rb
|
|
170
172
|
- lib/urbanairship/devices/channel_tags.rb
|
|
171
173
|
- lib/urbanairship/devices/channel_uninstall.rb
|
|
172
174
|
- lib/urbanairship/devices/create_and_send.rb
|