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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdbe86415e1ff2cdeb0dfb7a9229551f010ec1382e5ee94e7d37101dad60efea
|
4
|
+
data.tar.gz: 8af01dfd83eada3351dd739d723df4a682ee8d864c1f2aeae2d6840ab67d2cca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5c0c37a945410c1db532e0469298c3fe13a64c236d567a597669281cb464f5be1bf9338a6c9fae74c73aa993b5acdfd2f6dbe3ca0036099e00604a6e8add1bf
|
7
|
+
data.tar.gz: 81b060f70f6d9b979e12df327137082bfe7c300e15baed3818b028f21454060f88ab1ead4c43b0b4948f0382dc107a19ba54414803c3d4689f8999a5ef1782c5
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "main" ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
permissions:
|
12
|
+
contents: read
|
13
|
+
packages: write
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v3
|
17
|
+
- name: Set up Ruby 2.7
|
18
|
+
uses: actions/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.7.x
|
21
|
+
|
22
|
+
- name: Publish to GPR
|
23
|
+
run: |
|
24
|
+
mkdir -p $HOME/.gem
|
25
|
+
touch $HOME/.gem/credentials
|
26
|
+
chmod 0600 $HOME/.gem/credentials
|
27
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
28
|
+
gem build *.gemspec
|
29
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
30
|
+
env:
|
31
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
32
|
+
OWNER: ${{ github.repository_owner }}
|
33
|
+
|
34
|
+
- name: Publish to RubyGems
|
35
|
+
run: |
|
36
|
+
mkdir -p $HOME/.gem
|
37
|
+
touch $HOME/.gem/credentials
|
38
|
+
chmod 0600 $HOME/.gem/credentials
|
39
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
40
|
+
gem build *.gemspec
|
41
|
+
gem push *.gem
|
42
|
+
env:
|
43
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "main", "edge" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "main", "edge" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
checks: write
|
19
|
+
|
20
|
+
jobs:
|
21
|
+
test:
|
22
|
+
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
strategy:
|
25
|
+
matrix:
|
26
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
27
|
+
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v3
|
30
|
+
- name: Set up Ruby
|
31
|
+
uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby-version }}
|
34
|
+
bundler-cache: true
|
35
|
+
- name: Run tests
|
36
|
+
run: bundle exec rake
|
37
|
+
- name: SimpleCov+ Action
|
38
|
+
uses: joshmfrankel/simplecov-check-action@1.0.0
|
39
|
+
with:
|
40
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
41
|
+
|
42
|
+
|
43
|
+
dependency-review:
|
44
|
+
runs-on: ubuntu-latest
|
45
|
+
steps:
|
46
|
+
- name: 'Checkout Repository'
|
47
|
+
uses: actions/checkout@v3
|
48
|
+
- name: 'Dependency Review'
|
49
|
+
uses: actions/dependency-review-action@v2
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [0.4.0](https://github.com/iarie/pwush/tree/HEAD)
|
4
|
+
- Update Dry-Monads runtime dependecy to 1.4
|
5
|
+
- Update Dry-Struct runtime dependecy to 1.4
|
6
|
+
- Update the HTTP gem runtime dependecy to 5.1
|
7
|
+
- Drop ruby 2.5 support
|
8
|
+
|
9
|
+
## [0.3.0](https://github.com/iarie/pwush/tree/HEAD)
|
10
|
+
- Update Dry-Struct runtime dependecy to 1.0
|
11
|
+
- Drop ruby 2.3 support
|
12
|
+
|
13
|
+
## [0.2.0](https://github.com/iarie/pwush/tree/HEAD)
|
14
|
+
|
15
|
+
**Added:**
|
16
|
+
- Introduce devices api [\#4](https://github.com/iarie/pwush/pull/4) ([iarie](https://github.com/iarie))
|
17
|
+
|
18
|
+
## [0.1.2](https://github.com/iarie/pwush/tree/HEAD)
|
19
|
+
|
20
|
+
**Changed:**
|
21
|
+
- Update dry-rb gems [\#3](https://github.com/iarie/pwush/pull/3)
|
22
|
+
|
23
|
+
## [0.1.1](https://github.com/iarie/pwush/tree/HEAD)
|
24
|
+
|
25
|
+
**Added:**
|
26
|
+
- timeout config options added [\#1](https://github.com/iarie/pwush/pull/1) ([achernik](https://github.com/achernik))
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
[](https://circleci.com/gh/iarie/pwush/tree/master)
|
2
1
|
[](https://badge.fury.io/rb/pwush)
|
3
2
|
[](https://codeclimate.com/github/iarie/pwush/maintainability)
|
4
3
|
[](https://codeclimate.com/github/iarie/pwush/test_coverage)
|
@@ -12,7 +11,7 @@ Pwush is a remote api toolkit for [Pushwoosh](https://www.pushwoosh.com/v1.0/ref
|
|
12
11
|
Add this line to your application's Gemfile:
|
13
12
|
|
14
13
|
```ruby
|
15
|
-
gem 'pwush', '~> 0.
|
14
|
+
gem 'pwush', '~> 0.3.0'
|
16
15
|
```
|
17
16
|
|
18
17
|
And then execute:
|
@@ -31,6 +30,10 @@ MyPW = Pwush.new(auth: 'AUTH_KEY', app: 'APP_CODE', timeout: { connect: 5, read:
|
|
31
30
|
```
|
32
31
|
### Push message
|
33
32
|
```ruby
|
33
|
+
MyPW.create_message(content: 'Hello, there!')
|
34
|
+
```
|
35
|
+
### Using built-in struct
|
36
|
+
```ruby
|
34
37
|
first_message = Pwush::Message.new(
|
35
38
|
content: { en: 'Hello' },
|
36
39
|
send_date: '2018-04-06 23:00',
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pwush
|
4
|
+
module Api
|
5
|
+
module Devices
|
6
|
+
def register_device(params)
|
7
|
+
post(:registerDevice, params)
|
8
|
+
end
|
9
|
+
|
10
|
+
def unregister_device(hwid)
|
11
|
+
post(:unregisterDevice, hwid: hwid)
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_test_device(params)
|
15
|
+
post(:createTestDevice, params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def list_test_devices
|
19
|
+
post(:listTestDevices)
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_badge(hwid, badge)
|
23
|
+
post(:setBadge, hwid: hwid, badge: badge)
|
24
|
+
end
|
25
|
+
|
26
|
+
def application_open(hwid)
|
27
|
+
post(:applicationOpen, hwid: hwid)
|
28
|
+
end
|
29
|
+
|
30
|
+
def push_stat(hwid, hash_tag = nil)
|
31
|
+
post(:pushStat, hwid: hwid, hash: hash_tag)
|
32
|
+
end
|
33
|
+
|
34
|
+
def message_delivery_event(hwid, hash_tag = nil)
|
35
|
+
post(:messageDeliveryEvent, hwid: hwid, hash: hash_tag)
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_purchase(hwid, params = {})
|
39
|
+
post(:setPurchase, params.merge(hwid: hwid))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pwush
|
4
|
+
module Api
|
5
|
+
module Messages
|
6
|
+
def create_message(*messages)
|
7
|
+
post(:createMessage, notifications: messages.flatten)
|
8
|
+
end
|
9
|
+
alias push create_message
|
10
|
+
|
11
|
+
def delete_message(message_code)
|
12
|
+
post(:deleteMessage, message: message_code)
|
13
|
+
end
|
14
|
+
|
15
|
+
def message_details(message)
|
16
|
+
post(:getMessageDetails, message: message)
|
17
|
+
end
|
18
|
+
|
19
|
+
def message_stats(message)
|
20
|
+
post(:getMsgStats, message: message)
|
21
|
+
end
|
22
|
+
|
23
|
+
def results(request_id)
|
24
|
+
post(:getResults, request_id: request_id)
|
25
|
+
end
|
26
|
+
|
27
|
+
def preset(preset_code)
|
28
|
+
post(:getPreset, preset_code: preset_code)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pwush/client.rb
CHANGED
@@ -1,40 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'http'
|
2
4
|
|
5
|
+
require 'pwush/api/messages'
|
6
|
+
require 'pwush/api/devices'
|
7
|
+
require 'pwush/api/applications'
|
8
|
+
|
3
9
|
module Pwush
|
4
10
|
class Client
|
11
|
+
include Api::Messages
|
12
|
+
include Api::Devices
|
13
|
+
include Api::Applications
|
14
|
+
|
5
15
|
def initialize(options)
|
6
16
|
@config = Config.new(options)
|
7
17
|
end
|
8
18
|
|
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
19
|
private
|
39
20
|
|
40
21
|
def get(action, payload = nil)
|
@@ -57,7 +38,7 @@ module Pwush
|
|
57
38
|
"Pushwoosh #{verb.upcase} #{url} BODY #{request.body.to_json}"
|
58
39
|
)
|
59
40
|
|
60
|
-
|
41
|
+
HTTP.timeout(@config.timeout).request(verb, url, json: request.body)
|
61
42
|
end
|
62
43
|
|
63
44
|
def build_request(payload = nil)
|
data/lib/pwush/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'logger'
|
2
4
|
|
3
5
|
module Pwush
|
@@ -5,14 +7,14 @@ module Pwush
|
|
5
7
|
MissingAppToken = Class.new(StandardError)
|
6
8
|
|
7
9
|
class Config
|
8
|
-
URL = 'https://cp.pushwoosh.com/json/1.3'
|
10
|
+
URL = 'https://cp.pushwoosh.com/json/1.3'
|
9
11
|
|
10
12
|
def initialize(options = {})
|
11
13
|
@url = options[:url] || URL
|
12
14
|
@auth = options[:auth] || auth_missing
|
13
15
|
@app = options[:app] || app_missing
|
14
16
|
@timeout = options[:timeout] || { write: 2, connect: 5, read: 10 }
|
15
|
-
@logger = options[:logger] || Logger.new(
|
17
|
+
@logger = options[:logger] || Logger.new($stdout)
|
16
18
|
end
|
17
19
|
|
18
20
|
attr_accessor :auth, :url, :app, :timeout, :logger
|