pwush 0.1.5 → 0.4.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/.github/workflows/gem-push.yml +43 -0
- data/.github/workflows/ruby.yml +49 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +26 -0
- data/Gemfile +3 -1
- data/README.md +5 -2
- data/Rakefile +5 -3
- data/bin/console +1 -0
- data/lib/pwush/api/applications.rb +11 -0
- data/lib/pwush/api/devices.rb +43 -0
- data/lib/pwush/api/messages.rb +32 -0
- data/lib/pwush/client.rb +11 -30
- data/lib/pwush/config.rb +4 -2
- data/lib/pwush/message.rb +83 -96
- data/lib/pwush/request.rb +3 -1
- data/lib/pwush/response/deffered.rb +5 -2
- data/lib/pwush/response/value.rb +5 -3
- data/lib/pwush/response.rb +3 -1
- data/lib/pwush/types.rb +3 -1
- data/lib/pwush/version.rb +3 -1
- data/lib/pwush.rb +2 -0
- data/pwush.gemspec +14 -12
- metadata +34 -59
- data/.circleci/config.yml +0 -64
- data/Gemfile.lock +0 -119
data/lib/pwush/message.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Pwush
|
2
4
|
class Message < Dry::Struct
|
3
5
|
# transform_types do |type|
|
@@ -6,17 +8,17 @@ module Pwush
|
|
6
8
|
# https://www.pushwoosh.com/v1.0/reference#createmessage
|
7
9
|
|
8
10
|
# YYYY-MM-DD HH:mm OR 'now'
|
9
|
-
attribute :send_date, Types::Strict::String.default('now')
|
11
|
+
attribute :send_date, Types::Strict::String.default('now').freeze
|
10
12
|
|
11
13
|
attribute :ignore_user_timezone, Types::Strict::Bool.default(true)
|
12
14
|
|
13
15
|
# "timezone":"America/New_York", optional, if ignored UTC-0 is default in "send_date".
|
14
16
|
# See http://php.net/manual/timezones.php for supported timezones
|
15
|
-
attribute :timezone, Types::Strict::String
|
17
|
+
attribute? :timezone, Types::Strict::String
|
16
18
|
|
17
19
|
# "campaign":"CAMPAIGN_CODE", optional.
|
18
20
|
# Campaign code to which you want to assign this push message
|
19
|
-
attribute :campaign, Types::Strict::String
|
21
|
+
attribute? :campaign, Types::Strict::String
|
20
22
|
|
21
23
|
# "content":{
|
22
24
|
# "en":"English",
|
@@ -26,96 +28,90 @@ module Pwush
|
|
26
28
|
attribute :content, Types::Strict::String | Types::Hash
|
27
29
|
|
28
30
|
# "page_id": 39, optional. HTML Pages. integer
|
29
|
-
attribute :page_id, Types::Strict::Integer
|
31
|
+
attribute? :page_id, Types::Strict::Integer
|
30
32
|
|
31
33
|
# "rich_page_id": 42, optional. Rich Pages. integer
|
32
|
-
attribute :rich_page_id, Types::Strict::Integer
|
34
|
+
attribute? :rich_page_id, Types::Strict::Integer
|
33
35
|
|
34
36
|
# "rich_media": "XXXX-XXXX", optional. Rich Media code. string
|
35
|
-
attribute :rich_media, Types::Strict::String
|
37
|
+
attribute? :rich_media, Types::Strict::String
|
36
38
|
|
37
39
|
# "remote_page" : "http://myremoteurl.com",
|
38
40
|
# Remote Rich HTML Page URL. <scheme>://<authority>
|
39
|
-
attribute :remote_page, Types::Strict::String
|
41
|
+
attribute? :remote_page, Types::Strict::String
|
40
42
|
|
41
43
|
# "link": "http://google.com", optional, string.
|
42
44
|
# For deeplinks add "minimize_link":0
|
43
|
-
attribute :link, Types::Strict::String
|
45
|
+
attribute? :link, Types::Strict::String
|
44
46
|
|
45
47
|
# "minimize_link": 0, optional.
|
46
48
|
# 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)
|
49
|
+
attribute? :minimize_link, Types::Strict::Integer.constrained(included_in: 0..2)
|
49
50
|
|
50
51
|
# "data": {"key":"value"}, JSON string or JSON object,
|
51
52
|
# will be passed as "u" parameter in the payload (converted to JSON string)
|
52
|
-
attribute :data,
|
53
|
+
attribute? :data, Types::Strict::String | Types::Hash
|
53
54
|
|
54
55
|
# 1 - iOS; 2 - BB; 3 - Android; 5 - Windows Phone; 7 - OS X; 8 - Windows 8;
|
55
56
|
# 9 - Amazon; 10 - Safari; 11 - Chrome; 12 - Firefox;
|
56
57
|
# ignored if "devices" < 10
|
57
58
|
Platforms = Types::Strict::Integer.enum(1, 2, 3, 5, 7, 8, 9, 10, 11, 12)
|
58
|
-
attribute :platforms, Types::Strict::Array.of(Platforms)
|
59
|
+
attribute? :platforms, Types::Strict::Array.of(Platforms)
|
59
60
|
|
60
61
|
# "preset":"Q1A2Z-6X8SW", Push Preset Code from your Control Panel
|
61
|
-
attribute :preset, Types::Strict::String
|
62
|
+
attribute? :preset, Types::Strict::String
|
62
63
|
|
63
64
|
# "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)
|
65
|
+
attribute? :send_rate, Types::Strict::Integer.constrained(included_in: 100..1000)
|
66
66
|
|
67
67
|
# Optional. Specify tokens or hwids to send targeted push notifications.
|
68
68
|
# Not more than 1000 tokens/hwids in an array.
|
69
69
|
# If set, the message will only be sent to the devices on the list.
|
70
70
|
# 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)
|
71
|
+
attribute? :devices, Types::Strict::Array.of(Types::Strict::String)
|
73
72
|
|
74
73
|
# "users":["user_3078a"], optional.
|
75
74
|
# If set, message will only be delivered to the specified users Id's
|
76
75
|
# (specified via /registerUser call).
|
77
76
|
# 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)
|
77
|
+
attribute? :users, Types::Strict::Array.of(Types::Strict::String)
|
80
78
|
|
81
79
|
# "filter": "FILTER_NAME", optional.
|
82
|
-
attribute :filter, Types::Strict::String
|
80
|
+
attribute? :filter, Types::Strict::String
|
83
81
|
|
84
82
|
# optional, placeholders for dynamic content instead of device tags
|
85
83
|
# "dynamic_content_placeholders" :{
|
86
84
|
# "firstname":"John",
|
87
85
|
# "lastname":"Doe"
|
88
86
|
# },
|
89
|
-
attribute :dynamic_content_placeholders, Types::Hash
|
87
|
+
attribute? :dynamic_content_placeholders, Types::Hash
|
90
88
|
|
91
89
|
# "conditions": [TAG_CONDITION1, TAG_CONDITION2, ..., TAG_CONDITIONN],
|
92
90
|
# Optional.
|
93
|
-
attribute :conditions, Types::Strict::Array.of(Types::Strict::String)
|
94
|
-
.meta(omittable: true)
|
91
|
+
attribute? :conditions, Types::Strict::Array.of(Types::Strict::String)
|
95
92
|
|
96
93
|
# iOS related
|
97
94
|
|
98
95
|
# "ios_badges": 5, optional, integer.
|
99
96
|
# iOS application badge number.
|
100
97
|
# Use "+n" or "-n" to increment/decrement the badge value by n
|
101
|
-
attribute :ios_badges, Types::Strict::Integer
|
98
|
+
attribute? :ios_badges, Types::Strict::Integer
|
102
99
|
|
103
100
|
# "ios_sound": "sound file.wav", optional.
|
104
101
|
# Sound file name in the main bundle of application.
|
105
102
|
# If left empty, the device will produce no sound upon receiving a push
|
106
|
-
attribute :ios_sound, Types::Strict::String
|
103
|
+
attribute? :ios_sound, Types::Strict::String
|
107
104
|
|
108
105
|
# "ios_ttl": 3600, optional.
|
109
106
|
# Time to live parameter - maximum message lifespan in seconds
|
110
|
-
attribute :ios_ttl, Types::Strict::Integer
|
107
|
+
attribute? :ios_ttl, Types::Strict::Integer
|
111
108
|
|
112
109
|
# "ios_silent": 1, optional.
|
113
110
|
# Enable silent notifications (ignore "sound" and "content")
|
114
|
-
attribute :ios_silent, Types::Strict::Integer.constrained(included_in: 0..1)
|
115
|
-
.meta(omittable: true)
|
111
|
+
attribute? :ios_silent, Types::Strict::Integer.constrained(included_in: 0..1)
|
116
112
|
|
117
113
|
# iOS8 category ID from Pushwoosh
|
118
|
-
attribute :ios_category_id, Types::Strict::Integer
|
114
|
+
attribute? :ios_category_id, Types::Strict::Integer
|
119
115
|
|
120
116
|
# Optional - root level parameters to the aps dictionary
|
121
117
|
# "ios_root_params" : {
|
@@ -126,121 +122,118 @@ module Pwush
|
|
126
122
|
# "attachment":"YOUR_ATTACHMENT_URL", // iOS 10 media attachment URL
|
127
123
|
# "data": << User supplied data, max of 4KB>>
|
128
124
|
# },
|
129
|
-
attribute :ios_root_params, Types::Hash
|
125
|
+
attribute? :ios_root_params, Types::Hash
|
130
126
|
|
131
127
|
# "apns_trim_content":1, optional. (0|1)
|
132
128
|
# Trims the exceeding content strings with ellipsis
|
133
|
-
attribute :apns_trim_content, Types::Strict::Integer.constrained(included_in: 0..1)
|
134
|
-
.meta(omittable: true)
|
129
|
+
attribute? :apns_trim_content, Types::Strict::Integer.constrained(included_in: 0..1)
|
135
130
|
|
136
131
|
# "ios_title":"Title", optional. Add Title for push notification
|
137
|
-
attribute :ios_title, Types::Strict::String
|
132
|
+
attribute? :ios_title, Types::Strict::String
|
138
133
|
|
139
134
|
# "ios_subtitle" : "SubTitle", //Optional. Added sub-title for push notification
|
140
|
-
attribute :ios_subtitle, Types::Strict::String
|
135
|
+
attribute? :ios_subtitle, Types::Strict::String
|
141
136
|
|
142
137
|
# Android related
|
143
138
|
|
144
139
|
# "android_root_params": {"key": "value"}
|
145
140
|
# custom key-value object. root level parameters for the android payload recipients
|
146
|
-
attribute :android_root_params, Types::Hash
|
141
|
+
attribute? :android_root_params, Types::Hash
|
147
142
|
|
148
143
|
# "android_sound" : "soundfile", optional. No file extension.
|
149
144
|
# If left empty, the device will produce no sound upon receiving a push
|
150
|
-
attribute :android_sound, Types::Strict::String
|
145
|
+
attribute? :android_sound, Types::Strict::String
|
151
146
|
|
152
147
|
# "android_header":"header", optional. Android notification header
|
153
|
-
attribute :android_header, Types::Strict::String
|
148
|
+
attribute? :android_header, Types::Strict::String
|
154
149
|
|
155
150
|
# "android_icon": "icon",
|
156
|
-
attribute :android_icon, Types::Strict::String
|
151
|
+
attribute? :android_icon, Types::Strict::String
|
157
152
|
|
158
153
|
# "android_custom_icon": "http://example.com/image.png", optional.
|
159
154
|
# Full path URL to the image file
|
160
|
-
attribute :android_custom_icon, Types::Strict::String
|
155
|
+
attribute? :android_custom_icon, Types::Strict::String
|
161
156
|
|
162
157
|
# "android_banner": "http://example.com/banner.png", optional.
|
163
158
|
# Full path URL to the image file
|
164
|
-
attribute :android_banner, Types::Strict::String
|
159
|
+
attribute? :android_banner, Types::Strict::String
|
165
160
|
|
166
161
|
# "android_badges": 5, optional, integer.
|
167
162
|
# Android application icon badge number.
|
168
163
|
# Use "+n" or "-n" to increment/decrement the badge value by n
|
169
|
-
attribute :android_badges, Types::Strict::Integer
|
164
|
+
attribute? :android_badges, Types::Strict::Integer
|
170
165
|
|
171
166
|
# "android_gcm_ttl": 3600, optional.
|
172
167
|
# Time to live parameter - maximum message lifespan in seconds
|
173
|
-
attribute :android_gcm_ttl, Types::Strict::Integer
|
168
|
+
attribute? :android_gcm_ttl, Types::Strict::Integer
|
174
169
|
|
175
170
|
# "android_vibration": 0, Android force-vibration for high-priority pushes, boolean
|
176
|
-
attribute :android_vibration, Types::Strict::Bool
|
171
|
+
attribute? :android_vibration, Types::Strict::Bool
|
177
172
|
|
178
173
|
# "android_led":"#rrggbb", LED hex color, device will do its best approximation
|
179
|
-
attribute :android_led, Types::Strict::String
|
174
|
+
attribute? :android_led, Types::Strict::String
|
180
175
|
|
181
176
|
# "android_priority":-1, priority of the push in the Android push drawer.
|
182
177
|
# 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)
|
178
|
+
attribute? :android_priority, Types::Strict::Integer.constrained(included_in: -2..2)
|
185
179
|
|
186
180
|
# "android_ibc":"#RRGGBB", icon background color on Lollipop,
|
187
181
|
# #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
|
188
|
-
attribute :android_ibc, Types::Strict::String
|
182
|
+
attribute? :android_ibc, Types::Strict::String
|
189
183
|
|
190
184
|
# "android_silent": 1, optional. 0 or 1
|
191
185
|
# Enable silent notificaiton (ignore sound and content)
|
192
|
-
attribute :android_silent, Types::Strict::Integer.constrained(included_in: 0..1)
|
193
|
-
.meta(omittable: true)
|
186
|
+
attribute? :android_silent, Types::Strict::Integer.constrained(included_in: 0..1)
|
194
187
|
|
195
188
|
# Amazon related
|
196
189
|
|
197
190
|
# "adm_root_params": {"key": "value"}, // custom key-value object
|
198
|
-
attribute :adm_root_params, Types::Hash
|
191
|
+
attribute? :adm_root_params, Types::Hash
|
199
192
|
# "adm_sound": "push.mp3",
|
200
|
-
attribute :adm_sound, Types::Strict::String
|
193
|
+
attribute? :adm_sound, Types::Strict::String
|
201
194
|
# "adm_header": "Header",
|
202
|
-
attribute :adm_header, Types::Strict::String
|
195
|
+
attribute? :adm_header, Types::Strict::String
|
203
196
|
# "adm_icon": "icon",
|
204
|
-
attribute :adm_icon, Types::Strict::String
|
197
|
+
attribute? :adm_icon, Types::Strict::String
|
205
198
|
# "adm_custom_icon": "http://example.com/image.png",
|
206
|
-
attribute :adm_custom_icon, Types::Strict::String
|
199
|
+
attribute? :adm_custom_icon, Types::Strict::String
|
207
200
|
# "adm_banner": "http://example.com/banner.png",
|
208
|
-
attribute :adm_banner, Types::Strict::String
|
201
|
+
attribute? :adm_banner, Types::Strict::String
|
209
202
|
# "adm_ttl": 3600, optional. Time to live parameter - the maximum message lifespan in seconds
|
210
|
-
attribute :adm_ttl, Types::Strict::Integer
|
203
|
+
attribute? :adm_ttl, Types::Strict::Integer
|
211
204
|
# "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.
|
205
|
+
attribute? :adm_priority, Types::Strict::Integer.constrained(included_in: -2..2)
|
213
206
|
|
214
207
|
# Windows Phone related
|
215
208
|
|
216
209
|
# Windows Phone notification type. 'Tile' or 'Toast'. Raw notifications are not supported. 'Tile' if default
|
217
|
-
attribute :wp_type, Types::Strict::String
|
210
|
+
attribute? :wp_type, Types::Strict::String
|
218
211
|
# tile image
|
219
|
-
attribute :wp_background, Types::Strict::String
|
212
|
+
attribute? :wp_background, Types::Strict::String
|
220
213
|
# back tile image
|
221
|
-
attribute :wp_backbackground, Types::Strict::String
|
214
|
+
attribute? :wp_backbackground, Types::Strict::String
|
222
215
|
# back tile title
|
223
|
-
attribute :wp_backtitle, Types::Strict::String
|
216
|
+
attribute? :wp_backtitle, Types::Strict::String
|
224
217
|
# back tile content
|
225
|
-
attribute :wp_backcontent, Types::Strict::String
|
218
|
+
attribute? :wp_backcontent, Types::Strict::String
|
226
219
|
# Badge for Windows Phone notification
|
227
|
-
attribute :wp_count, Types::Strict::Integer
|
220
|
+
attribute? :wp_count, Types::Strict::Integer
|
228
221
|
|
229
222
|
# BlackBerry related
|
230
223
|
|
231
224
|
# BlackBerry header, applicable to BB10 Series devices
|
232
|
-
attribute :blackberry_header, Types::Strict::String
|
225
|
+
attribute? :blackberry_header, Types::Strict::String
|
233
226
|
|
234
227
|
# Mac OS X related
|
235
228
|
|
236
229
|
# "mac_badges": 3,
|
237
|
-
attribute :mac_badges, Types::Strict::Integer
|
230
|
+
attribute? :mac_badges, Types::Strict::Integer
|
238
231
|
# "mac_sound": "sound.caf",
|
239
|
-
attribute :mac_sound, Types::Strict::String
|
232
|
+
attribute? :mac_sound, Types::Strict::String
|
240
233
|
# "mac_root_params": {"content-available":1},
|
241
|
-
attribute :mac_root_params, Types::Hash
|
234
|
+
attribute? :mac_root_params, Types::Hash
|
242
235
|
# Time to live parameter — maximum message lifespan in seconds
|
243
|
-
attribute :mac_ttl, Types::Strict::Integer
|
236
|
+
attribute? :mac_ttl, Types::Strict::Integer
|
244
237
|
|
245
238
|
# WNS related
|
246
239
|
|
@@ -248,79 +241,73 @@ module Pwush
|
|
248
241
|
# "en": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==",
|
249
242
|
# "de": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4="
|
250
243
|
# },
|
251
|
-
attribute :wns_content, Types::Hash
|
244
|
+
attribute? :wns_content, Types::Hash
|
252
245
|
# 'Tile' | 'Toast' | 'Badge' | 'Raw'
|
253
|
-
attribute :wns_type, Types::Strict::String
|
246
|
+
attribute? :wns_type, Types::Strict::String
|
254
247
|
# optional. Used in Tile replacement policy. An alphanumeric string of no more than 16 characters.
|
255
|
-
attribute :wns_tag, Types::Strict::String
|
248
|
+
attribute? :wns_tag, Types::Strict::String
|
256
249
|
# optional. (1|0) Translates into X-WNS-Cache-Policy value
|
257
|
-
attribute :wns_cache, Types::Strict::Integer
|
250
|
+
attribute? :wns_cache, Types::Strict::Integer
|
258
251
|
# optional. Expiration time for notification in seconds
|
259
|
-
attribute :wns_ttl, Types::Strict::Integer
|
252
|
+
attribute? :wns_ttl, Types::Strict::Integer
|
260
253
|
|
261
254
|
# Safari related
|
262
255
|
|
263
256
|
# obligatory, title of the notification
|
264
|
-
attribute :safari_title, Types::Strict::String
|
257
|
+
attribute? :safari_title, Types::Strict::String
|
265
258
|
|
266
259
|
# "safari_action": "Click here", // optional
|
267
|
-
attribute :safari_action, Types::Strict::String
|
260
|
+
attribute? :safari_action, Types::Strict::String
|
268
261
|
|
269
262
|
# "safari_url_args": ["firstArgument", "secondArgument"],
|
270
263
|
# Obligatory, but the value may be empty
|
271
|
-
attribute :safari_url_args, Types::Strict::Array.of(Types::Strict::String)
|
272
|
-
.meta(omittable: true)
|
264
|
+
attribute? :safari_url_args, Types::Strict::Array.of(Types::Strict::String)
|
273
265
|
|
274
266
|
# 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)
|
267
|
+
attribute? :safari_ttl, Types::Strict::Integer.constrained(min_size: 0)
|
277
268
|
|
278
269
|
# Chrome related
|
279
270
|
|
280
271
|
# You can specify the header of the message in this parameter
|
281
|
-
attribute :chrome_title, Types::Strict::String
|
272
|
+
attribute? :chrome_title, Types::Strict::String
|
282
273
|
|
283
274
|
# "chrome_icon":"", full path URL to the icon or extension resources file path
|
284
|
-
attribute :chrome_icon, Types::Strict::String
|
275
|
+
attribute? :chrome_icon, Types::Strict::String
|
285
276
|
|
286
277
|
# Time to live parameter - maximum message lifespan in seconds
|
287
|
-
attribute :chrome_gcm_ttl, Types::Strict::Integer
|
278
|
+
attribute? :chrome_gcm_ttl, Types::Strict::Integer
|
288
279
|
|
289
280
|
# optional, changes chrome push display time.
|
290
281
|
# Set to 0 to display push until user interacts with it
|
291
|
-
attribute :chrome_duration, Types::Strict::Integer
|
282
|
+
attribute? :chrome_duration, Types::Strict::Integer
|
292
283
|
|
293
284
|
# optional, URL to large image.
|
294
|
-
attribute :chrome_image, Types::Strict::String
|
285
|
+
attribute? :chrome_image, Types::Strict::String
|
295
286
|
|
296
|
-
attribute :chrome_button_text1, Types::Strict::String
|
287
|
+
attribute? :chrome_button_text1, Types::Strict::String
|
297
288
|
|
298
289
|
# ignored if chrome_button_text1 is not set
|
299
|
-
attribute :chrome_button_url1, Types::Strict::String
|
290
|
+
attribute? :chrome_button_url1, Types::Strict::String
|
300
291
|
|
301
|
-
attribute :chrome_button_text2, Types::Strict::String
|
292
|
+
attribute? :chrome_button_text2, Types::Strict::String
|
302
293
|
|
303
294
|
# ignored if chrome_button_text2 is not set
|
304
|
-
attribute :chrome_button_url2, Types::Strict::String
|
295
|
+
attribute? :chrome_button_url2, Types::Strict::String
|
305
296
|
|
306
297
|
# Firefox-related
|
307
298
|
|
308
299
|
# optional. You can specify message header here
|
309
|
-
attribute :firefox_title, Types::Strict::String
|
300
|
+
attribute? :firefox_title, Types::Strict::String
|
310
301
|
|
311
302
|
# 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
|
303
|
+
attribute? :firefox_icon, Types::Strict::String
|
317
304
|
|
318
305
|
def to_json(options = nil)
|
319
|
-
|
306
|
+
attributes.to_json(options)
|
320
307
|
end
|
321
308
|
|
322
309
|
def inspect
|
323
|
-
attrs =
|
310
|
+
attrs = attributes.map { |k, v| " #{k}=#{v.inspect}" }.join
|
324
311
|
"#<#{self.class}#{attrs}>"
|
325
312
|
end
|
326
313
|
end
|
data/lib/pwush/request.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Pwush
|
2
4
|
module Response
|
3
5
|
class Deffered
|
@@ -10,6 +12,7 @@ module Pwush
|
|
10
12
|
def resolve
|
11
13
|
return http_request_failure if raw_result.status != 200
|
12
14
|
return api_request_failure if value_from_api.status_code != 200
|
15
|
+
|
13
16
|
api_request_succesful
|
14
17
|
end
|
15
18
|
|
@@ -45,9 +48,9 @@ module Pwush
|
|
45
48
|
|
46
49
|
def value_from_api
|
47
50
|
@_value_from_api ||= Value.new(
|
48
|
-
status_code:
|
51
|
+
status_code: parsed_result['status_code'],
|
49
52
|
status_message: parsed_result['status_message'],
|
50
|
-
body:
|
53
|
+
body: parsed_result['response']
|
51
54
|
)
|
52
55
|
end
|
53
56
|
end
|
data/lib/pwush/response/value.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Pwush
|
2
4
|
module Response
|
3
|
-
class Value < Dry::Struct
|
5
|
+
class Value < Dry::Struct
|
4
6
|
attribute :status_code, Types::Coercible::Integer
|
5
|
-
attribute :status_message, Types::Strict::String
|
6
|
-
attribute :body, (Types::Hash | Types::String).
|
7
|
+
attribute? :status_message, Types::Strict::String
|
8
|
+
attribute? :body, (Types::Hash | Types::String).optional
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
data/lib/pwush/response.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'dry/monads/result'
|
2
4
|
|
3
5
|
require 'pwush/response/deffered'
|
@@ -9,7 +11,7 @@ module Pwush
|
|
9
11
|
|
10
12
|
def self.wrap
|
11
13
|
Deffered.new(yield).resolve
|
12
|
-
rescue
|
14
|
+
rescue HTTP::TimeoutError => e
|
13
15
|
Failure.new(e)
|
14
16
|
end
|
15
17
|
end
|
data/lib/pwush/types.rb
CHANGED
data/lib/pwush/version.rb
CHANGED
data/lib/pwush.rb
CHANGED
data/pwush.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'pwush/version'
|
@@ -20,17 +22,17 @@ Gem::Specification.new do |spec|
|
|
20
22
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
23
|
spec.require_paths = ['lib']
|
22
24
|
|
23
|
-
spec.
|
24
|
-
|
25
|
-
spec.add_dependency 'dry-
|
26
|
-
spec.add_dependency '
|
27
|
-
spec.add_dependency '
|
25
|
+
spec.required_ruby_version = '>= 2.6.0'
|
26
|
+
|
27
|
+
spec.add_dependency 'dry-monads', '~> 1.4'
|
28
|
+
spec.add_dependency 'dry-struct', '~> 1.4'
|
29
|
+
spec.add_dependency 'http', '~> 5.1'
|
30
|
+
spec.add_dependency 'oj', '~> 3.13'
|
28
31
|
|
29
|
-
spec.add_development_dependency 'bundler', '~>
|
30
|
-
spec.add_development_dependency 'pry-byebug', '~> 3.
|
31
|
-
spec.add_development_dependency 'rake', '
|
32
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
33
|
-
spec.add_development_dependency '
|
34
|
-
spec.add_development_dependency '
|
35
|
-
spec.add_development_dependency 'webmock', '~> 3.0'
|
32
|
+
spec.add_development_dependency 'bundler', '~> 2.2'
|
33
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
34
|
+
spec.add_development_dependency 'rake', '>= 13.0.6'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.11'
|
36
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
37
|
+
spec.add_development_dependency 'webmock', '~> 3.18'
|
36
38
|
end
|