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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 167bc841bf6dcfcb6586b1a8c609abbb9e3e7d0ae68ba0f8e9cade81ba6a9fa7
4
- data.tar.gz: 80f429072e2a6c31882def50b9990ec9b76ae892be0a4f3922b8fe0f86bfd6ff
3
+ metadata.gz: bdbe86415e1ff2cdeb0dfb7a9229551f010ec1382e5ee94e7d37101dad60efea
4
+ data.tar.gz: 8af01dfd83eada3351dd739d723df4a682ee8d864c1f2aeae2d6840ab67d2cca
5
5
  SHA512:
6
- metadata.gz: 81975b84e91988f0006e934a6222a892231031e910dd9796d97756bb6678bda817e540da02dc34465225138e7377b36cf48d55611f73f8bf77ff64aff90b5e46
7
- data.tar.gz: 2e795ce936734b464200cddadb6e88b4714201da40f667493ce78697ad3f79fdf8533847616bd93f1d6c4851b834e670aa865464d594fbab0e94763afd966518
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
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
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
@@ -1,4 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
data/README.md CHANGED
@@ -1,4 +1,3 @@
1
- [![CircleCI](https://circleci.com/gh/iarie/pwush/tree/master.svg?style=shield)](https://circleci.com/gh/iarie/pwush/tree/master)
2
1
  [![Gem Version](https://badge.fury.io/rb/pwush.svg)](https://badge.fury.io/rb/pwush)
3
2
  [![Maintainability](https://api.codeclimate.com/v1/badges/d1887381dee84e26e860/maintainability)](https://codeclimate.com/github/iarie/pwush/maintainability)
4
3
  [![Test Coverage](https://api.codeclimate.com/v1/badges/d1887381dee84e26e860/test_coverage)](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.1.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
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'pwush'
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pwush
4
+ module Api
5
+ module Applications
6
+ def applications
7
+ post(:getApplications)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -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
- Http.timeout(@config.timeout).request(verb, url, json: request.body)
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'.freeze
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(STDOUT)
17
+ @logger = options[:logger] || Logger.new($stdout)
16
18
  end
17
19
 
18
20
  attr_accessor :auth, :url, :app, :timeout, :logger