notification-pusher-onesignal 1.2.6 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f08266986a6dc29a38160e40a7538758ebbe7af2daa5b39b9c9b49d01cc9830
4
- data.tar.gz: d24373b5c9bd0a6c0c572a855a24cc432861ecb0c09cad16d8183e5f511af81a
3
+ metadata.gz: 5e0d569e256c162ee1e9ec709b2a324a6371da9dda921377ffb8221edcbe4e9f
4
+ data.tar.gz: b228cbdeacaf05e420b4ae32774703f654f4d64f53810d57aa80529a071c017f
5
5
  SHA512:
6
- metadata.gz: 667cd4e33e746c5000cb42326a97261d1994580e31cbe3b1b0d0fd303628d74e86fa5d563e56ec792fed8d1d3616482d6befd3b2b6e539487eeb40857af56c10
7
- data.tar.gz: 21041e057e0e104b6c011dcad2e4b9d019a69ff2cf197599168ead6fe8ede1ee760aff7e3d4ca4f845d4123595e11fc71405f57d77754dd86ada74df8c867820
6
+ metadata.gz: 236b9a2b53d1547a0316b386e3cbe975b13bc641e551bb2a61168685810850cb6d4d8ac63e08f31bcaa57b9740ac57ea04bfedccb0a5a3b53d72047dd569689f
7
+ data.tar.gz: 51a5fadd33ca0e67d92136741cc8a2da7751ae7275cf645aa2a99cfdfdfa502f23fc572ee2c08557c8e3c86b40f797f9e50821ca009b73ee9abb7dfafb40b582
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # NotificationPusher for OneSignal
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/notification-pusher-onesignal.svg)](https://badge.fury.io/rb/notification-pusher-onesignal) <img src="https://travis-ci.org/jonhue/notifications-rails.svg?branch=master" />
3
+ [![Gem Version](https://badge.fury.io/rb/notification-pusher-onesignal.svg)](https://badge.fury.io/rb/notification-pusher-onesignal) ![Travis](https://travis-ci.com/jonhue/notifications-rails.svg?branch=master)
4
4
 
5
5
  A pusher to send cross-platform notifications with OneSignal.
6
6
 
@@ -10,12 +10,10 @@ A pusher to send cross-platform notifications with OneSignal.
10
10
 
11
11
  * [Installation](#installation)
12
12
  * [Usage](#usage)
13
- * [Options](#options)
13
+ * [Options](#options)
14
14
  * [To Do](#to-do)
15
15
  * [Contributing](#contributing)
16
- * [Contributors](#contributors)
17
- * [Semantic versioning](#semantic-versioning)
18
- * [License](#license)
16
+ * [Semantic versioning](#semantic-versioning)
19
17
 
20
18
  ---
21
19
 
@@ -35,48 +33,42 @@ Or install it yourself as:
35
33
 
36
34
  $ gem install notification-pusher-onesignal
37
35
 
38
- If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
39
-
40
- ```ruby
41
- gem 'notification-pusher-onesignal', github: 'jonhue/notifications-rails'
42
- ```
43
-
44
36
  ---
45
37
 
46
38
  ## Usage
47
39
 
48
- Define this pusher in your `NotificationPusher` configuration:
40
+ Register this delivery method in your `NotificationPusher` configuration:
49
41
 
50
42
  ```ruby
51
43
  NotificationPusher.configure do |config|
52
-    config.define_pusher :OneSignal, app_id: 'f158a844-9f3c-4207-b246-e93603b0a970', auth_key: 'kODc3N2ItOTNC00NGzOGYtMzI5OWQ3ZmQ'
44
+ config.register_delivery_method :one_signal, :OneSignal, app_id: 'f158a844-9f3c-4207-b246-e93603b0a970', auth_key: 'kODc3N2ItOTNC00NGzOGYtMzI5OWQ3ZmQ'
53
45
  end
54
46
  ```
55
47
 
56
- Now you can push your notifications to OneSignal:
48
+ Now you can deliver your notifications through OneSignal:
57
49
 
58
50
  ```ruby
59
- notification = Notification.create target: User.first, object: Recipe.first
60
- notification.push :OneSignal, player_ids: ['f158a844-9f3c-4207-b246-e93603b0a970'], url: Rails.application.routes.url_helpers.root_url, contents: {
61
-    en: notification.object.title
62
- }
51
+ notification = Notification.create(target: User.first, object: Recipe.first)
52
+ notification.deliver(:one_signal, player_ids: ['f158a844-9f3c-4207-b246-e93603b0a970'], url: Rails.application.routes.url_helpers.root_url, contents: {
53
+ en: notification.object.title
54
+ })
63
55
  ```
64
56
 
65
- To get player id's you could use the [devise-onesignal](https://github.com/jonhue/devise-onesignal) gem. This is how that would look:
57
+ To get player id's you could use the [OnSignal](https://github.com/jonhue/onsignal-rails) gem. This is how that would look:
66
58
 
67
59
  ```ruby
68
- notification.push :OneSignal, player_ids: notification.target.onesignal_player_ids
60
+ notification.deliver(:one_signal, player_ids: notification.target.onesignal_player_ids)
69
61
  ```
70
62
 
71
63
  You can also store OneSignal information in your notification opposed to specifying it when pushing:
72
64
 
73
65
  ```ruby
74
- notification.metadata[:onesignal_url] = Rails.application.routes.url_helpers.root_url
66
+ notification.metadata[:onesignal_url] = Rails.application.routes.url_helpers.root_url
75
67
  notification.metadata[:onesignal_contents] = { en: 'My notification content' }
76
68
  notification.metadata[:onesignal_headings] = { en: 'My notification header' }
77
69
  notification.metadata[:onesignal_subtitle] = { en: 'My notification subtitle' }
78
- notification.save
79
- notification.push :OneSignal, player_ids: notification.target.onesignal_player_ids
70
+ notification.save!
71
+ notification.deliver(:one_signal, player_ids: notification.target.onesignal_player_ids)
80
72
  ```
81
73
 
82
74
 
@@ -100,7 +92,7 @@ notification.push :OneSignal, player_ids: notification.target.onesignal_player_i
100
92
 
101
93
  ## To Do
102
94
 
103
- [Here](https://github.com/jonhue/notifications-rails/projects/7) is the full list of current projects.
95
+ We use [GitHub projects](https://github.com/jonhue/notifications-rails/projects/7) to coordinate the work on this project.
104
96
 
105
97
  To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/notifications-rails/issues/new).
106
98
 
@@ -112,36 +104,6 @@ We hope that you will consider contributing to NotificationPusher for OneSignal.
112
104
 
113
105
  [Learn more about contributing to this repository](https://github.com/jonhue/notifications-rails/blob/master/CONTRIBUTING.md), [Code of Conduct](https://github.com/jonhue/notifications-rails/blob/master/CODE_OF_CONDUCT.md)
114
106
 
115
- ### Contributors
116
-
117
- Give the people some :heart: who are working on this project. See them all at:
118
-
119
- https://github.com/jonhue/notifications-rails/graphs/contributors
120
-
121
107
  ### Semantic Versioning
122
108
 
123
109
  NotificationPusher for OneSignal follows Semantic Versioning 2.0 as defined at http://semver.org.
124
-
125
- ## License
126
-
127
- MIT License
128
-
129
- Copyright (c) 2017 Jonas Hübotter
130
-
131
- Permission is hereby granted, free of charge, to any person obtaining a copy
132
- of this software and associated documentation files (the "Software"), to deal
133
- in the Software without restriction, including without limitation the rights
134
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
135
- copies of the Software, and to permit persons to whom the Software is
136
- furnished to do so, subject to the following conditions:
137
-
138
- The above copyright notice and this permission notice shall be included in all
139
- copies or substantial portions of the Software.
140
-
141
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
142
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
143
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
144
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
145
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
146
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
147
- SOFTWARE.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'one_signal'
3
4
  require 'notification-pusher'
4
- require 'notification_pusher/one_signal'
5
+ require_relative 'notification_pusher/delivery_method/one_signal'
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NotificationPusher
4
+ module DeliveryMethod
5
+ class OneSignal < NotificationPusher::DeliveryMethod::Base
6
+ def call
7
+ return unless options[:player_ids].any?
8
+
9
+ ::OneSignal::Notification.create params: {
10
+ app_id: options[:app_id],
11
+ url: url_param,
12
+ contents: contents_param,
13
+ headings: headings_param,
14
+ subtitle: subtitle_param,
15
+ include_player_ids: options[:player_ids]
16
+ }, opts: { auth_key: options[:auth_key] }
17
+ end
18
+
19
+ private
20
+
21
+ def url_param
22
+ options[:url] || notification.metadata[:onesignal_url].to_h
23
+ end
24
+
25
+ def contents_param
26
+ options[:contents] || notification.metadata[:onesignal_contents].to_h
27
+ end
28
+
29
+ def headings_param
30
+ options[:headings] || notification.metadata[:onesignal_headings].to_h
31
+ end
32
+
33
+ def subtitle_param
34
+ options[:subtitle] || notification.metadata[:onesignal_subtitle].to_h
35
+ end
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notification-pusher-onesignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-22 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: notification-pusher
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.6
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.6
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: one_signal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,49 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: factory_bot
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
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
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
87
  - - ">="
@@ -80,6 +122,20 @@ dependencies:
80
122
  - - ">="
81
123
  - !ruby/object:Gem::Version
82
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: sqlite3
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
83
139
  description: A pusher to send cross-platform notifications with OneSignal.
84
140
  email: me@jonhue.me
85
141
  executables: []
@@ -89,7 +145,7 @@ files:
89
145
  - LICENSE
90
146
  - README.md
91
147
  - lib/notification-pusher-onesignal.rb
92
- - lib/notification_pusher/one_signal.rb
148
+ - lib/notification_pusher/delivery_method/one_signal.rb
93
149
  homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-pusher/notification-pusher-onesignal
94
150
  licenses:
95
151
  - MIT
@@ -109,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
165
  - !ruby/object:Gem::Version
110
166
  version: '0'
111
167
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.6
168
+ rubygems_version: 3.0.3
114
169
  signing_key:
115
170
  specification_version: 4
116
171
  summary: A pusher to send cross-platform notifications with OneSignal
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'one_signal'
4
-
5
- module NotificationPusher
6
- class OneSignal
7
- def initialize(notification, options = {})
8
- return unless options[:player_ids].any?
9
-
10
- ::OneSignal::Notification.create params: {
11
- app_id: options[:app_id],
12
- url: url_param(options[:url], notification),
13
- contents: contents_param(options[:contents], notification),
14
- headings: headings_param(options[:headings], notification),
15
- subtitle: subtitle_param(options[:subtitle], notification),
16
- include_player_ids: options[:player_ids]
17
- }, opts: { auth_key: options[:auth_key] }
18
- end
19
-
20
- private
21
-
22
- def url_param(url, notification)
23
- url || notification.metadata[:onesignal_url].to_h
24
- end
25
-
26
- def contents_param(contents, notification)
27
- contents || notification.metadata[:onesignal_contents].to_h
28
- end
29
-
30
- def headings_param(headings, notification)
31
- headings || notification.metadata[:onesignal_headings].to_h
32
- end
33
-
34
- def subtitle_param(subtitle, notification)
35
- subtitle || notification.metadata[:onesignal_subtitle].to_h
36
- end
37
- end
38
- end