webhook_manager 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -10
- data/lib/webhook_manager.rb +19 -4
- data/lib/webhook_manager/version.rb +1 -1
- data/webhook_manager.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ce69b03b9534faf7a15f2f617ddcc5aef0022ab30330aeb8ec87a7f4528ea66
|
4
|
+
data.tar.gz: 8c48b9e482fa8f807729d87b28c7bfda7c5e2cc92e123788604e4ee63afcb2c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 000c1f9b47ad3a13f3c9ac40561e33778d2fc4fa87b2dce1cd11043aa268a0cd143388bd132aff107d86cc6430c08199752549ae7d00ace294fa6af3be3fc2c6
|
7
|
+
data.tar.gz: 1addfda4ef719f8a9b28e2daeadcf35632899dd79602d0b96216c8fe393e9f77b156ba983d52c2fdece71fa6e3c03909b4be61c41e22e89e5c1ed6c9cba059a8
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
webhook_manager (0.1.
|
5
|
-
faraday (
|
4
|
+
webhook_manager (0.1.1)
|
5
|
+
faraday (~> 0.17.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -10,9 +10,8 @@ GEM
|
|
10
10
|
ast (2.4.1)
|
11
11
|
coderay (1.1.3)
|
12
12
|
diff-lcs (1.4.4)
|
13
|
-
faraday (
|
13
|
+
faraday (0.17.3)
|
14
14
|
multipart-post (>= 1.2, < 3)
|
15
|
-
ruby2_keywords
|
16
15
|
method_source (1.0.0)
|
17
16
|
multipart-post (2.1.1)
|
18
17
|
parallel (1.20.1)
|
@@ -23,21 +22,21 @@ GEM
|
|
23
22
|
method_source (~> 1.0)
|
24
23
|
rainbow (3.0.0)
|
25
24
|
rake (13.0.3)
|
26
|
-
regexp_parser (2.0.
|
25
|
+
regexp_parser (2.0.3)
|
27
26
|
rexml (3.2.4)
|
28
27
|
rspec (3.10.0)
|
29
28
|
rspec-core (~> 3.10.0)
|
30
29
|
rspec-expectations (~> 3.10.0)
|
31
30
|
rspec-mocks (~> 3.10.0)
|
32
|
-
rspec-core (3.10.
|
31
|
+
rspec-core (3.10.1)
|
33
32
|
rspec-support (~> 3.10.0)
|
34
|
-
rspec-expectations (3.10.
|
33
|
+
rspec-expectations (3.10.1)
|
35
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
36
35
|
rspec-support (~> 3.10.0)
|
37
|
-
rspec-mocks (3.10.
|
36
|
+
rspec-mocks (3.10.1)
|
38
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
38
|
rspec-support (~> 3.10.0)
|
40
|
-
rspec-support (3.10.
|
39
|
+
rspec-support (3.10.1)
|
41
40
|
rubocop (1.7.0)
|
42
41
|
parallel (~> 1.10)
|
43
42
|
parser (>= 2.7.1.5)
|
@@ -50,7 +49,6 @@ GEM
|
|
50
49
|
rubocop-ast (1.3.0)
|
51
50
|
parser (>= 2.7.1.5)
|
52
51
|
ruby-progressbar (1.10.1)
|
53
|
-
ruby2_keywords (0.0.2)
|
54
52
|
unicode-display_width (1.7.0)
|
55
53
|
|
56
54
|
PLATFORMS
|
data/lib/webhook_manager.rb
CHANGED
@@ -22,13 +22,25 @@ module WebhookManager
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def trigger!(event_name:, payload:)
|
25
|
-
|
25
|
+
begin
|
26
|
+
res = @conn.post("webhook_events/trigger", { event_name: event_name, event_payload: payload }.to_json)
|
27
|
+
rescue Faraday::ConnectionFailed => e
|
28
|
+
raise Error.new("Could not connect to API")
|
29
|
+
rescue Faraday::TimeoutError => e
|
30
|
+
raise Error.new("Time out error")
|
31
|
+
end
|
26
32
|
|
27
33
|
handle_reponse(res)
|
28
34
|
end
|
29
35
|
|
30
36
|
def update_status(event_id:, status:)
|
31
|
-
|
37
|
+
begin
|
38
|
+
res = @conn.post("webhook_events/update_status", { event_id: event_id, status: status }.to_json)
|
39
|
+
rescue Faraday::ConnectionFailed => e
|
40
|
+
raise Error.new("Could not connect to API")
|
41
|
+
rescue Faraday::TimeoutError => e
|
42
|
+
raise Error.new("Time out error")
|
43
|
+
end
|
32
44
|
|
33
45
|
handle_reponse(res)
|
34
46
|
end
|
@@ -39,11 +51,14 @@ module WebhookManager
|
|
39
51
|
if res.status == 200
|
40
52
|
data = JSON.parse(res.body)
|
41
53
|
|
42
|
-
|
54
|
+
case data["status"]
|
55
|
+
when "ERROR"
|
43
56
|
raise "Something went wrong: #{data["errors"].join(", ")}"
|
44
|
-
|
57
|
+
when "OK"
|
45
58
|
true
|
46
59
|
end
|
60
|
+
elsif res.status == 401
|
61
|
+
raise Error.new("Unauthorized access to the API!")
|
47
62
|
else
|
48
63
|
raise Error.new("Something went wrong calling the hooky API!")
|
49
64
|
end
|
data/webhook_manager.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
32
|
# Uncomment to register a new dependency of your gem
|
33
|
-
spec.add_dependency "faraday", "
|
33
|
+
spec.add_dependency "faraday", "~> 0.17.3"
|
34
34
|
spec.add_development_dependency "pry"
|
35
35
|
|
36
36
|
# For more information and examples about making a new gem, checkout our
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webhook_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luay Bseiso
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.17.3
|
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:
|
26
|
+
version: 0.17.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|