active_campaign_wrapper 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_campaign_wrapper.rb +12 -5
- data/lib/active_campaign_wrapper/helpers.rb +20 -5
- data/lib/active_campaign_wrapper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a01f4281b5de081432bbaf0da09354d81f7ddbe869e84412ff814626328b9416
|
4
|
+
data.tar.gz: 8a77c02c292757bb1be2f53fe8fcaa07465400cb959cfc85e1025b7041797e97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3365e49ae4c44429254d3e1efea35a68b3593818931bf438117827b59aa3aade3ac982ce90f2bca797e4f560abd5deda80105a4176cc2abce3ca3a9e626dec41
|
7
|
+
data.tar.gz: fc94fb2186455e6377c43c607dbf3514f895d463b3fffe51f769326580cbfdb508a2504aceae08565594b977c60f647d4c1a2ddd12cd9e6246d829de9f3fe659
|
@@ -15,13 +15,20 @@ module ActiveCampaignWrapper
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
class Error < StandardError
|
18
|
+
class Error < StandardError
|
19
|
+
attr_accessor :response
|
19
20
|
|
20
|
-
|
21
|
+
def initialize(response)
|
22
|
+
super
|
23
|
+
@response = response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Forbidden < Error; end
|
21
28
|
|
22
|
-
class UnprocessableEntity <
|
29
|
+
class UnprocessableEntity < Error; end
|
23
30
|
|
24
|
-
class NotFound <
|
31
|
+
class NotFound < Error; end
|
25
32
|
|
26
|
-
class TooManyRequests <
|
33
|
+
class TooManyRequests < Error; end
|
27
34
|
end
|
@@ -7,11 +7,7 @@ module ActiveCampaignWrapper
|
|
7
7
|
module_function
|
8
8
|
|
9
9
|
def normalize_response(response)
|
10
|
-
|
11
|
-
raise ActiveCampaignWrapper::NotFound, response['message'] if response.not_found?
|
12
|
-
raise ActiveCampaignWrapper::UnprocessableEntity, response['errors']&.join(', ') || response['error'] if response.unprocessable_entity?
|
13
|
-
raise ActiveCampaignWrapper::TooManyRequests, response['message'] if response.too_many_requests?
|
14
|
-
raise ActiveCampaignWrapper::Error, response['message'] unless response.success?
|
10
|
+
handle_errors(response)
|
15
11
|
|
16
12
|
if response&.body.present?
|
17
13
|
transform_keys(response, [:underscore])
|
@@ -87,5 +83,24 @@ module ActiveCampaignWrapper
|
|
87
83
|
end
|
88
84
|
end
|
89
85
|
end
|
86
|
+
|
87
|
+
def handle_errors(response)
|
88
|
+
return if response.success?
|
89
|
+
|
90
|
+
class_name = if response.forbidden?
|
91
|
+
ActiveCampaignWrapper::Forbidden
|
92
|
+
elsif response.not_found?
|
93
|
+
ActiveCampaignWrapper::NotFound
|
94
|
+
elsif response.unprocessable_entity?
|
95
|
+
ActiveCampaignWrapper::UnprocessableEntity
|
96
|
+
elsif response.too_many_requests?
|
97
|
+
ActiveCampaignWrapper::TooManyRequests
|
98
|
+
else
|
99
|
+
ActiveCampaignWrapper::Error
|
100
|
+
end
|
101
|
+
raise class_name.new(response),
|
102
|
+
response['message'] || response['errors'].join(', ') || response['error'],
|
103
|
+
caller
|
104
|
+
end
|
90
105
|
end
|
91
106
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_campaign_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anmol Yousaf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|