bmc 1.1.0 → 1.2.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/CHANGELOG.md +3 -0
- data/lib/bmc/engine.rb +0 -1
- data/lib/bmc/version.rb +1 -1
- metadata +6 -8
- data/app/libs/bmc/fcm/notifier.rb +0 -32
- data/app/libs/bmc/fcm/request.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9a6a356266f81ad7eb8ea4a4854057b183396375fa8eb0440dc5994e0ba619a
|
4
|
+
data.tar.gz: 7abd6a5c91201a3c34fd0e56014a19767a6113f55d8865da4d2c6ed79747a9b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3b50c4e23f67f61f8b9fcbf09af737459b0c5e2aacd97fccc76935b1cac3acecbe388cd630dbe24df11ef15ead5eef6a2f574af98e118e08b561247a7eff392
|
7
|
+
data.tar.gz: 2739cc1504180bf2ecb05609d90c788e80142cb3986fa6939853ec9c108d12563fb21443b7f715f271d742699a5d14ab827ec4ff80bc47086394064c9884a1d2
|
data/CHANGELOG.md
CHANGED
data/lib/bmc/engine.rb
CHANGED
data/lib/bmc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Benoit MARTIN-CHAVE
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -150,8 +150,6 @@ files:
|
|
150
150
|
- app/jobs/bmc/application_job.rb
|
151
151
|
- app/jobs/concerns/bmc/setup_job_concern.rb
|
152
152
|
- app/libs/bmc/collection_update.rb
|
153
|
-
- app/libs/bmc/fcm/notifier.rb
|
154
|
-
- app/libs/bmc/fcm/request.rb
|
155
153
|
- app/libs/bmc/mini_model_serializer/serialize.rb
|
156
154
|
- app/libs/bmc/mini_model_serializer/serializer.rb
|
157
155
|
- app/libs/bmc/monkey.rb
|
@@ -215,7 +213,7 @@ homepage: https://gitlab.benoitmc.com/pub/bmc
|
|
215
213
|
licenses:
|
216
214
|
- MIT
|
217
215
|
metadata: {}
|
218
|
-
post_install_message:
|
216
|
+
post_install_message:
|
219
217
|
rdoc_options: []
|
220
218
|
require_paths:
|
221
219
|
- lib
|
@@ -231,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
229
|
version: '0'
|
232
230
|
requirements: []
|
233
231
|
rubygems_version: 3.1.6
|
234
|
-
signing_key:
|
232
|
+
signing_key:
|
235
233
|
specification_version: 4
|
236
234
|
summary: BMC
|
237
235
|
test_files: []
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class BMC::FCM::Notifier
|
2
|
-
attr_reader :to, :title, :body, :badge, :sound, :data
|
3
|
-
|
4
|
-
# rubocop:disable Metrics/ParameterLists
|
5
|
-
def initialize(to:, title: nil, body:, badge: 0, sound: "default", data: {})
|
6
|
-
super()
|
7
|
-
@to = to
|
8
|
-
@title = title
|
9
|
-
@body = body
|
10
|
-
@badge = badge
|
11
|
-
@sound = sound
|
12
|
-
@data = data
|
13
|
-
end
|
14
|
-
# rubocop:enable Metrics/ParameterLists
|
15
|
-
|
16
|
-
def call
|
17
|
-
BMC::FCM::Request.call(
|
18
|
-
:to => to,
|
19
|
-
:notification => {
|
20
|
-
:title => title,
|
21
|
-
:body => body,
|
22
|
-
:badge => badge,
|
23
|
-
:sound => sound,
|
24
|
-
},
|
25
|
-
:data => data,
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.call(...)
|
30
|
-
new(...).call
|
31
|
-
end
|
32
|
-
end
|
data/app/libs/bmc/fcm/request.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
class BMC::FCM::Request
|
2
|
-
extend AttrExtras.mixin
|
3
|
-
|
4
|
-
URL = "https://fcm.googleapis.com/fcm/send"
|
5
|
-
|
6
|
-
class << self
|
7
|
-
attr_writer :api_key
|
8
|
-
|
9
|
-
def api_key
|
10
|
-
@api_key ||= ENV["FCM_API_KEY"]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_reader_initialize :request_body
|
15
|
-
|
16
|
-
attr_reader :response_json
|
17
|
-
|
18
|
-
def self.call(...)
|
19
|
-
new(...).call
|
20
|
-
end
|
21
|
-
|
22
|
-
def call
|
23
|
-
response_body = HTTParty.post(URL,
|
24
|
-
:body => request_body.to_json,
|
25
|
-
:headers => {
|
26
|
-
"Content-Type" => "application/json",
|
27
|
-
"Authorization" => "key=#{self.class.api_key}",
|
28
|
-
},
|
29
|
-
).body
|
30
|
-
|
31
|
-
@response_json = JSON.parse(response_body).deep_symbolize_keys
|
32
|
-
|
33
|
-
self
|
34
|
-
rescue JSON::ParserError
|
35
|
-
@response_json = {success: 0, failure: 1, results: [{:error => "InvalidJsonResponse"}]}
|
36
|
-
self
|
37
|
-
end
|
38
|
-
|
39
|
-
def ok?
|
40
|
-
response_json[:success].positive? && response_json[:failure].zero?
|
41
|
-
end
|
42
|
-
|
43
|
-
def error?
|
44
|
-
!ok?
|
45
|
-
end
|
46
|
-
|
47
|
-
def errors
|
48
|
-
response_json[:results].pluck(:error).compact
|
49
|
-
end
|
50
|
-
|
51
|
-
def invalid_token?
|
52
|
-
errors.include?("NotRegistered") || errors.include?("InvalidRegistration")
|
53
|
-
end
|
54
|
-
end
|