pusher-push-notifications 2.0.1 → 2.0.3
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/.coveralls.yml +1 -1
- data/.github/workflows/gh-release.yml +5 -5
- data/.github/workflows/publish.yml +1 -1
- data/.github/workflows/release.yml +1 -1
- data/.github/workflows/test.yml +4 -2
- data/.rubocop.yml +7 -4
- data/CHANGELOG.md +35 -25
- data/Gemfile.lock +53 -33
- data/README.md +1 -2
- data/lib/pusher/push_notifications/use_cases/delete_user.rb +3 -22
- data/lib/pusher/push_notifications/use_cases/generate_token.rb +4 -21
- data/lib/pusher/push_notifications/use_cases/publish.rb +8 -32
- data/lib/pusher/push_notifications/use_cases/publish_to_users.rb +2 -22
- data/lib/pusher/push_notifications/version.rb +1 -1
- data/lib/pusher/push_notifications.rb +26 -7
- data/pusher-push-notifications.gemspec +2 -2
- metadata +10 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38b02aaf3830201e5bd99343e628d43ef7737ebf9aaf518ff4f1fa571a3b1f8a
|
|
4
|
+
data.tar.gz: 886bcc12d73a1112fcd4a76a12b2c39c0a74f14649932948bbb2349b4d73b256
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12c7d7486b7479b53f648ae6f10a2034c7b6f238ed272e7853765945de5f4d4b9f7c366b953c338b87d5c376273a45bf35e2f2fc6ee7dfe5cb973fe09986444b
|
|
7
|
+
data.tar.gz: 64aa6d93318888fed90438300011609686eadef9fd4f1aa82e615f892b28429f5ba5ac67c27ee74d13bb1cfa69a5a0afded348916b0a9e94bec53f2aced9b9bd
|
data/.coveralls.yml
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
repo_token:
|
|
1
|
+
repo_token: secret
|
|
@@ -10,7 +10,7 @@ jobs:
|
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
12
12
|
- name: Checkout code
|
|
13
|
-
uses: actions/checkout@
|
|
13
|
+
uses: actions/checkout@v6
|
|
14
14
|
- name: Setup git
|
|
15
15
|
run: |
|
|
16
16
|
git config user.email "pusher-ci@pusher.com"
|
|
@@ -24,12 +24,12 @@ jobs:
|
|
|
24
24
|
export TAG=$(head -1 CHANGELOG.tmp | cut -d' ' -f2)
|
|
25
25
|
echo "TAG=$TAG" >> $GITHUB_ENV
|
|
26
26
|
- name: Create Release
|
|
27
|
-
uses:
|
|
28
|
-
env:
|
|
29
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
27
|
+
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3
|
|
30
28
|
with:
|
|
31
29
|
tag_name: ${{ env.TAG }}
|
|
32
|
-
|
|
30
|
+
name: ${{ env.TAG }}
|
|
33
31
|
body_path: CHANGELOG.tmp
|
|
34
32
|
draft: false
|
|
35
33
|
prerelease: false
|
|
34
|
+
env:
|
|
35
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -43,7 +43,7 @@ jobs:
|
|
|
43
43
|
export NEW_VERSION=$(semver bump ${{ env.RELEASE }} $CURRENT)
|
|
44
44
|
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
|
|
45
45
|
- name: Checkout code
|
|
46
|
-
uses: actions/checkout@
|
|
46
|
+
uses: actions/checkout@v6
|
|
47
47
|
- name: Setup git
|
|
48
48
|
run: |
|
|
49
49
|
git config user.email "pusher-ci@pusher.com"
|
data/.github/workflows/test.yml
CHANGED
|
@@ -12,14 +12,14 @@ jobs:
|
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
13
|
strategy:
|
|
14
14
|
matrix:
|
|
15
|
-
ruby-version: ['
|
|
15
|
+
ruby-version: ['3.3', '3.4']
|
|
16
16
|
|
|
17
17
|
env:
|
|
18
18
|
PUSHER_INSTANCE_ID: 1b880590-6301-4bb5-b34f-45db1c5f5644
|
|
19
19
|
PUSHER_SECRET_KEY: abc
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@v6
|
|
23
23
|
- name: Set up Ruby
|
|
24
24
|
uses: ruby/setup-ruby@v1
|
|
25
25
|
with:
|
|
@@ -29,3 +29,5 @@ jobs:
|
|
|
29
29
|
run: bundle exec rake
|
|
30
30
|
- name: Run rubocop
|
|
31
31
|
run: bundle exec rubocop
|
|
32
|
+
- name: Upload coverage to Codecov
|
|
33
|
+
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6
|
data/.rubocop.yml
CHANGED
|
@@ -2,15 +2,18 @@ Documentation:
|
|
|
2
2
|
Enabled: false
|
|
3
3
|
|
|
4
4
|
AllCops:
|
|
5
|
-
TargetRubyVersion:
|
|
5
|
+
TargetRubyVersion: 3.3
|
|
6
|
+
NewCops: disable
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Max: 80
|
|
8
|
+
Layout/LineLength:
|
|
9
|
+
Max: 120
|
|
10
10
|
|
|
11
11
|
Style/GuardClause:
|
|
12
12
|
Enabled: false
|
|
13
13
|
|
|
14
|
+
Style/IfUnlessModifier:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
14
17
|
Metrics/MethodLength:
|
|
15
18
|
Enabled: false
|
|
16
19
|
|
data/CHANGELOG.md
CHANGED
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 2.0.
|
|
4
|
-
|
|
3
|
+
## 2.0.3
|
|
4
|
+
|
|
5
|
+
* [FIXED] Ruby 3.4 compatibility
|
|
6
|
+
* [CHANGED] Widen JWT dependency constraint from ~> 2.1 to >= 2.1, < 4 to support jwt v3
|
|
7
|
+
* [REMOVED] Support for Ruby below 3.3
|
|
8
|
+
|
|
9
|
+
## 2.0.2
|
|
10
|
+
|
|
11
|
+
* [FIXED] Multiple Beams instances no longer use last configuration.
|
|
12
|
+
|
|
13
|
+
## 2.0.1
|
|
14
|
+
|
|
5
15
|
* [CHANGED] Update Gemfile lock on release.
|
|
6
|
-
|
|
7
|
-
## 2.0.0
|
|
8
|
-
|
|
16
|
+
|
|
17
|
+
## 2.0.0
|
|
18
|
+
|
|
9
19
|
* [ADDED] Support for Ruby 3.0.
|
|
10
20
|
* [REMOVED] Support for Ruby 2.5 and below.
|
|
11
21
|
* [CHANGED] Refactor tests to avoid caze dependency.
|
|
12
|
-
|
|
13
|
-
## 1.3.0
|
|
14
|
-
|
|
15
|
-
* [ADDED] Support for multiple instances of Beams clients to exist for more advanced use cases.
|
|
16
|
-
|
|
17
|
-
## 1.2.1
|
|
18
|
-
|
|
19
|
-
* [FIXED] Endpoint also allows the scheme to be configured to enable for local development.
|
|
20
|
-
|
|
21
|
-
## 1.2.0
|
|
22
|
-
|
|
23
|
-
* [ADDED] Support for "endpoint" overrides to allow for internal integration testing.
|
|
24
|
-
|
|
25
|
-
## 1.1.0
|
|
26
|
-
|
|
27
|
-
* [ADDED] Support for "Authenticated Users" feature: publishToUsers, generateToken and deleteUser.
|
|
28
|
-
|
|
29
|
-
## 1.0.0
|
|
30
|
-
|
|
31
|
-
* [ADDED] General availability (GA) release.
|
|
22
|
+
|
|
23
|
+
## 1.3.0
|
|
24
|
+
|
|
25
|
+
* [ADDED] Support for multiple instances of Beams clients to exist for more advanced use cases.
|
|
26
|
+
|
|
27
|
+
## 1.2.1
|
|
28
|
+
|
|
29
|
+
* [FIXED] Endpoint also allows the scheme to be configured to enable for local development.
|
|
30
|
+
|
|
31
|
+
## 1.2.0
|
|
32
|
+
|
|
33
|
+
* [ADDED] Support for "endpoint" overrides to allow for internal integration testing.
|
|
34
|
+
|
|
35
|
+
## 1.1.0
|
|
36
|
+
|
|
37
|
+
* [ADDED] Support for "Authenticated Users" feature: publishToUsers, generateToken and deleteUser.
|
|
38
|
+
|
|
39
|
+
## 1.0.0
|
|
40
|
+
|
|
41
|
+
* [ADDED] General availability (GA) release.
|
data/Gemfile.lock
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pusher-push-notifications (2.0.
|
|
5
|
-
jwt (
|
|
4
|
+
pusher-push-notifications (2.0.3)
|
|
5
|
+
jwt (>= 2.1, < 4)
|
|
6
6
|
rest-client (~> 2.0, >= 2.0.2)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
addressable (2.
|
|
12
|
-
public_suffix (>= 2.0.2, <
|
|
13
|
-
ast (2.4.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
addressable (2.9.0)
|
|
12
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
13
|
+
ast (2.4.3)
|
|
14
|
+
base64 (0.3.0)
|
|
15
|
+
bigdecimal (3.1.9)
|
|
16
|
+
byebug (13.0.0)
|
|
17
|
+
reline (>= 0.6.0)
|
|
18
|
+
codecov (0.2.12)
|
|
19
|
+
json
|
|
20
|
+
simplecov
|
|
17
21
|
coderay (1.1.3)
|
|
18
22
|
coveralls (0.8.23)
|
|
19
23
|
json (>= 1.8, < 3)
|
|
@@ -21,7 +25,8 @@ GEM
|
|
|
21
25
|
term-ansicolor (~> 1.3)
|
|
22
26
|
thor (>= 0.19.4, < 2.0)
|
|
23
27
|
tins (~> 1.6)
|
|
24
|
-
crack (0.
|
|
28
|
+
crack (1.0.1)
|
|
29
|
+
bigdecimal
|
|
25
30
|
rexml
|
|
26
31
|
diff-lcs (1.4.4)
|
|
27
32
|
docile (1.3.5)
|
|
@@ -32,33 +37,43 @@ GEM
|
|
|
32
37
|
http-accept (1.7.0)
|
|
33
38
|
http-cookie (1.0.3)
|
|
34
39
|
domain_name (~> 0.5)
|
|
40
|
+
io-console (0.8.2)
|
|
35
41
|
json (2.5.1)
|
|
36
|
-
jwt (
|
|
37
|
-
|
|
42
|
+
jwt (3.2.0)
|
|
43
|
+
base64
|
|
44
|
+
language_server-protocol (3.17.0.5)
|
|
45
|
+
lint_roller (1.1.0)
|
|
46
|
+
method_source (1.1.0)
|
|
38
47
|
mime-types (3.3.1)
|
|
39
48
|
mime-types-data (~> 3.2015)
|
|
40
49
|
mime-types-data (3.2021.0225)
|
|
41
50
|
netrc (0.11.0)
|
|
42
|
-
parallel (1.
|
|
43
|
-
parser (3.
|
|
51
|
+
parallel (2.1.0)
|
|
52
|
+
parser (3.3.11.1)
|
|
44
53
|
ast (~> 2.4.1)
|
|
45
|
-
|
|
54
|
+
racc
|
|
55
|
+
prism (1.9.0)
|
|
56
|
+
pry (0.16.0)
|
|
46
57
|
coderay (~> 1.1)
|
|
47
58
|
method_source (~> 1.0)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
reline (>= 0.6.0)
|
|
60
|
+
pry-byebug (3.12.0)
|
|
61
|
+
byebug (~> 13.0)
|
|
62
|
+
pry (>= 0.13, < 0.17)
|
|
63
|
+
public_suffix (4.0.7)
|
|
64
|
+
racc (1.8.1)
|
|
65
|
+
rainbow (3.1.1)
|
|
53
66
|
rake (13.0.3)
|
|
54
67
|
rb-readline (0.5.5)
|
|
55
|
-
regexp_parser (2.
|
|
68
|
+
regexp_parser (2.12.0)
|
|
69
|
+
reline (0.6.3)
|
|
70
|
+
io-console (~> 0.5)
|
|
56
71
|
rest-client (2.1.0)
|
|
57
72
|
http-accept (>= 1.7.0, < 2.0)
|
|
58
73
|
http-cookie (>= 1.0.2, < 2.0)
|
|
59
74
|
mime-types (>= 1.16, < 4.0)
|
|
60
75
|
netrc (~> 0.8)
|
|
61
|
-
rexml (3.
|
|
76
|
+
rexml (3.4.4)
|
|
62
77
|
rspec (3.10.0)
|
|
63
78
|
rspec-core (~> 3.10.0)
|
|
64
79
|
rspec-expectations (~> 3.10.0)
|
|
@@ -72,18 +87,21 @@ GEM
|
|
|
72
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
73
88
|
rspec-support (~> 3.10.0)
|
|
74
89
|
rspec-support (3.10.2)
|
|
75
|
-
rubocop (1.
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
rubocop (1.86.2)
|
|
91
|
+
json (~> 2.3)
|
|
92
|
+
language_server-protocol (~> 3.17.0.2)
|
|
93
|
+
lint_roller (~> 1.1.0)
|
|
94
|
+
parallel (>= 1.10)
|
|
95
|
+
parser (>= 3.3.0.2)
|
|
78
96
|
rainbow (>= 2.2.2, < 4.0)
|
|
79
|
-
regexp_parser (>=
|
|
80
|
-
|
|
81
|
-
rubocop-ast (>= 1.2.0, < 2.0)
|
|
97
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
98
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
82
99
|
ruby-progressbar (~> 1.7)
|
|
83
|
-
unicode-display_width (>=
|
|
84
|
-
rubocop-ast (1.
|
|
85
|
-
parser (>=
|
|
86
|
-
|
|
100
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
101
|
+
rubocop-ast (1.49.1)
|
|
102
|
+
parser (>= 3.3.7.2)
|
|
103
|
+
prism (~> 1.7)
|
|
104
|
+
ruby-progressbar (1.13.0)
|
|
87
105
|
simplecov (0.16.1)
|
|
88
106
|
docile (~> 1.1)
|
|
89
107
|
json (>= 1.8, < 3)
|
|
@@ -98,7 +116,9 @@ GEM
|
|
|
98
116
|
unf (0.1.4)
|
|
99
117
|
unf_ext
|
|
100
118
|
unf_ext (0.0.7.7)
|
|
101
|
-
unicode-display_width (2.0
|
|
119
|
+
unicode-display_width (3.2.0)
|
|
120
|
+
unicode-emoji (~> 4.1)
|
|
121
|
+
unicode-emoji (4.2.0)
|
|
102
122
|
vcr (3.0.3)
|
|
103
123
|
webmock (3.12.0)
|
|
104
124
|
addressable (>= 2.3.6)
|
|
@@ -123,4 +143,4 @@ DEPENDENCIES
|
|
|
123
143
|
webmock (~> 3.0, >= 3.0.1)
|
|
124
144
|
|
|
125
145
|
BUNDLED WITH
|
|
126
|
-
2.
|
|
146
|
+
2.4.22
|
data/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Pusher Beams Ruby Server SDK
|
|
2
2
|
|
|
3
|
-
[](https://coveralls.io/github/pusher/push-notifications-ruby?branch=update-sdk)
|
|
3
|
+
[](https://github.com/pusher/push-notifications-ruby/actions/workflows/test.yml) [](https://coveralls.io/github/pusher/push-notifications-ruby) [](https://rubygems.org/gems/pusher-push-notifications)
|
|
5
4
|
|
|
6
5
|
Pusher Beams using the Pusher system.
|
|
7
6
|
|
|
@@ -6,37 +6,18 @@ module Pusher
|
|
|
6
6
|
class DeleteUser
|
|
7
7
|
class UserDeletionError < RuntimeError; end
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def initialize(user:)
|
|
16
|
-
@user = user
|
|
17
|
-
@user_id = Pusher::PushNotifications::UserId.new
|
|
18
|
-
|
|
9
|
+
# Contacts the Beams service
|
|
10
|
+
# to remove all the devices of the given user.
|
|
11
|
+
def self.delete_user(client, user:)
|
|
19
12
|
raise UserDeletionError, 'User Id cannot be empty.' if user.empty?
|
|
20
13
|
|
|
21
14
|
if user.length > UserId::MAX_USER_ID_LENGTH
|
|
22
15
|
raise UserDeletionError, 'User id length too long ' \
|
|
23
16
|
"(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
|
|
24
17
|
end
|
|
25
|
-
end
|
|
26
18
|
|
|
27
|
-
# Contacts the Beams service
|
|
28
|
-
# to remove all the devices of the given user.
|
|
29
|
-
def delete_user
|
|
30
19
|
client.delete(user)
|
|
31
20
|
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
attr_reader :user
|
|
36
|
-
|
|
37
|
-
def client
|
|
38
|
-
@client ||= PushNotifications::Client.new
|
|
39
|
-
end
|
|
40
21
|
end
|
|
41
22
|
end
|
|
42
23
|
end
|
|
@@ -6,35 +6,18 @@ module Pusher
|
|
|
6
6
|
class GenerateToken
|
|
7
7
|
class GenerateTokenError < RuntimeError; end
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
new(*args, **kwargs).generate_token
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def initialize(user:)
|
|
16
|
-
@user = user
|
|
17
|
-
@user_id = Pusher::PushNotifications::UserId.new
|
|
18
|
-
|
|
9
|
+
# Creates a signed JWT for a user id.
|
|
10
|
+
def self.generate_token(user:)
|
|
19
11
|
raise GenerateTokenError, 'User Id cannot be empty.' if user.empty?
|
|
20
12
|
|
|
21
13
|
if user.length > UserId::MAX_USER_ID_LENGTH
|
|
22
14
|
raise GenerateTokenError, 'User id length too long ' \
|
|
23
15
|
"(expected fewer than #{UserId::MAX_USER_ID_LENGTH + 1} characters)"
|
|
24
16
|
end
|
|
25
|
-
end
|
|
26
17
|
|
|
27
|
-
|
|
28
|
-
def generate_token
|
|
29
|
-
{ 'token' => jwt_token.generate(user) }
|
|
30
|
-
end
|
|
18
|
+
jwt_token = PushNotifications::Token.new
|
|
31
19
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
attr_reader :user
|
|
35
|
-
|
|
36
|
-
def jwt_token
|
|
37
|
-
@jwt_token ||= PushNotifications::Token.new
|
|
20
|
+
{ 'token' => jwt_token.generate(user) }
|
|
38
21
|
end
|
|
39
22
|
end
|
|
40
23
|
end
|
|
@@ -6,21 +6,16 @@ module Pusher
|
|
|
6
6
|
class Publish
|
|
7
7
|
class PublishError < RuntimeError; end
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
new(*args, **kwargs).publish_to_interests
|
|
16
|
-
end
|
|
9
|
+
# Publish the given payload to the specified interests.
|
|
10
|
+
# <b>DEPRECATED:</b> Please use <tt>publish_to_interests</tt> instead.
|
|
11
|
+
def self.publish(client, interests:, payload: {})
|
|
12
|
+
warn "[DEPRECATION] `publish` is deprecated. \
|
|
13
|
+
Please use `publish_to_interests` instead."
|
|
14
|
+
publish_to_interests(client, interests: interests, payload: payload)
|
|
17
15
|
end
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@payload = payload
|
|
22
|
-
@user_id = Pusher::PushNotifications::UserId.new
|
|
23
|
-
|
|
17
|
+
# Publish the given payload to the specified interests.
|
|
18
|
+
def self.publish_to_interests(client, interests:, payload: {})
|
|
24
19
|
valid_interest_pattern = /^(_|-|=|@|,|\.|:|[A-Z]|[a-z]|[0-9])*$/
|
|
25
20
|
|
|
26
21
|
interests.each do |interest|
|
|
@@ -38,29 +33,10 @@ module Pusher
|
|
|
38
33
|
raise PublishError, "Number of interests #{interests.length}" \
|
|
39
34
|
' exceeds maximum of 100'
|
|
40
35
|
end
|
|
41
|
-
end
|
|
42
36
|
|
|
43
|
-
# Publish the given payload to the specified interests.
|
|
44
|
-
# <b>DEPRECATED:</b> Please use <tt>publish_to_interests</tt> instead.
|
|
45
|
-
def publish
|
|
46
|
-
warn "[DEPRECATION] `publish` is deprecated. \
|
|
47
|
-
Please use `publish_to_interests` instead."
|
|
48
|
-
publish_to_interests
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Publish the given payload to the specified interests.
|
|
52
|
-
def publish_to_interests
|
|
53
37
|
data = { interests: interests }.merge!(payload)
|
|
54
38
|
client.post('publishes', data)
|
|
55
39
|
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
|
|
59
|
-
attr_reader :interests, :payload
|
|
60
|
-
|
|
61
|
-
def client
|
|
62
|
-
@client ||= PushNotifications::Client.new
|
|
63
|
-
end
|
|
64
40
|
end
|
|
65
41
|
end
|
|
66
42
|
end
|
|
@@ -6,17 +6,8 @@ module Pusher
|
|
|
6
6
|
class PublishToUsers
|
|
7
7
|
class UsersPublishError < RuntimeError; end
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
new(*args, **kwargs).publish_to_users
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def initialize(users:, payload: {})
|
|
16
|
-
@users = users
|
|
17
|
-
@user_id = Pusher::PushNotifications::UserId.new
|
|
18
|
-
@payload = payload
|
|
19
|
-
|
|
9
|
+
# Publish the given payload to the specified users.
|
|
10
|
+
def self.publish_to_users(client, users:, payload: {})
|
|
20
11
|
users.each do |user|
|
|
21
12
|
raise UsersPublishError, 'User Id cannot be empty.' if user.empty?
|
|
22
13
|
|
|
@@ -33,21 +24,10 @@ module Pusher
|
|
|
33
24
|
raise UsersPublishError, "Number of user ids #{users.length} "\
|
|
34
25
|
"exceeds maximum of #{UserId::MAX_NUM_USER_IDS}."
|
|
35
26
|
end
|
|
36
|
-
end
|
|
37
27
|
|
|
38
|
-
# Publish the given payload to the specified users.
|
|
39
|
-
def publish_to_users
|
|
40
28
|
data = { users: users }.merge!(payload)
|
|
41
29
|
client.post('publishes/users', data)
|
|
42
30
|
end
|
|
43
|
-
|
|
44
|
-
private
|
|
45
|
-
|
|
46
|
-
attr_reader :users, :payload
|
|
47
|
-
|
|
48
|
-
def client
|
|
49
|
-
@client ||= PushNotifications::Client.new
|
|
50
|
-
end
|
|
51
31
|
end
|
|
52
32
|
end
|
|
53
33
|
end
|
|
@@ -14,15 +14,8 @@ module Pusher
|
|
|
14
14
|
class PushError < RuntimeError; end
|
|
15
15
|
|
|
16
16
|
class << self
|
|
17
|
-
extend Forwardable
|
|
18
|
-
|
|
19
17
|
attr_reader :instance_id, :secret_key
|
|
20
18
|
|
|
21
|
-
def_delegators UseCases::Publish, :publish, :publish_to_interests
|
|
22
|
-
def_delegators UseCases::PublishToUsers, :publish_to_users
|
|
23
|
-
def_delegators UseCases::DeleteUser, :delete_user
|
|
24
|
-
def_delegators UseCases::GenerateToken, :generate_token
|
|
25
|
-
|
|
26
19
|
def configure
|
|
27
20
|
yield(self)
|
|
28
21
|
# returning a duplicate of `self` to allow multiple clients to be
|
|
@@ -53,6 +46,32 @@ module Pusher
|
|
|
53
46
|
|
|
54
47
|
"https://#{@instance_id}.pushnotifications.pusher.com"
|
|
55
48
|
end
|
|
49
|
+
|
|
50
|
+
def publish(interests:, payload: {})
|
|
51
|
+
UseCases::Publish.publish(client, interests: interests, payload: payload)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def publish_to_interests(interests:, payload: {})
|
|
55
|
+
UseCases::Publish.publish_to_interests(client, interests: interests, payload: payload)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def publish_to_users(users:, payload: {})
|
|
59
|
+
UseCases::PublishToUsers.publish_to_users(client, users: users, payload: payload)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def delete_user(user:)
|
|
63
|
+
UseCases::DeleteUser.delete_user(client, user: user)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def generate_token(user:)
|
|
67
|
+
UseCases::GenerateToken.generate_token(user: user)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
def client
|
|
73
|
+
@client ||= Client.new(config: self)
|
|
74
|
+
end
|
|
56
75
|
end
|
|
57
76
|
end
|
|
58
77
|
end
|
|
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
5
5
|
require 'pusher/push_notifications/version'
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
|
-
spec.required_ruby_version = '>=
|
|
8
|
+
spec.required_ruby_version = '>= 3.3'
|
|
9
9
|
spec.name = 'pusher-push-notifications'
|
|
10
10
|
spec.version = Pusher::PushNotifications::VERSION
|
|
11
11
|
spec.authors = ['Lucas Medeiros', 'Pusher']
|
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = ['lib']
|
|
24
24
|
|
|
25
|
-
spec.add_dependency 'jwt', '
|
|
25
|
+
spec.add_dependency 'jwt', '>= 2.1', '< 4'
|
|
26
26
|
spec.add_dependency 'rest-client', '~> 2.0', '>= 2.0.2'
|
|
27
27
|
|
|
28
28
|
spec.add_development_dependency 'bundler', '~> 2.2'
|
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: 2.0.
|
|
4
|
+
version: 2.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lucas Medeiros
|
|
@@ -9,28 +9,28 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-05-28 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: jwt
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
requirements:
|
|
18
|
-
- - "
|
|
18
|
+
- - ">="
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
20
|
version: '2.1'
|
|
21
|
-
- - "
|
|
21
|
+
- - "<"
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version:
|
|
23
|
+
version: '4'
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
27
27
|
requirements:
|
|
28
|
-
- - "
|
|
28
|
+
- - ">="
|
|
29
29
|
- !ruby/object:Gem::Version
|
|
30
30
|
version: '2.1'
|
|
31
|
-
- - "
|
|
31
|
+
- - "<"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: '4'
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: rest-client
|
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -279,14 +279,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
279
279
|
requirements:
|
|
280
280
|
- - ">="
|
|
281
281
|
- !ruby/object:Gem::Version
|
|
282
|
-
version:
|
|
282
|
+
version: '3.3'
|
|
283
283
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
284
284
|
requirements:
|
|
285
285
|
- - ">="
|
|
286
286
|
- !ruby/object:Gem::Version
|
|
287
287
|
version: '0'
|
|
288
288
|
requirements: []
|
|
289
|
-
rubygems_version: 3.
|
|
289
|
+
rubygems_version: 3.4.20
|
|
290
290
|
signing_key:
|
|
291
291
|
specification_version: 4
|
|
292
292
|
summary: Pusher Push Notifications Ruby server SDK
|