pusher-push-notifications 1.0.0 → 1.1.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/.rubocop.yml +11 -7
- data/.travis.yml +3 -0
- data/CHANGELOG.md +8 -2
- data/Gemfile +0 -2
- data/Gemfile.lock +20 -16
- data/README.md +14 -9
- data/bin/console +1 -1
- data/lib/pusher/push_notifications.rb +15 -2
- data/lib/pusher/push_notifications/client.rb +32 -7
- data/lib/pusher/push_notifications/token.rb +26 -0
- data/lib/pusher/push_notifications/use_cases/delete_user.rb +42 -0
- data/lib/pusher/push_notifications/use_cases/generate_token.rb +41 -0
- data/lib/pusher/push_notifications/use_cases/publish.rb +28 -10
- data/lib/pusher/push_notifications/use_cases/publish_to_users.rb +54 -0
- data/lib/pusher/push_notifications/user_id.rb +10 -0
- data/lib/pusher/push_notifications/version.rb +1 -1
- data/lib/{pusher-push-notifications.rb → pusher_push_notifications.rb} +0 -0
- data/pusher-push-notifications.gemspec +8 -6
- metadata +76 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad9f48448c40362a680daa49622e38fd91270cc
|
4
|
+
data.tar.gz: 158ea72c621de04521745b568f40f5c6fb8b088d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1da920d75d9a2a07dc36268233395f6df60a253681768386f4a27a223cc08d4c33563ca37a3342b86ef6c0bc8413a1cbee81a750482915989d56090c61a0f26
|
7
|
+
data.tar.gz: 6d029a5ea9f9b1b385e5e2ef228c613c64bea7fd5bb5fae83a76a0eaa930dc5fd131a871129883a915bf3d1990d5c253b5311f30410682f9872d548d08cf911f
|
data/.rubocop.yml
CHANGED
@@ -5,19 +5,23 @@ AllCops:
|
|
5
5
|
TargetRubyVersion: 2.4.0
|
6
6
|
|
7
7
|
Metrics/LineLength:
|
8
|
-
|
8
|
+
Enabled:
|
9
|
+
Max: 80
|
10
|
+
|
11
|
+
Style/GuardClause:
|
12
|
+
Enabled: false
|
9
13
|
|
10
14
|
Metrics/MethodLength:
|
11
|
-
|
12
|
-
- 'spec/**/*.rb'
|
15
|
+
Enabled: false
|
13
16
|
|
14
|
-
|
15
|
-
|
17
|
+
Metrics/AbcSize:
|
18
|
+
Enabled: false
|
16
19
|
|
17
20
|
Metrics/ModuleLength:
|
18
21
|
Exclude:
|
19
|
-
-
|
22
|
+
- "spec/**/*.rb"
|
20
23
|
|
21
24
|
Metrics/BlockLength:
|
22
25
|
Exclude:
|
23
|
-
-
|
26
|
+
- "spec/**/*.rb"
|
27
|
+
- "pusher-push-notifications.gemspec"
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,8 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## [Unreleased](https://github.com/pusher/push-notifications-ruby/compare/1.0
|
8
|
+
## [Unreleased](https://github.com/pusher/push-notifications-ruby/compare/v1.1.0...HEAD)
|
9
9
|
|
10
|
-
## [1.
|
10
|
+
## [1.1.0](https://github.com/pusher/push-notifications-ruby/compare/v1.0.0...v1.1.0) - 2019-02-22
|
11
|
+
|
12
|
+
Added
|
13
|
+
|
14
|
+
Support for "Authenticated Users" feature: publishToUsers, generateToken and deleteUser.
|
15
|
+
|
16
|
+
## [1.0.0](https://github.com/pusher/push-notifications-ruby/compare/v0.3.0...v1.0.0) - 2018-07-31
|
11
17
|
|
12
18
|
- General availability (GA) release.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pusher-push-notifications (1.
|
5
|
-
caze
|
6
|
-
|
4
|
+
pusher-push-notifications (1.1.0)
|
5
|
+
caze (~> 0)
|
6
|
+
jwt (~> 2.1, >= 2.1.0)
|
7
|
+
rest-client (~> 2.0, >= 2.0.2)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
|
-
activesupport (5.2.
|
12
|
+
activesupport (5.2.2)
|
12
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
14
|
i18n (>= 0.7, < 2)
|
14
15
|
minitest (~> 5.1)
|
@@ -16,7 +17,7 @@ GEM
|
|
16
17
|
addressable (2.5.2)
|
17
18
|
public_suffix (>= 2.0.2, < 4.0)
|
18
19
|
ast (2.3.0)
|
19
|
-
byebug (
|
20
|
+
byebug (10.0.2)
|
20
21
|
caze (0.2.2)
|
21
22
|
activesupport (>= 3)
|
22
23
|
codecov (0.1.10)
|
@@ -24,7 +25,7 @@ GEM
|
|
24
25
|
simplecov
|
25
26
|
url
|
26
27
|
coderay (1.1.2)
|
27
|
-
concurrent-ruby (1.
|
28
|
+
concurrent-ruby (1.1.4)
|
28
29
|
coveralls (0.8.21)
|
29
30
|
json (>= 1.8, < 3)
|
30
31
|
simplecov (~> 0.14.1)
|
@@ -41,28 +42,30 @@ GEM
|
|
41
42
|
hashdiff (0.3.7)
|
42
43
|
http-cookie (1.0.3)
|
43
44
|
domain_name (~> 0.5)
|
44
|
-
i18n (1.
|
45
|
+
i18n (1.5.3)
|
45
46
|
concurrent-ruby (~> 1.0)
|
46
47
|
json (2.1.0)
|
47
|
-
|
48
|
-
|
48
|
+
jwt (2.1.0)
|
49
|
+
method_source (0.9.2)
|
50
|
+
mime-types (3.2.2)
|
49
51
|
mime-types-data (~> 3.2015)
|
50
|
-
mime-types-data (3.
|
52
|
+
mime-types-data (3.2018.0812)
|
51
53
|
minitest (5.11.3)
|
52
54
|
netrc (0.11.0)
|
53
55
|
parallel (1.12.1)
|
54
56
|
parser (2.4.0.2)
|
55
57
|
ast (~> 2.3)
|
56
58
|
powerpack (0.1.1)
|
57
|
-
pry (0.
|
59
|
+
pry (0.12.2)
|
58
60
|
coderay (~> 1.1.0)
|
59
61
|
method_source (~> 0.9.0)
|
60
|
-
pry-byebug (3.
|
61
|
-
byebug (~>
|
62
|
+
pry-byebug (3.6.0)
|
63
|
+
byebug (~> 10.0)
|
62
64
|
pry (~> 0.10)
|
63
65
|
public_suffix (3.0.1)
|
64
66
|
rainbow (3.0.0)
|
65
67
|
rake (10.5.0)
|
68
|
+
rb-readline (0.5.5)
|
66
69
|
rest-client (2.0.2)
|
67
70
|
http-cookie (>= 1.0.2, < 2.0)
|
68
71
|
mime-types (>= 1.16, < 4.0)
|
@@ -117,14 +120,15 @@ PLATFORMS
|
|
117
120
|
|
118
121
|
DEPENDENCIES
|
119
122
|
bundler (~> 1.16)
|
120
|
-
codecov
|
123
|
+
codecov (~> 0)
|
121
124
|
coveralls (~> 0.8.21)
|
122
125
|
dotenv (~> 2.2, >= 2.2.1)
|
123
|
-
pry-byebug
|
126
|
+
pry-byebug (~> 3.6, >= 3.6.0)
|
124
127
|
pusher-push-notifications!
|
125
128
|
rake (~> 10.0)
|
129
|
+
rb-readline (~> 0)
|
126
130
|
rspec (~> 3.0)
|
127
|
-
rubocop
|
131
|
+
rubocop (~> 0)
|
128
132
|
vcr (~> 3.0, >= 3.0.3)
|
129
133
|
webmock (~> 3.0, >= 3.0.1)
|
130
134
|
|
data/README.md
CHANGED
@@ -35,6 +35,8 @@ Where `instance_id` and `secret_key` are the values of the instance you created
|
|
35
35
|
After the configuration is done you can push notifications like this:
|
36
36
|
|
37
37
|
```ruby
|
38
|
+
require 'pusher/push_notifications'
|
39
|
+
|
38
40
|
data = {
|
39
41
|
apns: {
|
40
42
|
aps: {
|
@@ -52,7 +54,17 @@ data = {
|
|
52
54
|
}
|
53
55
|
}
|
54
56
|
|
55
|
-
|
57
|
+
# Publish the given 'data' to the specified interests.
|
58
|
+
Pusher::PushNotifications.publish_to_interests(interests: ['hello'], payload: data)
|
59
|
+
|
60
|
+
# Publish the given 'data' to the specified users.
|
61
|
+
Pusher::PushNotifications.publish_to_users(users: ['jonathan', 'jordan', 'luis', 'luka', 'mina'], payload: data)
|
62
|
+
|
63
|
+
# Authenticate User
|
64
|
+
Pusher::PushNotifications.generate_token(user: 'Elmo')
|
65
|
+
|
66
|
+
# Delete User
|
67
|
+
Pusher::PushNotifications.delete_user(user: 'Elmo')
|
56
68
|
```
|
57
69
|
|
58
70
|
The return of this call is a ruby struct containing the http status code (`status`) the response body (`content`) and an `ok?` attribute saying if the notification was successful or not.
|
@@ -61,14 +73,7 @@ The return of this call is a ruby struct containing the http status code (`statu
|
|
61
73
|
|
62
74
|
## Errors
|
63
75
|
|
64
|
-
|
65
|
-
|
66
|
-
| HTTP Status | Reason |
|
67
|
-
| ----------- | --------------------------------------------------------------------------------------------- |
|
68
|
-
| 401 | Incorrect secret key |
|
69
|
-
| 400 | Payload too big (10Kb limit), Payload invalid, Payload in a wrong schema, instance_id missing |
|
70
|
-
| 404 | Instance not found |
|
71
|
-
| 500 | Internal server error |
|
76
|
+
All available error responses can be be found [here](https://docs.pusher.com/beams/reference/publish-api#error-responses).
|
72
77
|
|
73
78
|
## Development
|
74
79
|
|
data/bin/console
CHANGED
@@ -4,7 +4,12 @@ require 'caze'
|
|
4
4
|
|
5
5
|
require_relative './push_notifications/client'
|
6
6
|
require_relative './push_notifications/use_cases/publish'
|
7
|
+
require_relative './push_notifications/use_cases/publish_to_users'
|
8
|
+
require_relative './push_notifications/use_cases/delete_user'
|
9
|
+
require_relative './push_notifications/use_cases/generate_token'
|
7
10
|
require_relative './push_notifications/version'
|
11
|
+
require_relative './push_notifications/user_id'
|
12
|
+
require_relative './push_notifications/token'
|
8
13
|
|
9
14
|
module Pusher
|
10
15
|
module PushNotifications
|
@@ -13,6 +18,10 @@ module Pusher
|
|
13
18
|
class PushError < RuntimeError; end
|
14
19
|
|
15
20
|
has_use_case :publish, UseCases::Publish
|
21
|
+
has_use_case :publish_to_interests, UseCases::Publish
|
22
|
+
has_use_case :publish_to_users, UseCases::PublishToUsers
|
23
|
+
has_use_case :delete_user, UseCases::DeleteUser
|
24
|
+
has_use_case :generate_token, UseCases::GenerateToken
|
16
25
|
|
17
26
|
class << self
|
18
27
|
attr_reader :instance_id, :secret_key
|
@@ -23,12 +32,16 @@ module Pusher
|
|
23
32
|
end
|
24
33
|
|
25
34
|
def instance_id=(instance_id)
|
26
|
-
|
35
|
+
if instance_id.nil? || instance_id.delete(' ').empty?
|
36
|
+
raise PushError, 'Invalid instance id'
|
37
|
+
end
|
27
38
|
@instance_id = instance_id
|
28
39
|
end
|
29
40
|
|
30
41
|
def secret_key=(secret_key)
|
31
|
-
|
42
|
+
if secret_key.nil? || secret_key.delete(' ').empty?
|
43
|
+
raise PushError, 'Invalid secret key'
|
44
|
+
end
|
32
45
|
@secret_key = secret_key
|
33
46
|
end
|
34
47
|
end
|
@@ -9,8 +9,6 @@ module Pusher
|
|
9
9
|
class Client
|
10
10
|
extend Forwardable
|
11
11
|
|
12
|
-
BASE_URL = 'pushnotifications.pusher.com/publish_api/v1/instances'
|
13
|
-
|
14
12
|
Response = Struct.new(:status, :content, :ok?)
|
15
13
|
|
16
14
|
def initialize(config: PushNotifications)
|
@@ -18,7 +16,7 @@ module Pusher
|
|
18
16
|
end
|
19
17
|
|
20
18
|
def post(resource, payload = {})
|
21
|
-
url =
|
19
|
+
url = build_publish_url(resource)
|
22
20
|
body = payload.to_json
|
23
21
|
|
24
22
|
RestClient::Request.execute(
|
@@ -30,7 +28,25 @@ module Pusher
|
|
30
28
|
body = JSON.parse(response.body)
|
31
29
|
Response.new(status, body, status == 200)
|
32
30
|
else
|
33
|
-
Response.new(
|
31
|
+
Response.new(status, nil, false)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete(user)
|
37
|
+
url_encoded_user_id = CGI.escape(user)
|
38
|
+
url = build_users_url(url_encoded_user_id)
|
39
|
+
|
40
|
+
RestClient::Request.execute(
|
41
|
+
method: :delete, url: url,
|
42
|
+
headers: headers
|
43
|
+
) do |response|
|
44
|
+
status = response.code
|
45
|
+
case status
|
46
|
+
when 200
|
47
|
+
Response.new(status, nil, true)
|
48
|
+
else
|
49
|
+
Response.new(status, nil, false)
|
34
50
|
end
|
35
51
|
end
|
36
52
|
end
|
@@ -40,15 +56,24 @@ module Pusher
|
|
40
56
|
attr_reader :config
|
41
57
|
def_delegators :@config, :instance_id, :secret_key
|
42
58
|
|
43
|
-
def
|
44
|
-
"https://#{instance_id}
|
59
|
+
def build_publish_url(resource)
|
60
|
+
"https://#{instance_id}.pushnotifications.pusher.com/" \
|
61
|
+
"publish_api/v1/instances/#{instance_id}/#{resource}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def build_users_url(user)
|
65
|
+
"https://#{instance_id}.pushnotifications.pusher.com/" \
|
66
|
+
"customer_api/v1/instances/#{instance_id}/users/#{user}"
|
45
67
|
end
|
46
68
|
|
47
69
|
def headers
|
48
70
|
{
|
49
71
|
content_type: 'application/json',
|
50
72
|
accept: :json,
|
51
|
-
Authorization: "Bearer #{secret_key}"
|
73
|
+
Authorization: "Bearer #{secret_key}",
|
74
|
+
'X-Pusher-Library':
|
75
|
+
'pusher-push-notifications-ruby ' \
|
76
|
+
"#{Pusher::PushNotifications::VERSION}"
|
52
77
|
}
|
53
78
|
end
|
54
79
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jwt'
|
4
|
+
|
5
|
+
module Pusher
|
6
|
+
module PushNotifications
|
7
|
+
class Token
|
8
|
+
extend Forwardable
|
9
|
+
def initialize(config: PushNotifications)
|
10
|
+
@config = config
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate(user)
|
14
|
+
exp = Time.now.to_i + 24 * 60 * 60 # Current time + 24h
|
15
|
+
iss = "https://#{instance_id}.pushnotifications.pusher.com"
|
16
|
+
payload = { 'sub' => user, 'exp' => exp, 'iss' => iss }
|
17
|
+
JWT.encode payload, secret_key, 'HS256'
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :config
|
23
|
+
def_delegators :@config, :instance_id, :secret_key
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'caze'
|
4
|
+
|
5
|
+
module Pusher
|
6
|
+
module PushNotifications
|
7
|
+
module UseCases
|
8
|
+
class DeleteUser
|
9
|
+
include Caze
|
10
|
+
|
11
|
+
class UserDeletionError < RuntimeError; end
|
12
|
+
|
13
|
+
export :delete_user, as: :delete_user
|
14
|
+
|
15
|
+
def initialize(user:)
|
16
|
+
@user = user
|
17
|
+
@user_id = Pusher::PushNotifications::UserId.new
|
18
|
+
|
19
|
+
raise UserDeletionError, 'User Id cannot be empty.' if user.empty?
|
20
|
+
if user.length > UserId::MAX_USER_ID_LENGTH
|
21
|
+
raise UserDeletionError, 'User id length too long ' \
|
22
|
+
"(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Contacts the Beams service
|
27
|
+
# to remove all the devices of the given user.
|
28
|
+
def delete_user
|
29
|
+
client.delete(user)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :user
|
35
|
+
|
36
|
+
def client
|
37
|
+
@client ||= PushNotifications::Client.new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'caze'
|
4
|
+
|
5
|
+
module Pusher
|
6
|
+
module PushNotifications
|
7
|
+
module UseCases
|
8
|
+
class GenerateToken
|
9
|
+
include Caze
|
10
|
+
|
11
|
+
class GenerateTokenError < RuntimeError; end
|
12
|
+
|
13
|
+
export :generate_token, as: :generate_token
|
14
|
+
|
15
|
+
def initialize(user:)
|
16
|
+
@user = user
|
17
|
+
@user_id = Pusher::PushNotifications::UserId.new
|
18
|
+
|
19
|
+
raise GenerateTokenError, 'User Id cannot be empty.' if user.empty?
|
20
|
+
if user.length > UserId::MAX_USER_ID_LENGTH
|
21
|
+
raise GenerateTokenError, 'User id length too long ' \
|
22
|
+
"(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Creates a signed JWT for a user id.
|
27
|
+
def generate_token
|
28
|
+
{ 'token' => jwt_token.generate(user) }
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :user
|
34
|
+
|
35
|
+
def jwt_token
|
36
|
+
@jwt_token ||= PushNotifications::Token.new
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -10,25 +10,43 @@ module Pusher
|
|
10
10
|
|
11
11
|
class PublishError < RuntimeError; end
|
12
12
|
|
13
|
-
export :
|
13
|
+
export :publish, as: :publish
|
14
|
+
export :publish_to_interests, as: :publish_to_interests
|
14
15
|
|
15
16
|
def initialize(interests:, payload: {})
|
17
|
+
@interests = interests
|
18
|
+
@payload = payload
|
19
|
+
@user_id = Pusher::PushNotifications::UserId.new
|
20
|
+
|
16
21
|
valid_interest_pattern = /^(_|\-|=|@|,|\.|:|[A-Z]|[a-z]|[0-9])*$/
|
17
22
|
|
18
23
|
interests.each do |interest|
|
19
|
-
if
|
20
|
-
|
21
|
-
|
24
|
+
next if valid_interest_pattern.match?(interest)
|
25
|
+
raise PublishError,
|
26
|
+
"Invalid interest name \nMax #{UserId::MAX_USER_ID_LENGTH}" \
|
27
|
+
' characters and can only contain ASCII upper/lower-case' \
|
28
|
+
' letters, numbers or one of _-=@,.:'
|
22
29
|
end
|
23
30
|
|
24
|
-
|
25
|
-
|
31
|
+
if interests.empty?
|
32
|
+
raise PublishError, 'Must provide at least one interest'
|
33
|
+
end
|
34
|
+
if interests.length > 100
|
35
|
+
raise PublishError, "Number of interests #{interests.length}" \
|
36
|
+
' exceeds maximum of 100'
|
37
|
+
end
|
38
|
+
end
|
26
39
|
|
27
|
-
|
28
|
-
|
40
|
+
# Publish the given payload to the specified interests.
|
41
|
+
# <b>DEPRECATED:</b> Please use <tt>publish_to_interests</tt> instead.
|
42
|
+
def publish
|
43
|
+
warn "[DEPRECATION] `publish` is deprecated. \
|
44
|
+
Please use `publish_to_interests` instead."
|
45
|
+
publish_to_interests
|
29
46
|
end
|
30
47
|
|
31
|
-
|
48
|
+
# Publish the given payload to the specified interests.
|
49
|
+
def publish_to_interests
|
32
50
|
data = { interests: interests }.merge!(payload)
|
33
51
|
client.post('publishes', data)
|
34
52
|
end
|
@@ -38,7 +56,7 @@ module Pusher
|
|
38
56
|
attr_reader :interests, :payload
|
39
57
|
|
40
58
|
def client
|
41
|
-
@
|
59
|
+
@client ||= PushNotifications::Client.new
|
42
60
|
end
|
43
61
|
end
|
44
62
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'caze'
|
4
|
+
|
5
|
+
module Pusher
|
6
|
+
module PushNotifications
|
7
|
+
module UseCases
|
8
|
+
class PublishToUsers
|
9
|
+
include Caze
|
10
|
+
|
11
|
+
class UsersPublishError < RuntimeError; end
|
12
|
+
|
13
|
+
export :publish_to_users, as: :publish_to_users
|
14
|
+
|
15
|
+
def initialize(users:, payload: {})
|
16
|
+
@users = users
|
17
|
+
@user_id = Pusher::PushNotifications::UserId.new
|
18
|
+
@payload = payload
|
19
|
+
|
20
|
+
users.each do |user|
|
21
|
+
raise UsersPublishError, 'User Id cannot be empty.' if user.empty?
|
22
|
+
|
23
|
+
next unless user.length > UserId::MAX_USER_ID_LENGTH
|
24
|
+
raise UsersPublishError, 'User id length too long ' \
|
25
|
+
"(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1}" \
|
26
|
+
' characters)'
|
27
|
+
end
|
28
|
+
|
29
|
+
if users.count < 1
|
30
|
+
raise UsersPublishError, 'Must supply at least one user id.'
|
31
|
+
end
|
32
|
+
if users.length > UserId::MAX_NUM_USER_IDS
|
33
|
+
raise UsersPublishError, "Number of user ids #{users.length} "\
|
34
|
+
"exceeds maximum of #{UserId::MAX_NUM_USER_IDS}."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Publish the given payload to the specified users.
|
39
|
+
def publish_to_users
|
40
|
+
data = { users: users }.merge!(payload)
|
41
|
+
client.post('publishes/users', data)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
attr_reader :users, :payload
|
47
|
+
|
48
|
+
def client
|
49
|
+
@client ||= PushNotifications::Client.new
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
File without changes
|
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
5
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
5
|
require 'pusher/push_notifications/version'
|
7
6
|
|
@@ -22,16 +21,19 @@ Gem::Specification.new do |spec|
|
|
22
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
22
|
spec.require_paths = ['lib']
|
24
23
|
|
25
|
-
spec.add_dependency 'caze'
|
26
|
-
spec.add_dependency '
|
24
|
+
spec.add_dependency 'caze', '~> 0'
|
25
|
+
spec.add_dependency 'jwt', '~> 2.1', '>= 2.1.0'
|
26
|
+
spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.2'
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
29
|
+
spec.add_development_dependency 'codecov', '~> 0'
|
29
30
|
spec.add_development_dependency 'coveralls', '~> 0.8.21'
|
30
31
|
spec.add_development_dependency 'dotenv', '~> 2.2', '>= 2.2.1'
|
31
|
-
spec.add_development_dependency 'pry-byebug'
|
32
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.6', '>= 3.6.0'
|
32
33
|
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'rb-readline', '~> 0'
|
33
35
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
-
spec.add_development_dependency 'rubocop'
|
36
|
+
spec.add_development_dependency 'rubocop', '~> 0'
|
35
37
|
spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
|
36
38
|
spec.add_development_dependency 'webmock', '~> 3.0', '>= 3.0.1'
|
37
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher-push-notifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Medeiros
|
@@ -9,36 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: caze
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: jwt
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.1'
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.1.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - "~>"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '2.1'
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.1.0
|
28
48
|
- !ruby/object:Gem::Dependency
|
29
49
|
name: rest-client
|
30
50
|
requirement: !ruby/object:Gem::Requirement
|
31
51
|
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
32
55
|
- - ">="
|
33
56
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
57
|
+
version: 2.0.2
|
35
58
|
type: :runtime
|
36
59
|
prerelease: false
|
37
60
|
version_requirements: !ruby/object:Gem::Requirement
|
38
61
|
requirements:
|
62
|
+
- - "~>"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '2.0'
|
39
65
|
- - ">="
|
40
66
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
67
|
+
version: 2.0.2
|
42
68
|
- !ruby/object:Gem::Dependency
|
43
69
|
name: bundler
|
44
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,6 +79,20 @@ dependencies:
|
|
53
79
|
- - "~>"
|
54
80
|
- !ruby/object:Gem::Version
|
55
81
|
version: '1.16'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: codecov
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
56
96
|
- !ruby/object:Gem::Dependency
|
57
97
|
name: coveralls
|
58
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,16 +131,22 @@ dependencies:
|
|
91
131
|
name: pry-byebug
|
92
132
|
requirement: !ruby/object:Gem::Requirement
|
93
133
|
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '3.6'
|
94
137
|
- - ">="
|
95
138
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
139
|
+
version: 3.6.0
|
97
140
|
type: :development
|
98
141
|
prerelease: false
|
99
142
|
version_requirements: !ruby/object:Gem::Requirement
|
100
143
|
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '3.6'
|
101
147
|
- - ">="
|
102
148
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
149
|
+
version: 3.6.0
|
104
150
|
- !ruby/object:Gem::Dependency
|
105
151
|
name: rake
|
106
152
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,6 +161,20 @@ dependencies:
|
|
115
161
|
- - "~>"
|
116
162
|
- !ruby/object:Gem::Version
|
117
163
|
version: '10.0'
|
164
|
+
- !ruby/object:Gem::Dependency
|
165
|
+
name: rb-readline
|
166
|
+
requirement: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - "~>"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
type: :development
|
172
|
+
prerelease: false
|
173
|
+
version_requirements: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - "~>"
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
118
178
|
- !ruby/object:Gem::Dependency
|
119
179
|
name: rspec
|
120
180
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,14 +193,14 @@ dependencies:
|
|
133
193
|
name: rubocop
|
134
194
|
requirement: !ruby/object:Gem::Requirement
|
135
195
|
requirements:
|
136
|
-
- - "
|
196
|
+
- - "~>"
|
137
197
|
- !ruby/object:Gem::Version
|
138
198
|
version: '0'
|
139
199
|
type: :development
|
140
200
|
prerelease: false
|
141
201
|
version_requirements: !ruby/object:Gem::Requirement
|
142
202
|
requirements:
|
143
|
-
- - "
|
203
|
+
- - "~>"
|
144
204
|
- !ruby/object:Gem::Version
|
145
205
|
version: '0'
|
146
206
|
- !ruby/object:Gem::Dependency
|
@@ -205,11 +265,16 @@ files:
|
|
205
265
|
- Rakefile
|
206
266
|
- bin/console
|
207
267
|
- bin/setup
|
208
|
-
- lib/pusher-push-notifications.rb
|
209
268
|
- lib/pusher/push_notifications.rb
|
210
269
|
- lib/pusher/push_notifications/client.rb
|
270
|
+
- lib/pusher/push_notifications/token.rb
|
271
|
+
- lib/pusher/push_notifications/use_cases/delete_user.rb
|
272
|
+
- lib/pusher/push_notifications/use_cases/generate_token.rb
|
211
273
|
- lib/pusher/push_notifications/use_cases/publish.rb
|
274
|
+
- lib/pusher/push_notifications/use_cases/publish_to_users.rb
|
275
|
+
- lib/pusher/push_notifications/user_id.rb
|
212
276
|
- lib/pusher/push_notifications/version.rb
|
277
|
+
- lib/pusher_push_notifications.rb
|
213
278
|
- pusher-push-notifications.gemspec
|
214
279
|
homepage: https://github.com/pusher/push-notifications-ruby
|
215
280
|
licenses:
|