pwush 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d8d77497c47ca280c06fd2b2060182aa35f2507
4
+ data.tar.gz: ffd8c230450b4ee67d0fd84edf41b80557e24fe3
5
+ SHA512:
6
+ metadata.gz: 32d179a4c3d209330d4c7f7106197cfeec1d33e57f7a99ff34c3f62b5ceb5ccb46da92cbf96a3237b5905b379aaa7f4f306254e7682569aa4ac5757a18d0ff07
7
+ data.tar.gz: d856987601c229d4a2ce043e0eefbd82a05a69a4923f38d0fdd3b676390858d1e2d6044047b7994cdd2cd7d1dcea011e7152d15f0d672c20a4fa3fd069833683
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.3
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at litvinov@applicot.ru. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in pw.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ Pwush (0.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ byebug (10.0.2)
10
+ coderay (1.1.2)
11
+ diff-lcs (1.3)
12
+ method_source (0.9.0)
13
+ pry (0.11.3)
14
+ coderay (~> 1.1.0)
15
+ method_source (~> 0.9.0)
16
+ pry-byebug (3.6.0)
17
+ byebug (~> 10.0)
18
+ pry (~> 0.10)
19
+ rake (10.5.0)
20
+ rspec (3.7.0)
21
+ rspec-core (~> 3.7.0)
22
+ rspec-expectations (~> 3.7.0)
23
+ rspec-mocks (~> 3.7.0)
24
+ rspec-core (3.7.1)
25
+ rspec-support (~> 3.7.0)
26
+ rspec-expectations (3.7.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-mocks (3.7.0)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-support (3.7.1)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ Pwush!
39
+ bundler (~> 1.16)
40
+ pry-byebug
41
+ rake (~> 10.0)
42
+ rspec (~> 3.0)
43
+
44
+ BUNDLED WITH
45
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Yaroslav Litvinov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # PwRb
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pw_rb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'pw'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install pw_rb
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pw. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the PwRb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pw_rb/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pw"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,65 @@
1
+ module Pwush
2
+ class Client
3
+ def initialize(options)
4
+ @config = Config.new(options)
5
+ end
6
+
7
+ def create_message(*notifications)
8
+ post(:createMessage, notifications: notifications)
9
+ end
10
+ alias push create_message
11
+
12
+ def message_details(message)
13
+ post(:getMessageDetails, message: message)
14
+ end
15
+
16
+ # enterprise api
17
+ def message_stats(message)
18
+ post(:getMsgStats, message: message)
19
+ end
20
+
21
+ # enterprise api
22
+ def results(request_id)
23
+ post(:getResults, request_id: request_id)
24
+ end
25
+
26
+ # enterprise api
27
+ def applications
28
+ post(:getApplications)
29
+ end
30
+
31
+ # enterprise api
32
+ def preset(preset_code)
33
+ post(:getPreset, preset_code: preset_code)
34
+ end
35
+
36
+ private
37
+
38
+ def get(action, payload = nil)
39
+ perform_request(:get, action, payload)
40
+ end
41
+
42
+ def post(action, payload = nil)
43
+ perform_request(:post, action, payload)
44
+ end
45
+
46
+ def perform_request(verb, action, payload)
47
+ response = Http.request(
48
+ verb, url(action), json: build_request(payload).body
49
+ )
50
+ parse_response(response)
51
+ end
52
+
53
+ def build_request(payload = nil)
54
+ Request.new(auth: @config.auth, app: @config.app, payload: payload)
55
+ end
56
+
57
+ def parse_response(response)
58
+ Oj.load(response.body)
59
+ end
60
+
61
+ def url(action)
62
+ [@config.url, action].join('/')
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,26 @@
1
+ module Pwush
2
+ MissingAuthToken = Class.new(StandardError)
3
+ MissingAppToken = Class.new(StandardError)
4
+
5
+ class Config
6
+ URL = 'https://cp.pushwoosh.com/json/1.3'.freeze
7
+
8
+ def initialize(options = {})
9
+ @url = options[:url] || URL
10
+ @auth = options[:auth] || auth_missing
11
+ @app = options[:app] || app_missing
12
+ end
13
+
14
+ attr_accessor :auth, :url, :app
15
+
16
+ private
17
+
18
+ def auth_missing
19
+ raise(MissingAuthToken, 'please provide :auth argument')
20
+ end
21
+
22
+ def app_missing
23
+ raise(MissingAppToken, 'please provide :app argument')
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,285 @@
1
+ module Pwush
2
+ class Notification < Dry::Struct::Value
3
+ # https://www.pushwoosh.com/v1.0/reference#createmessage
4
+
5
+ constructor_type :schema
6
+
7
+ # YYYY-MM-DD HH:mm OR 'now'
8
+ attribute :send_date, Types::Strict::String.default('now')
9
+
10
+ attribute :ignore_user_timezone, Types::Strict::Bool.default(true)
11
+
12
+ # "timezone":"America/New_York", optional, if ignored UTC-0 is default in "send_date".
13
+ # See http://php.net/manual/timezones.php for supported timezones
14
+ attribute :timezone, Types::Strict::String.optional
15
+
16
+ # "campaign":"CAMPAIGN_CODE", optional.
17
+ # Campaign code to which you want to assign this push message
18
+ attribute :campaign, Types::Strict::String.optional
19
+
20
+ # "content":{
21
+ # "en":"English",
22
+ # "ru":"Русский",
23
+ # "de":"Deutsch"
24
+ # },
25
+ attribute :content, Types::Strict::String | Types::Hash
26
+
27
+ # "page_id": 39, optional. HTML Pages. integer
28
+ attribute :page_id, Types::Strict::String.optional
29
+
30
+ # "rich_page_id": 42, optional. Rich Pages. integer
31
+ attribute :rich_page_id, Types::Strict::String.optional
32
+
33
+ # "rich_media": "XXXX-XXXX", optional. Rich Media code. string
34
+ attribute :rich_media, Types::Strict::String.optional
35
+
36
+ # "remote_page" : "http://myremoteurl.com",
37
+ # Remote Rich HTML Page URL. <scheme>://<authority>
38
+ attribute :remote_page, Types::Strict::String.optional
39
+
40
+ # "link": "http://google.com", optional, string.
41
+ # For deeplinks add "minimize_link":0
42
+ attribute :link, Types::Strict::String.optional
43
+
44
+ # "minimize_link": 0, optional.
45
+ # False or 0 - do not minimize, 1 - Google, 2 - bitly. Default = 1
46
+ attribute :minimize_link, Types::Strict::Int.default(1).constrained(included_in: 0..2)
47
+
48
+ # "data": {"key":"value"}, JSON string or JSON object,
49
+ # will be passed as "u" parameter in the payload (converted to JSON string)
50
+ attribute :data, Types::Strict::String.optional | Types::Hash
51
+
52
+ # 1 - iOS; 2 - BB; 3 - Android; 5 - Windows Phone; 7 - OS X; 8 - Windows 8;
53
+ # 9 - Amazon; 10 - Safari; 11 - Chrome; 12 - Firefox;
54
+ # ignored if "devices" < 10
55
+ Platforms = Types::Strict::Int.enum(1, 2, 3, 5, 7, 8, 9, 10, 11, 12)
56
+ attribute :platforms, Types::Strict::Array.of(Platforms).optional
57
+
58
+ # "preset":"Q1A2Z-6X8SW", Push Preset Code from your Control Panel
59
+ attribute :preset, Types::Strict::String.optional
60
+
61
+ # "send_rate": 100, throttling. Valid values are from 100 to 1000 pushes/second.
62
+ attribute :send_rate, Types::Strict::Int.optional.constrained(included_in: 100..1000)
63
+
64
+ # Optional. Specify tokens or hwids to send targeted push notifications.
65
+ # Not more than 1000 tokens/hwids in an array.
66
+ # If set, the message will only be sent to the devices on the list.
67
+ # Ignored if the Applications Group is used. iOS push tokens can only be lower case.
68
+ attribute :devices, Types::Strict::Array.of(Types::Strict::String).optional
69
+
70
+ # "users":["user_3078a"], optional.
71
+ # If set, message will only be delivered to the specified users Id's
72
+ # (specified via /registerUser call).
73
+ # If specified together with devices parameter, the latter will be ignored.
74
+ attribute :users, Types::Strict::Array.of(Types::Strict::String).optional
75
+
76
+ # "filter": "FILTER_NAME", optional.
77
+ attribute :filter, Types::Strict::String.optional
78
+
79
+ # optional, placeholders for dynamic content instead of device tags
80
+ # "dynamic_content_placeholders" :{
81
+ # "firstname":"John",
82
+ # "lastname":"Doe"
83
+ # },
84
+ attribute :dynamic_content_placeholders, Types::Hash.optional
85
+
86
+ # "conditions": [TAG_CONDITION1, TAG_CONDITION2, ..., TAG_CONDITIONN],
87
+ # Optional.
88
+ attribute :conditions, Types::Strict::Array.of(Types::Strict::String).optional
89
+
90
+ # iOS related
91
+
92
+ # "ios_badges": 5, optional, integer.
93
+ # iOS application badge number.
94
+ # Use "+n" or "-n" to increment/decrement the badge value by n
95
+ attribute :ios_badges, Types::Strict::Int.optional
96
+
97
+ # "ios_sound": "sound file.wav", optional.
98
+ # Sound file name in the main bundle of application.
99
+ # If left empty, the device will produce no sound upon receiving a push
100
+ attribute :ios_sound, Types::Strict::String.optional
101
+
102
+ # "ios_ttl": 3600, optional.
103
+ # Time to live parameter - maximum message lifespan in seconds
104
+ attribute :ios_ttl, Types::Strict::Int.optional
105
+
106
+ # "ios_silent": 1, optional.
107
+ # Enable silent notifications (ignore "sound" and "content")
108
+ attribute :ios_silent, Types::Strict::Int.optional
109
+
110
+ # iOS8 category ID from Pushwoosh
111
+ attribute :ios_category_id, Types::Strict::Int.optional.constrained(included_in: 0..1)
112
+
113
+ # Optional - root level parameters to the aps dictionary
114
+ # "ios_root_params" : {
115
+ # "aps":{
116
+ # "content-available": "1",
117
+ # "mutable-content":1 //required for iOS 10 Media attachments
118
+ # },
119
+ # "attachment":"YOUR_ATTACHMENT_URL", // iOS 10 media attachment URL
120
+ # "data": << User supplied data, max of 4KB>>
121
+ # },
122
+ attribute :ios_root_params, Types::Hash.optional
123
+
124
+ # "apns_trim_content":1, optional. (0|1)
125
+ # Trims the exceeding content strings with ellipsis
126
+ attribute :apns_trim_content, Types::Strict::Int.optional.constrained(included_in: 0..1)
127
+
128
+ # "ios_title":"Title", optional. Add Title for push notification
129
+ attribute :ios_title, Types::Strict::String.optional
130
+
131
+ # "ios_subtitle" : "SubTitle", //Optional. Added sub-title for push notification
132
+ attribute :ios_subtitle, Types::Strict::String.optional
133
+
134
+ # Android related
135
+
136
+ # "android_root_params": {"key": "value"}
137
+ # custom key-value object. root level parameters for the android payload recipients
138
+ attribute :android_root_params, Types::Hash
139
+
140
+ # "android_sound" : "soundfile", optional. No file extension.
141
+ # If left empty, the device will produce no sound upon receiving a push
142
+ attribute :android_sound, Types::Strict::String.optional
143
+
144
+ # "android_header":"header", optional. Android notification header
145
+ attribute :android_header, Types::Strict::String.optional
146
+
147
+ # "android_icon": "icon",
148
+ attribute :android_icon, Types::Strict::String.optional
149
+
150
+ # "android_custom_icon": "http://example.com/image.png", optional.
151
+ # Full path URL to the image file
152
+ attribute :android_custom_icon, Types::Strict::String.optional
153
+
154
+ # "android_banner": "http://example.com/banner.png", optional.
155
+ # Full path URL to the image file
156
+ attribute :android_banner, Types::Strict::String.optional
157
+
158
+ # "android_badges": 5, optional, integer.
159
+ # Android application icon badge number.
160
+ # Use "+n" or "-n" to increment/decrement the badge value by n
161
+ attribute :android_badges, Types::Strict::Int.optional
162
+
163
+ # "android_gcm_ttl": 3600, optional.
164
+ # Time to live parameter — maximum message lifespan in seconds
165
+ attribute :android_gcm_ttl, Types::Strict::Int.optional
166
+
167
+ # "android_vibration": 0, Android force-vibration for high-priority pushes, boolean
168
+ attribute :android_vibration, Types::Strict::Bool.default(false)
169
+
170
+ # "android_led":"#rrggbb", LED hex color, device will do its best approximation
171
+ attribute :android_led, Types::Strict::String.optional
172
+
173
+ # "android_priority":-1, priority of the push in the Android push drawer.
174
+ # Valid values are -2, -1, 0, 1 and 2
175
+ attribute :android_priority, Types::Strict::Int.optional.constrained(included_in: -2..2)
176
+
177
+ # "android_ibc":"#RRGGBB", icon background color on Lollipop,
178
+ # #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
179
+ attribute :android_ibc, Types::Strict::String.optional
180
+
181
+ # "android_silent": 1, optional. 0 or 1
182
+ # Enable silent notificaiton (ignore sound and content)
183
+ attribute :android_silent, Types::Strict::Int.optional.constrained(included_in: 0..1)
184
+
185
+ # Amazon related
186
+
187
+ # "adm_root_params": {"key": "value"}, // custom key-value object
188
+ # "adm_sound": "push.mp3",
189
+ # "adm_header": "Header",
190
+ # "adm_icon": "icon",
191
+ # "adm_custom_icon": "http://example.com/image.png",
192
+ # "adm_banner": "http://example.com/banner.png",
193
+ # "adm_ttl": 3600, optional. Time to live parameter - the maximum message lifespan in seconds
194
+ # "adm_priority":-1, priority of the push in Amazon push drawer, valid values are -2, -1, 0, 1 and 2
195
+
196
+ # Windows Phone related
197
+
198
+ # "wp_type": "Tile", // Windows Phone notification type. 'Tile' or 'Toast'. Raw notifications are not supported. 'Tile' if default
199
+ # "wp_background": "/Resources/Red.jpg", // tile image
200
+ # "wp_backbackground": "/Resources/Green.jpg", // back tile image
201
+ # "wp_backtitle": "back title", // back tile title
202
+ # "wp_backcontent": "back content", // back tile content
203
+ # "wp_count": 3, // optional. Int. Badge for Windows Phone notification
204
+
205
+ # BlackBerry related
206
+
207
+ # "blackberry_header": "header", BlackBerry header, applicable to BB10 Series devices
208
+
209
+ # Mac OS X related
210
+
211
+ # "mac_badges": 3,
212
+ # "mac_sound": "sound.caf",
213
+ # "mac_root_params": {"content-available":1},
214
+ # "mac_ttl": 3600, // Optional. Time to live parameter — maximum message lifespan in seconds
215
+
216
+ # WNS related
217
+
218
+ # "wns_content": { // Content (XML or raw) of notification encoded in MIME's base64 in form of Object( language1: 'content1', language2: 'content2' ) OR String
219
+ # "en": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==",
220
+ # "de": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4="
221
+ # },
222
+ # "wns_type": "Badge", // 'Tile' | 'Toast' | 'Badge' | 'Raw'
223
+ # "wns_tag": "myTag", // optional. Used in Tile replacement policy. An alphanumeric string of no more than 16 characters.
224
+ # "wns_cache": 1, // optional. (1|0) Translates into X-WNS-Cache-Policy value
225
+ # "wns_ttl": 600, // optional. Expiration time for notification in seconds
226
+
227
+ # Safari related
228
+
229
+ # obligatory, title of the notification
230
+ attribute :safari_title, Types::Strict::String.optional
231
+
232
+ # "safari_action": "Click here", // optional
233
+ attribute :safari_action, Types::Strict::String.optional
234
+
235
+ # "safari_url_args": ["firstArgument", "secondArgument"],
236
+ # Obligatory, but the value may be empty
237
+ attribute :safari_url_args, Types::Strict::Array.of(Types::Strict::String).optional
238
+
239
+ # Optional. Time to live parameter - the maximum lifespan of a message in seconds
240
+ attribute :safari_ttl, Types::Strict::Int.constrained(min_size: 0).optional
241
+
242
+ # Chrome related
243
+
244
+ # "chrome_title":"", optional.
245
+ # You can specify the header of the message in this parameter
246
+ attribute :chrome_title, Types::Strict::String.optional
247
+
248
+ # "chrome_icon":"", full path URL to the icon or extension resources file path
249
+ attribute :chrome_icon, Types::Strict::String.optional
250
+
251
+ # "chrome_gcm_ttl": 3600, optional.
252
+ # Time to live parameter - maximum message lifespan in seconds
253
+ attribute :chrome_gcm_ttl, Types::Strict::Int.optional
254
+
255
+ # "chrome_duration": 20, optional, changes chrome push display time.
256
+ # Set to 0 to display push until user interacts with it
257
+ attribute :chrome_duration”, Types::Strict::Int.optional
258
+
259
+ # "chrome_image": "image_url", optional, URL to large image.
260
+ attribute :chrome_image, Types::Strict::String.optional
261
+
262
+ # "chrome_button_text1": "1", optional
263
+ attribute :chrome_button_text1, Types::Strict::String.optional
264
+
265
+ # "chrome_button_url1": "button1_url", optional,
266
+ # ignored if chrome_button_text1 is not set
267
+ attribute :chrome_button_url1, Types::Strict::String.optional
268
+
269
+ # "chrome_button_text2": "2", optional
270
+ attribute :chrome_button_text2”, Types::Strict::String.optional
271
+
272
+ # "chrome_button_url2": "button2_url", optional,
273
+ # ignored if chrome_button_text2 is not set
274
+ attribute :chrome_button_url2”, Types::Strict::String.optional
275
+
276
+ # Firefox-related
277
+
278
+ # "firefox_title":"", optional. You can specify message header here
279
+ attribute :firefox_title, Types::Strict::String.optional
280
+
281
+ # "firefox_icon":"",
282
+ # full path URL to the icon or path to the file in extension resources
283
+ attribute :firefox_icon, Types::Strict::String.optional
284
+ end
285
+ end
@@ -0,0 +1,26 @@
1
+ module Pwush
2
+ class Request
3
+ attr_reader :body
4
+
5
+ def initialize(auth:, app:, payload: nil)
6
+ @auth = auth
7
+ @app = app
8
+ @payload = payload || {}
9
+ @body = build_body(@payload)
10
+ end
11
+
12
+ def to_json
13
+ Oj.dump(body)
14
+ end
15
+
16
+ private
17
+
18
+ def build_body(payload)
19
+ wrap_request payload.merge(auth: @auth, application: @app)
20
+ end
21
+
22
+ def wrap_request(request)
23
+ { request: request }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ require 'dry-struct'
2
+
3
+ module Pwush
4
+ module Types
5
+ include Dry::Types.module
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Pwush
2
+ VERSION = '0.0.0'.freeze
3
+ end
data/lib/pwush.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'pwush/config'
2
+ require 'pwush/client'
3
+ require 'pwush/request'
4
+ require 'pwush/types'
5
+ require 'pwush/notification'
6
+
7
+ module Pwush
8
+ def self.new(options)
9
+ Client.new(options)
10
+ end
11
+ end
12
+
13
+ # Pwush::Qlean = Pwush.new(
14
+ # auth: App::Settings.pushwoosh.auth,
15
+ # app: App::Settings.pushwoosh.clients_app
16
+ # )
data/pwush.gemspec ADDED
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "pwush/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pwush"
8
+ spec.version = Pwush::VERSION
9
+ spec.authors = ["Yaroslav Litvinov"]
10
+ spec.email = ["litvinov@applicot.ru"]
11
+
12
+ spec.summary = ""
13
+ spec.description = ""
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "pry-byebug"
28
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pwush
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Litvinov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: ''
70
+ email:
71
+ - litvinov@applicot.ru
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/pwush.rb
88
+ - lib/pwush/client.rb
89
+ - lib/pwush/config.rb
90
+ - lib/pwush/notification.rb
91
+ - lib/pwush/request.rb
92
+ - lib/pwush/types.rb
93
+ - lib/pwush/version.rb
94
+ - pwush.gemspec
95
+ homepage: ''
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.6.14
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: ''
119
+ test_files: []