pwush 0.2.0 → 0.3.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/.circleci/config.yml +13 -13
- data/.gitignore +1 -0
- data/CHANGELOG.md +16 -0
- data/README.md +5 -1
- data/lib/pwush/api/applications.rb +9 -0
- data/lib/pwush/api/devices.rb +41 -0
- data/lib/pwush/api/messages.rb +30 -0
- data/lib/pwush/client.rb +8 -67
- data/lib/pwush/message.rb +81 -96
- data/lib/pwush/response/value.rb +2 -2
- data/lib/pwush/types.rb +1 -1
- data/lib/pwush/version.rb +1 -1
- data/pwush.gemspec +3 -2
- metadata +12 -24
- data/Gemfile.lock +0 -119
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3273bf6a132f726c154ad5fa9141f2b83378cd665a7a22653beb55ebd5afd91
|
4
|
+
data.tar.gz: e5ef888ebfdb4bf8d1fd30bec420c4ffd36635a71f9cba8304d00c5f7680d5b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8f8a3fb2027788d4977dd417877cc09062878f376a428e1312257e4531599c71238e29a23722b487630031bc4114a5dbc9b557666ab331ad2da3715b96cd09a
|
7
|
+
data.tar.gz: 8226de0c179cf7d7247fcd624d5dd380215464f741aa2262b674e6969d4bf12404a8f248330c19ef71637dd71c1921efaa7ff0f37007e4e66a199dad8d722845
|
data/.circleci/config.yml
CHANGED
@@ -8,20 +8,20 @@ defaults: &default_job
|
|
8
8
|
steps:
|
9
9
|
- checkout
|
10
10
|
|
11
|
-
- type: cache-restore
|
12
|
-
|
13
|
-
|
11
|
+
# - type: cache-restore
|
12
|
+
# name: Restore bundle cache
|
13
|
+
# key: pwush-{{ checksum "Gemfile.lock" }}
|
14
14
|
|
15
15
|
- run:
|
16
16
|
name: install dependencies
|
17
17
|
command: |
|
18
18
|
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
19
19
|
|
20
|
-
- type: cache-save
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
# - type: cache-save
|
21
|
+
# name: Store bundle cache
|
22
|
+
# key: pwush-{{ checksum "Gemfile.lock" }}
|
23
|
+
# paths:
|
24
|
+
# - vendor/bundle
|
25
25
|
|
26
26
|
- run:
|
27
27
|
name: Download cc-test-reporter
|
@@ -42,10 +42,6 @@ defaults: &default_job
|
|
42
42
|
./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.json -r ce337e25b76b0c3048abfdb2d5aa6d3e87cc8540d90f0029ef7416683814732e
|
43
43
|
|
44
44
|
jobs:
|
45
|
-
ruby-2.3:
|
46
|
-
<<: *default_job
|
47
|
-
docker:
|
48
|
-
- image: circleci/ruby:2.3-node-browsers
|
49
45
|
ruby-2.4:
|
50
46
|
<<: *default_job
|
51
47
|
docker:
|
@@ -54,11 +50,15 @@ jobs:
|
|
54
50
|
<<: *default_job
|
55
51
|
docker:
|
56
52
|
- image: circleci/ruby:2.5-node-browsers
|
53
|
+
ruby-2.6:
|
54
|
+
<<: *default_job
|
55
|
+
docker:
|
56
|
+
- image: circleci/ruby:2.6-node-browsers
|
57
57
|
|
58
58
|
workflows:
|
59
59
|
version: 2
|
60
60
|
multiple-rubies:
|
61
61
|
jobs:
|
62
|
-
- ruby-2.3
|
63
62
|
- ruby-2.4
|
64
63
|
- ruby-2.5
|
64
|
+
- ruby-2.6
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [0.2.0](https://github.com/iarie/pwush/tree/HEAD)
|
4
|
+
|
5
|
+
**Added:**
|
6
|
+
- Introduce devices api [\#4](https://github.com/iarie/pwush/pull/4) ([iarie](https://github.com/iarie))
|
7
|
+
|
8
|
+
## [0.1.2](https://github.com/iarie/pwush/tree/HEAD)
|
9
|
+
|
10
|
+
**Changed:**
|
11
|
+
- Update dry-rb gems [\#3](https://github.com/iarie/pwush/pull/3)
|
12
|
+
|
13
|
+
## [0.1.1](https://github.com/iarie/pwush/tree/HEAD)
|
14
|
+
|
15
|
+
**Added:**
|
16
|
+
- timeout config options added [\#1](https://github.com/iarie/pwush/pull/1) ([achernik](https://github.com/achernik))
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Pwush is a remote api toolkit for [Pushwoosh](https://www.pushwoosh.com/v1.0/ref
|
|
12
12
|
Add this line to your application's Gemfile:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'pwush', '~> 0.
|
15
|
+
gem 'pwush', '~> 0.2.0'
|
16
16
|
```
|
17
17
|
|
18
18
|
And then execute:
|
@@ -31,6 +31,10 @@ MyPW = Pwush.new(auth: 'AUTH_KEY', app: 'APP_CODE', timeout: { connect: 5, read:
|
|
31
31
|
```
|
32
32
|
### Push message
|
33
33
|
```ruby
|
34
|
+
MyPW.create_message(content: 'Hello, there!')
|
35
|
+
```
|
36
|
+
### Using built-in struct
|
37
|
+
```ruby
|
34
38
|
first_message = Pwush::Message.new(
|
35
39
|
content: { en: 'Hello' },
|
36
40
|
send_date: '2018-04-06 23:00',
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Pwush
|
2
|
+
module Api
|
3
|
+
module Devices
|
4
|
+
def register_device(params)
|
5
|
+
post(:registerDevice, params)
|
6
|
+
end
|
7
|
+
|
8
|
+
def unregister_device(hwid)
|
9
|
+
post(:unregisterDevice, hwid: hwid)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_test_device(params)
|
13
|
+
post(:createTestDevice, params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_test_devices
|
17
|
+
post(:listTestDevices)
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_badge(hwid, badge)
|
21
|
+
post(:setBadge, hwid: hwid, badge: badge)
|
22
|
+
end
|
23
|
+
|
24
|
+
def application_open(hwid)
|
25
|
+
post(:applicationOpen, hwid: hwid)
|
26
|
+
end
|
27
|
+
|
28
|
+
def push_stat(hwid, hash_tag = nil)
|
29
|
+
post(:pushStat, hwid: hwid, hash: hash_tag)
|
30
|
+
end
|
31
|
+
|
32
|
+
def message_delivery_event(hwid, hash_tag = nil)
|
33
|
+
post(:messageDeliveryEvent, hwid: hwid, hash: hash_tag)
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_purchase(hwid, params = {})
|
37
|
+
post(:setPurchase, params.merge(hwid: hwid))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Pwush
|
2
|
+
module Api
|
3
|
+
module Messages
|
4
|
+
def create_message(*messages)
|
5
|
+
post(:createMessage, notifications: messages.flatten)
|
6
|
+
end
|
7
|
+
alias push create_message
|
8
|
+
|
9
|
+
def delete_message(message_code)
|
10
|
+
post(:deleteMessage, message: message_code)
|
11
|
+
end
|
12
|
+
|
13
|
+
def message_details(message)
|
14
|
+
post(:getMessageDetails, message: message)
|
15
|
+
end
|
16
|
+
|
17
|
+
def message_stats(message)
|
18
|
+
post(:getMsgStats, message: message)
|
19
|
+
end
|
20
|
+
|
21
|
+
def results(request_id)
|
22
|
+
post(:getResults, request_id: request_id)
|
23
|
+
end
|
24
|
+
|
25
|
+
def preset(preset_code)
|
26
|
+
post(:getPreset, preset_code: preset_code)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/pwush/client.rb
CHANGED
@@ -1,78 +1,19 @@
|
|
1
1
|
require 'http'
|
2
2
|
|
3
|
+
require 'pwush/api/messages'
|
4
|
+
require 'pwush/api/devices'
|
5
|
+
require 'pwush/api/applications'
|
6
|
+
|
3
7
|
module Pwush
|
4
8
|
class Client
|
9
|
+
include Api::Messages
|
10
|
+
include Api::Devices
|
11
|
+
include Api::Applications
|
12
|
+
|
5
13
|
def initialize(options)
|
6
14
|
@config = Config.new(options)
|
7
15
|
end
|
8
16
|
|
9
|
-
def create_message(*messages)
|
10
|
-
post(:createMessage, notifications: messages.flatten)
|
11
|
-
end
|
12
|
-
alias push create_message
|
13
|
-
|
14
|
-
def message_details(message)
|
15
|
-
post(:getMessageDetails, message: message)
|
16
|
-
end
|
17
|
-
|
18
|
-
# enterprise api
|
19
|
-
def message_stats(message)
|
20
|
-
post(:getMsgStats, message: message)
|
21
|
-
end
|
22
|
-
|
23
|
-
# enterprise api
|
24
|
-
def results(request_id)
|
25
|
-
post(:getResults, request_id: request_id)
|
26
|
-
end
|
27
|
-
|
28
|
-
# enterprise api
|
29
|
-
def applications
|
30
|
-
post(:getApplications)
|
31
|
-
end
|
32
|
-
|
33
|
-
# enterprise api
|
34
|
-
def preset(preset_code)
|
35
|
-
post(:getPreset, preset_code: preset_code)
|
36
|
-
end
|
37
|
-
|
38
|
-
### DEVICE API
|
39
|
-
|
40
|
-
def register_device(params)
|
41
|
-
post(:registerDevice, params)
|
42
|
-
end
|
43
|
-
|
44
|
-
def unregister_device(hwid)
|
45
|
-
post(:unregisterDevice, hwid: hwid)
|
46
|
-
end
|
47
|
-
|
48
|
-
def create_test_device(params)
|
49
|
-
post(:createTestDevice, params)
|
50
|
-
end
|
51
|
-
|
52
|
-
def list_test_devices
|
53
|
-
post(:listTestDevices)
|
54
|
-
end
|
55
|
-
|
56
|
-
def set_badge(hwid, badge)
|
57
|
-
post(:setBadge, hwid: hwid, badge: badge)
|
58
|
-
end
|
59
|
-
|
60
|
-
def application_open(hwid)
|
61
|
-
post(:applicationOpen, hwid: hwid)
|
62
|
-
end
|
63
|
-
|
64
|
-
def push_stat(hwid, hash_tag = nil)
|
65
|
-
post(:pushStat, hwid: hwid, hash: hash_tag)
|
66
|
-
end
|
67
|
-
|
68
|
-
def message_delivery_event(hwid, hash_tag = nil)
|
69
|
-
post(:messageDeliveryEvent, hwid: hwid, hash: hash_tag)
|
70
|
-
end
|
71
|
-
|
72
|
-
def set_purchase(hwid, params = {})
|
73
|
-
post(:setPurchase, params.merge(hwid: hwid))
|
74
|
-
end
|
75
|
-
|
76
17
|
private
|
77
18
|
|
78
19
|
def get(action, payload = nil)
|
data/lib/pwush/message.rb
CHANGED
@@ -6,17 +6,17 @@ module Pwush
|
|
6
6
|
# https://www.pushwoosh.com/v1.0/reference#createmessage
|
7
7
|
|
8
8
|
# YYYY-MM-DD HH:mm OR 'now'
|
9
|
-
attribute :send_date, Types::Strict::String.default('now')
|
9
|
+
attribute :send_date, Types::Strict::String.default('now').freeze
|
10
10
|
|
11
11
|
attribute :ignore_user_timezone, Types::Strict::Bool.default(true)
|
12
12
|
|
13
13
|
# "timezone":"America/New_York", optional, if ignored UTC-0 is default in "send_date".
|
14
14
|
# See http://php.net/manual/timezones.php for supported timezones
|
15
|
-
attribute :timezone, Types::Strict::String
|
15
|
+
attribute? :timezone, Types::Strict::String
|
16
16
|
|
17
17
|
# "campaign":"CAMPAIGN_CODE", optional.
|
18
18
|
# Campaign code to which you want to assign this push message
|
19
|
-
attribute :campaign, Types::Strict::String
|
19
|
+
attribute? :campaign, Types::Strict::String
|
20
20
|
|
21
21
|
# "content":{
|
22
22
|
# "en":"English",
|
@@ -26,96 +26,90 @@ module Pwush
|
|
26
26
|
attribute :content, Types::Strict::String | Types::Hash
|
27
27
|
|
28
28
|
# "page_id": 39, optional. HTML Pages. integer
|
29
|
-
attribute :page_id, Types::Strict::Integer
|
29
|
+
attribute? :page_id, Types::Strict::Integer
|
30
30
|
|
31
31
|
# "rich_page_id": 42, optional. Rich Pages. integer
|
32
|
-
attribute :rich_page_id, Types::Strict::Integer
|
32
|
+
attribute? :rich_page_id, Types::Strict::Integer
|
33
33
|
|
34
34
|
# "rich_media": "XXXX-XXXX", optional. Rich Media code. string
|
35
|
-
attribute :rich_media, Types::Strict::String
|
35
|
+
attribute? :rich_media, Types::Strict::String
|
36
36
|
|
37
37
|
# "remote_page" : "http://myremoteurl.com",
|
38
38
|
# Remote Rich HTML Page URL. <scheme>://<authority>
|
39
|
-
attribute :remote_page, Types::Strict::String
|
39
|
+
attribute? :remote_page, Types::Strict::String
|
40
40
|
|
41
41
|
# "link": "http://google.com", optional, string.
|
42
42
|
# For deeplinks add "minimize_link":0
|
43
|
-
attribute :link, Types::Strict::String
|
43
|
+
attribute? :link, Types::Strict::String
|
44
44
|
|
45
45
|
# "minimize_link": 0, optional.
|
46
46
|
# False or 0 - do not minimize, 1 - Google, 2 - bitly. Default = 1
|
47
|
-
attribute :minimize_link, Types::Strict::Integer.constrained(included_in: 0..2)
|
48
|
-
.meta(omittable: true)
|
47
|
+
attribute? :minimize_link, Types::Strict::Integer.constrained(included_in: 0..2)
|
49
48
|
|
50
49
|
# "data": {"key":"value"}, JSON string or JSON object,
|
51
50
|
# will be passed as "u" parameter in the payload (converted to JSON string)
|
52
|
-
attribute :data,
|
51
|
+
attribute? :data, Types::Strict::String | Types::Hash
|
53
52
|
|
54
53
|
# 1 - iOS; 2 - BB; 3 - Android; 5 - Windows Phone; 7 - OS X; 8 - Windows 8;
|
55
54
|
# 9 - Amazon; 10 - Safari; 11 - Chrome; 12 - Firefox;
|
56
55
|
# ignored if "devices" < 10
|
57
56
|
Platforms = Types::Strict::Integer.enum(1, 2, 3, 5, 7, 8, 9, 10, 11, 12)
|
58
|
-
attribute :platforms, Types::Strict::Array.of(Platforms)
|
57
|
+
attribute? :platforms, Types::Strict::Array.of(Platforms)
|
59
58
|
|
60
59
|
# "preset":"Q1A2Z-6X8SW", Push Preset Code from your Control Panel
|
61
|
-
attribute :preset, Types::Strict::String
|
60
|
+
attribute? :preset, Types::Strict::String
|
62
61
|
|
63
62
|
# "send_rate": 100, throttling. Valid values are from 100 to 1000 pushes/second.
|
64
|
-
attribute :send_rate, Types::Strict::Integer.constrained(included_in: 100..1000)
|
65
|
-
.meta(omittable: true)
|
63
|
+
attribute? :send_rate, Types::Strict::Integer.constrained(included_in: 100..1000)
|
66
64
|
|
67
65
|
# Optional. Specify tokens or hwids to send targeted push notifications.
|
68
66
|
# Not more than 1000 tokens/hwids in an array.
|
69
67
|
# If set, the message will only be sent to the devices on the list.
|
70
68
|
# Ignored if the Applications Group is used. iOS push tokens can only be lower case.
|
71
|
-
attribute :devices, Types::Strict::Array.of(Types::Strict::String)
|
72
|
-
.meta(omittable: true)
|
69
|
+
attribute? :devices, Types::Strict::Array.of(Types::Strict::String)
|
73
70
|
|
74
71
|
# "users":["user_3078a"], optional.
|
75
72
|
# If set, message will only be delivered to the specified users Id's
|
76
73
|
# (specified via /registerUser call).
|
77
74
|
# If specified together with devices parameter, the latter will be ignored.
|
78
|
-
attribute :users, Types::Strict::Array.of(Types::Strict::String)
|
79
|
-
.meta(omittable: true)
|
75
|
+
attribute? :users, Types::Strict::Array.of(Types::Strict::String)
|
80
76
|
|
81
77
|
# "filter": "FILTER_NAME", optional.
|
82
|
-
attribute :filter, Types::Strict::String
|
78
|
+
attribute? :filter, Types::Strict::String
|
83
79
|
|
84
80
|
# optional, placeholders for dynamic content instead of device tags
|
85
81
|
# "dynamic_content_placeholders" :{
|
86
82
|
# "firstname":"John",
|
87
83
|
# "lastname":"Doe"
|
88
84
|
# },
|
89
|
-
attribute :dynamic_content_placeholders, Types::Hash
|
85
|
+
attribute? :dynamic_content_placeholders, Types::Hash
|
90
86
|
|
91
87
|
# "conditions": [TAG_CONDITION1, TAG_CONDITION2, ..., TAG_CONDITIONN],
|
92
88
|
# Optional.
|
93
|
-
attribute :conditions, Types::Strict::Array.of(Types::Strict::String)
|
94
|
-
.meta(omittable: true)
|
89
|
+
attribute? :conditions, Types::Strict::Array.of(Types::Strict::String)
|
95
90
|
|
96
91
|
# iOS related
|
97
92
|
|
98
93
|
# "ios_badges": 5, optional, integer.
|
99
94
|
# iOS application badge number.
|
100
95
|
# Use "+n" or "-n" to increment/decrement the badge value by n
|
101
|
-
attribute :ios_badges, Types::Strict::Integer
|
96
|
+
attribute? :ios_badges, Types::Strict::Integer
|
102
97
|
|
103
98
|
# "ios_sound": "sound file.wav", optional.
|
104
99
|
# Sound file name in the main bundle of application.
|
105
100
|
# If left empty, the device will produce no sound upon receiving a push
|
106
|
-
attribute :ios_sound, Types::Strict::String
|
101
|
+
attribute? :ios_sound, Types::Strict::String
|
107
102
|
|
108
103
|
# "ios_ttl": 3600, optional.
|
109
104
|
# Time to live parameter - maximum message lifespan in seconds
|
110
|
-
attribute :ios_ttl, Types::Strict::Integer
|
105
|
+
attribute? :ios_ttl, Types::Strict::Integer
|
111
106
|
|
112
107
|
# "ios_silent": 1, optional.
|
113
108
|
# Enable silent notifications (ignore "sound" and "content")
|
114
|
-
attribute :ios_silent, Types::Strict::Integer.constrained(included_in: 0..1)
|
115
|
-
.meta(omittable: true)
|
109
|
+
attribute? :ios_silent, Types::Strict::Integer.constrained(included_in: 0..1)
|
116
110
|
|
117
111
|
# iOS8 category ID from Pushwoosh
|
118
|
-
attribute :ios_category_id, Types::Strict::Integer
|
112
|
+
attribute? :ios_category_id, Types::Strict::Integer
|
119
113
|
|
120
114
|
# Optional - root level parameters to the aps dictionary
|
121
115
|
# "ios_root_params" : {
|
@@ -126,121 +120,118 @@ module Pwush
|
|
126
120
|
# "attachment":"YOUR_ATTACHMENT_URL", // iOS 10 media attachment URL
|
127
121
|
# "data": << User supplied data, max of 4KB>>
|
128
122
|
# },
|
129
|
-
attribute :ios_root_params, Types::Hash
|
123
|
+
attribute? :ios_root_params, Types::Hash
|
130
124
|
|
131
125
|
# "apns_trim_content":1, optional. (0|1)
|
132
126
|
# Trims the exceeding content strings with ellipsis
|
133
|
-
attribute :apns_trim_content, Types::Strict::Integer.constrained(included_in: 0..1)
|
134
|
-
.meta(omittable: true)
|
127
|
+
attribute? :apns_trim_content, Types::Strict::Integer.constrained(included_in: 0..1)
|
135
128
|
|
136
129
|
# "ios_title":"Title", optional. Add Title for push notification
|
137
|
-
attribute :ios_title, Types::Strict::String
|
130
|
+
attribute? :ios_title, Types::Strict::String
|
138
131
|
|
139
132
|
# "ios_subtitle" : "SubTitle", //Optional. Added sub-title for push notification
|
140
|
-
attribute :ios_subtitle, Types::Strict::String
|
133
|
+
attribute? :ios_subtitle, Types::Strict::String
|
141
134
|
|
142
135
|
# Android related
|
143
136
|
|
144
137
|
# "android_root_params": {"key": "value"}
|
145
138
|
# custom key-value object. root level parameters for the android payload recipients
|
146
|
-
attribute :android_root_params, Types::Hash
|
139
|
+
attribute? :android_root_params, Types::Hash
|
147
140
|
|
148
141
|
# "android_sound" : "soundfile", optional. No file extension.
|
149
142
|
# If left empty, the device will produce no sound upon receiving a push
|
150
|
-
attribute :android_sound, Types::Strict::String
|
143
|
+
attribute? :android_sound, Types::Strict::String
|
151
144
|
|
152
145
|
# "android_header":"header", optional. Android notification header
|
153
|
-
attribute :android_header, Types::Strict::String
|
146
|
+
attribute? :android_header, Types::Strict::String
|
154
147
|
|
155
148
|
# "android_icon": "icon",
|
156
|
-
attribute :android_icon, Types::Strict::String
|
149
|
+
attribute? :android_icon, Types::Strict::String
|
157
150
|
|
158
151
|
# "android_custom_icon": "http://example.com/image.png", optional.
|
159
152
|
# Full path URL to the image file
|
160
|
-
attribute :android_custom_icon, Types::Strict::String
|
153
|
+
attribute? :android_custom_icon, Types::Strict::String
|
161
154
|
|
162
155
|
# "android_banner": "http://example.com/banner.png", optional.
|
163
156
|
# Full path URL to the image file
|
164
|
-
attribute :android_banner, Types::Strict::String
|
157
|
+
attribute? :android_banner, Types::Strict::String
|
165
158
|
|
166
159
|
# "android_badges": 5, optional, integer.
|
167
160
|
# Android application icon badge number.
|
168
161
|
# Use "+n" or "-n" to increment/decrement the badge value by n
|
169
|
-
attribute :android_badges, Types::Strict::Integer
|
162
|
+
attribute? :android_badges, Types::Strict::Integer
|
170
163
|
|
171
164
|
# "android_gcm_ttl": 3600, optional.
|
172
165
|
# Time to live parameter - maximum message lifespan in seconds
|
173
|
-
attribute :android_gcm_ttl, Types::Strict::Integer
|
166
|
+
attribute? :android_gcm_ttl, Types::Strict::Integer
|
174
167
|
|
175
168
|
# "android_vibration": 0, Android force-vibration for high-priority pushes, boolean
|
176
|
-
attribute :android_vibration, Types::Strict::Bool
|
169
|
+
attribute? :android_vibration, Types::Strict::Bool
|
177
170
|
|
178
171
|
# "android_led":"#rrggbb", LED hex color, device will do its best approximation
|
179
|
-
attribute :android_led, Types::Strict::String
|
172
|
+
attribute? :android_led, Types::Strict::String
|
180
173
|
|
181
174
|
# "android_priority":-1, priority of the push in the Android push drawer.
|
182
175
|
# Valid values are -2, -1, 0, 1 and 2
|
183
|
-
attribute :android_priority, Types::Strict::Integer.constrained(included_in: -2..2)
|
184
|
-
.meta(omittable: true)
|
176
|
+
attribute? :android_priority, Types::Strict::Integer.constrained(included_in: -2..2)
|
185
177
|
|
186
178
|
# "android_ibc":"#RRGGBB", icon background color on Lollipop,
|
187
179
|
# #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
|
188
|
-
attribute :android_ibc, Types::Strict::String
|
180
|
+
attribute? :android_ibc, Types::Strict::String
|
189
181
|
|
190
182
|
# "android_silent": 1, optional. 0 or 1
|
191
183
|
# Enable silent notificaiton (ignore sound and content)
|
192
|
-
attribute :android_silent, Types::Strict::Integer.constrained(included_in: 0..1)
|
193
|
-
.meta(omittable: true)
|
184
|
+
attribute? :android_silent, Types::Strict::Integer.constrained(included_in: 0..1)
|
194
185
|
|
195
186
|
# Amazon related
|
196
187
|
|
197
188
|
# "adm_root_params": {"key": "value"}, // custom key-value object
|
198
|
-
attribute :adm_root_params, Types::Hash
|
189
|
+
attribute? :adm_root_params, Types::Hash
|
199
190
|
# "adm_sound": "push.mp3",
|
200
|
-
attribute :adm_sound, Types::Strict::String
|
191
|
+
attribute? :adm_sound, Types::Strict::String
|
201
192
|
# "adm_header": "Header",
|
202
|
-
attribute :adm_header, Types::Strict::String
|
193
|
+
attribute? :adm_header, Types::Strict::String
|
203
194
|
# "adm_icon": "icon",
|
204
|
-
attribute :adm_icon, Types::Strict::String
|
195
|
+
attribute? :adm_icon, Types::Strict::String
|
205
196
|
# "adm_custom_icon": "http://example.com/image.png",
|
206
|
-
attribute :adm_custom_icon, Types::Strict::String
|
197
|
+
attribute? :adm_custom_icon, Types::Strict::String
|
207
198
|
# "adm_banner": "http://example.com/banner.png",
|
208
|
-
attribute :adm_banner, Types::Strict::String
|
199
|
+
attribute? :adm_banner, Types::Strict::String
|
209
200
|
# "adm_ttl": 3600, optional. Time to live parameter - the maximum message lifespan in seconds
|
210
|
-
attribute :adm_ttl, Types::Strict::Integer
|
201
|
+
attribute? :adm_ttl, Types::Strict::Integer
|
211
202
|
# "adm_priority":-1, priority of the push in Amazon push drawer, valid values are -2, -1, 0, 1 and 2
|
212
|
-
attribute :adm_priority, Types::Strict::Integer.
|
203
|
+
attribute? :adm_priority, Types::Strict::Integer.constrained(included_in: -2..2)
|
213
204
|
|
214
205
|
# Windows Phone related
|
215
206
|
|
216
207
|
# Windows Phone notification type. 'Tile' or 'Toast'. Raw notifications are not supported. 'Tile' if default
|
217
|
-
attribute :wp_type, Types::Strict::String
|
208
|
+
attribute? :wp_type, Types::Strict::String
|
218
209
|
# tile image
|
219
|
-
attribute :wp_background, Types::Strict::String
|
210
|
+
attribute? :wp_background, Types::Strict::String
|
220
211
|
# back tile image
|
221
|
-
attribute :wp_backbackground, Types::Strict::String
|
212
|
+
attribute? :wp_backbackground, Types::Strict::String
|
222
213
|
# back tile title
|
223
|
-
attribute :wp_backtitle, Types::Strict::String
|
214
|
+
attribute? :wp_backtitle, Types::Strict::String
|
224
215
|
# back tile content
|
225
|
-
attribute :wp_backcontent, Types::Strict::String
|
216
|
+
attribute? :wp_backcontent, Types::Strict::String
|
226
217
|
# Badge for Windows Phone notification
|
227
|
-
attribute :wp_count, Types::Strict::Integer
|
218
|
+
attribute? :wp_count, Types::Strict::Integer
|
228
219
|
|
229
220
|
# BlackBerry related
|
230
221
|
|
231
222
|
# BlackBerry header, applicable to BB10 Series devices
|
232
|
-
attribute :blackberry_header, Types::Strict::String
|
223
|
+
attribute? :blackberry_header, Types::Strict::String
|
233
224
|
|
234
225
|
# Mac OS X related
|
235
226
|
|
236
227
|
# "mac_badges": 3,
|
237
|
-
attribute :mac_badges, Types::Strict::Integer
|
228
|
+
attribute? :mac_badges, Types::Strict::Integer
|
238
229
|
# "mac_sound": "sound.caf",
|
239
|
-
attribute :mac_sound, Types::Strict::String
|
230
|
+
attribute? :mac_sound, Types::Strict::String
|
240
231
|
# "mac_root_params": {"content-available":1},
|
241
|
-
attribute :mac_root_params, Types::Hash
|
232
|
+
attribute? :mac_root_params, Types::Hash
|
242
233
|
# Time to live parameter — maximum message lifespan in seconds
|
243
|
-
attribute :mac_ttl, Types::Strict::Integer
|
234
|
+
attribute? :mac_ttl, Types::Strict::Integer
|
244
235
|
|
245
236
|
# WNS related
|
246
237
|
|
@@ -248,79 +239,73 @@ module Pwush
|
|
248
239
|
# "en": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==",
|
249
240
|
# "de": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4="
|
250
241
|
# },
|
251
|
-
attribute :wns_content, Types::Hash
|
242
|
+
attribute? :wns_content, Types::Hash
|
252
243
|
# 'Tile' | 'Toast' | 'Badge' | 'Raw'
|
253
|
-
attribute :wns_type, Types::Strict::String
|
244
|
+
attribute? :wns_type, Types::Strict::String
|
254
245
|
# optional. Used in Tile replacement policy. An alphanumeric string of no more than 16 characters.
|
255
|
-
attribute :wns_tag, Types::Strict::String
|
246
|
+
attribute? :wns_tag, Types::Strict::String
|
256
247
|
# optional. (1|0) Translates into X-WNS-Cache-Policy value
|
257
|
-
attribute :wns_cache, Types::Strict::Integer
|
248
|
+
attribute? :wns_cache, Types::Strict::Integer
|
258
249
|
# optional. Expiration time for notification in seconds
|
259
|
-
attribute :wns_ttl, Types::Strict::Integer
|
250
|
+
attribute? :wns_ttl, Types::Strict::Integer
|
260
251
|
|
261
252
|
# Safari related
|
262
253
|
|
263
254
|
# obligatory, title of the notification
|
264
|
-
attribute :safari_title, Types::Strict::String
|
255
|
+
attribute? :safari_title, Types::Strict::String
|
265
256
|
|
266
257
|
# "safari_action": "Click here", // optional
|
267
|
-
attribute :safari_action, Types::Strict::String
|
258
|
+
attribute? :safari_action, Types::Strict::String
|
268
259
|
|
269
260
|
# "safari_url_args": ["firstArgument", "secondArgument"],
|
270
261
|
# Obligatory, but the value may be empty
|
271
|
-
attribute :safari_url_args, Types::Strict::Array.of(Types::Strict::String)
|
272
|
-
.meta(omittable: true)
|
262
|
+
attribute? :safari_url_args, Types::Strict::Array.of(Types::Strict::String)
|
273
263
|
|
274
264
|
# Optional. Time to live parameter - the maximum lifespan of a message in seconds
|
275
|
-
attribute :safari_ttl, Types::Strict::Integer.constrained(min_size: 0)
|
276
|
-
.meta(omittable: true)
|
265
|
+
attribute? :safari_ttl, Types::Strict::Integer.constrained(min_size: 0)
|
277
266
|
|
278
267
|
# Chrome related
|
279
268
|
|
280
269
|
# You can specify the header of the message in this parameter
|
281
|
-
attribute :chrome_title, Types::Strict::String
|
270
|
+
attribute? :chrome_title, Types::Strict::String
|
282
271
|
|
283
272
|
# "chrome_icon":"", full path URL to the icon or extension resources file path
|
284
|
-
attribute :chrome_icon, Types::Strict::String
|
273
|
+
attribute? :chrome_icon, Types::Strict::String
|
285
274
|
|
286
275
|
# Time to live parameter - maximum message lifespan in seconds
|
287
|
-
attribute :chrome_gcm_ttl, Types::Strict::Integer
|
276
|
+
attribute? :chrome_gcm_ttl, Types::Strict::Integer
|
288
277
|
|
289
278
|
# optional, changes chrome push display time.
|
290
279
|
# Set to 0 to display push until user interacts with it
|
291
|
-
attribute :chrome_duration, Types::Strict::Integer
|
280
|
+
attribute? :chrome_duration, Types::Strict::Integer
|
292
281
|
|
293
282
|
# optional, URL to large image.
|
294
|
-
attribute :chrome_image, Types::Strict::String
|
283
|
+
attribute? :chrome_image, Types::Strict::String
|
295
284
|
|
296
|
-
attribute :chrome_button_text1, Types::Strict::String
|
285
|
+
attribute? :chrome_button_text1, Types::Strict::String
|
297
286
|
|
298
287
|
# ignored if chrome_button_text1 is not set
|
299
|
-
attribute :chrome_button_url1, Types::Strict::String
|
288
|
+
attribute? :chrome_button_url1, Types::Strict::String
|
300
289
|
|
301
|
-
attribute :chrome_button_text2, Types::Strict::String
|
290
|
+
attribute? :chrome_button_text2, Types::Strict::String
|
302
291
|
|
303
292
|
# ignored if chrome_button_text2 is not set
|
304
|
-
attribute :chrome_button_url2, Types::Strict::String
|
293
|
+
attribute? :chrome_button_url2, Types::Strict::String
|
305
294
|
|
306
295
|
# Firefox-related
|
307
296
|
|
308
297
|
# optional. You can specify message header here
|
309
|
-
attribute :firefox_title, Types::Strict::String
|
298
|
+
attribute? :firefox_title, Types::Strict::String
|
310
299
|
|
311
300
|
# full path URL to the icon or path to the file in extension resources
|
312
|
-
attribute :firefox_icon, Types::Strict::String
|
313
|
-
|
314
|
-
def defined_attributes
|
315
|
-
__attributes__.reject { |_, v| v.nil? }
|
316
|
-
end
|
301
|
+
attribute? :firefox_icon, Types::Strict::String
|
317
302
|
|
318
303
|
def to_json(options = nil)
|
319
|
-
|
304
|
+
attributes.to_json(options)
|
320
305
|
end
|
321
306
|
|
322
307
|
def inspect
|
323
|
-
attrs =
|
308
|
+
attrs = attributes.map { |k, v| " #{k}=#{v.inspect}" }.join
|
324
309
|
"#<#{self.class}#{attrs}>"
|
325
310
|
end
|
326
311
|
end
|
data/lib/pwush/response/value.rb
CHANGED
@@ -2,8 +2,8 @@ module Pwush
|
|
2
2
|
module Response
|
3
3
|
class Value < Dry::Struct::Value
|
4
4
|
attribute :status_code, Types::Coercible::Integer
|
5
|
-
attribute :status_message, Types::Strict::String
|
6
|
-
attribute :body, (Types::Hash | Types::String).
|
5
|
+
attribute? :status_message, Types::Strict::String
|
6
|
+
attribute? :body, (Types::Hash | Types::String).optional
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
data/lib/pwush/types.rb
CHANGED
data/lib/pwush/version.rb
CHANGED
data/pwush.gemspec
CHANGED
@@ -20,9 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
+
spec.required_ruby_version = '>= 2.4.0'
|
24
|
+
|
23
25
|
spec.add_dependency 'dry-monads', '~> 1.0'
|
24
|
-
spec.add_dependency 'dry-struct', '
|
25
|
-
spec.add_dependency 'dry-types', '<= 0.13.2'
|
26
|
+
spec.add_dependency 'dry-struct', '~> 1.0'
|
26
27
|
spec.add_dependency 'http', '~> 3.0'
|
27
28
|
spec.add_dependency 'oj', '~> 3'
|
28
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Litvinov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-monads
|
@@ -28,30 +28,16 @@ dependencies:
|
|
28
28
|
name: dry-struct
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.5.1
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "<="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.5.1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: dry-types
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "<="
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
33
|
+
version: '1.0'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - "
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
40
|
+
version: '1.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: http
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,15 +176,18 @@ files:
|
|
190
176
|
- ".circleci/config.yml"
|
191
177
|
- ".gitignore"
|
192
178
|
- ".rspec"
|
179
|
+
- CHANGELOG.md
|
193
180
|
- CODE_OF_CONDUCT.md
|
194
181
|
- Gemfile
|
195
|
-
- Gemfile.lock
|
196
182
|
- LICENSE.txt
|
197
183
|
- README.md
|
198
184
|
- Rakefile
|
199
185
|
- bin/console
|
200
186
|
- bin/setup
|
201
187
|
- lib/pwush.rb
|
188
|
+
- lib/pwush/api/applications.rb
|
189
|
+
- lib/pwush/api/devices.rb
|
190
|
+
- lib/pwush/api/messages.rb
|
202
191
|
- lib/pwush/client.rb
|
203
192
|
- lib/pwush/config.rb
|
204
193
|
- lib/pwush/message.rb
|
@@ -221,15 +210,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
210
|
requirements:
|
222
211
|
- - ">="
|
223
212
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
213
|
+
version: 2.4.0
|
225
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
215
|
requirements:
|
227
216
|
- - ">="
|
228
217
|
- !ruby/object:Gem::Version
|
229
218
|
version: '0'
|
230
219
|
requirements: []
|
231
|
-
|
232
|
-
rubygems_version: 2.7.6
|
220
|
+
rubygems_version: 3.0.2
|
233
221
|
signing_key:
|
234
222
|
specification_version: 4
|
235
223
|
summary: Pushwoosh remote API ruby toolkit
|
data/Gemfile.lock
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
pwush (0.1.4)
|
5
|
-
dry-monads (~> 1.0)
|
6
|
-
dry-struct (<= 0.5.1)
|
7
|
-
dry-types (<= 0.13.2)
|
8
|
-
http (~> 3.0)
|
9
|
-
oj (~> 3)
|
10
|
-
|
11
|
-
GEM
|
12
|
-
remote: https://rubygems.org/
|
13
|
-
specs:
|
14
|
-
addressable (2.5.2)
|
15
|
-
public_suffix (>= 2.0.2, < 4.0)
|
16
|
-
byebug (10.0.2)
|
17
|
-
coderay (1.1.2)
|
18
|
-
concurrent-ruby (1.0.5)
|
19
|
-
crack (0.4.3)
|
20
|
-
safe_yaml (~> 1.0.0)
|
21
|
-
diff-lcs (1.3)
|
22
|
-
docile (1.3.0)
|
23
|
-
domain_name (0.5.20180417)
|
24
|
-
unf (>= 0.0.5, < 1.0.0)
|
25
|
-
dry-configurable (0.7.0)
|
26
|
-
concurrent-ruby (~> 1.0)
|
27
|
-
dry-container (0.6.0)
|
28
|
-
concurrent-ruby (~> 1.0)
|
29
|
-
dry-configurable (~> 0.1, >= 0.1.3)
|
30
|
-
dry-core (0.4.7)
|
31
|
-
concurrent-ruby (~> 1.0)
|
32
|
-
dry-equalizer (0.2.1)
|
33
|
-
dry-inflector (0.1.2)
|
34
|
-
dry-logic (0.4.2)
|
35
|
-
dry-container (~> 0.2, >= 0.2.6)
|
36
|
-
dry-core (~> 0.2)
|
37
|
-
dry-equalizer (~> 0.2)
|
38
|
-
dry-monads (1.0.1)
|
39
|
-
concurrent-ruby (~> 1.0)
|
40
|
-
dry-core (~> 0.4, >= 0.4.4)
|
41
|
-
dry-equalizer
|
42
|
-
dry-struct (0.5.1)
|
43
|
-
dry-core (~> 0.4, >= 0.4.3)
|
44
|
-
dry-equalizer (~> 0.2)
|
45
|
-
dry-types (~> 0.13)
|
46
|
-
ice_nine (~> 0.11)
|
47
|
-
dry-types (0.13.2)
|
48
|
-
concurrent-ruby (~> 1.0)
|
49
|
-
dry-container (~> 0.3)
|
50
|
-
dry-core (~> 0.4, >= 0.4.4)
|
51
|
-
dry-equalizer (~> 0.2)
|
52
|
-
dry-inflector (~> 0.1, >= 0.1.2)
|
53
|
-
dry-logic (~> 0.4, >= 0.4.2)
|
54
|
-
hashdiff (0.3.7)
|
55
|
-
http (3.3.0)
|
56
|
-
addressable (~> 2.3)
|
57
|
-
http-cookie (~> 1.0)
|
58
|
-
http-form_data (~> 2.0)
|
59
|
-
http_parser.rb (~> 0.6.0)
|
60
|
-
http-cookie (1.0.3)
|
61
|
-
domain_name (~> 0.5)
|
62
|
-
http-form_data (2.1.1)
|
63
|
-
http_parser.rb (0.6.0)
|
64
|
-
ice_nine (0.11.2)
|
65
|
-
json (2.1.0)
|
66
|
-
method_source (0.9.0)
|
67
|
-
oj (3.6.8)
|
68
|
-
pry (0.11.3)
|
69
|
-
coderay (~> 1.1.0)
|
70
|
-
method_source (~> 0.9.0)
|
71
|
-
pry-byebug (3.6.0)
|
72
|
-
byebug (~> 10.0)
|
73
|
-
pry (~> 0.10)
|
74
|
-
public_suffix (3.0.2)
|
75
|
-
rake (10.5.0)
|
76
|
-
rspec (3.7.0)
|
77
|
-
rspec-core (~> 3.7.0)
|
78
|
-
rspec-expectations (~> 3.7.0)
|
79
|
-
rspec-mocks (~> 3.7.0)
|
80
|
-
rspec-core (3.7.1)
|
81
|
-
rspec-support (~> 3.7.0)
|
82
|
-
rspec-expectations (3.7.0)
|
83
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
-
rspec-support (~> 3.7.0)
|
85
|
-
rspec-mocks (3.7.0)
|
86
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
-
rspec-support (~> 3.7.0)
|
88
|
-
rspec-support (3.7.1)
|
89
|
-
rspec_junit_formatter (0.3.0)
|
90
|
-
rspec-core (>= 2, < 4, != 2.12.0)
|
91
|
-
safe_yaml (1.0.4)
|
92
|
-
simplecov (0.16.1)
|
93
|
-
docile (~> 1.1)
|
94
|
-
json (>= 1.8, < 3)
|
95
|
-
simplecov-html (~> 0.10.0)
|
96
|
-
simplecov-html (0.10.2)
|
97
|
-
unf (0.1.4)
|
98
|
-
unf_ext
|
99
|
-
unf_ext (0.0.7.5)
|
100
|
-
webmock (3.3.0)
|
101
|
-
addressable (>= 2.3.6)
|
102
|
-
crack (>= 0.3.2)
|
103
|
-
hashdiff
|
104
|
-
|
105
|
-
PLATFORMS
|
106
|
-
ruby
|
107
|
-
|
108
|
-
DEPENDENCIES
|
109
|
-
bundler (~> 1.16)
|
110
|
-
pry-byebug (~> 3.6)
|
111
|
-
pwush!
|
112
|
-
rake (~> 10.0)
|
113
|
-
rspec (~> 3.0)
|
114
|
-
rspec_junit_formatter (~> 0.3)
|
115
|
-
simplecov (~> 0.16)
|
116
|
-
webmock (~> 3.0)
|
117
|
-
|
118
|
-
BUNDLED WITH
|
119
|
-
1.16.2
|