active-campaign-simple 0.2.1 → 0.3.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/lib/active-campaign-simple/event.rb +3 -1
- data/lib/active-campaign-simple/exception_handler.rb +20 -0
- data/lib/active-campaign-simple/exceptions.rb +11 -0
- data/lib/active-campaign-simple/request.rb +2 -2
- data/lib/active-campaign-simple/version.rb +1 -1
- metadata +8 -7
- data/lib/active-campaign-simple/api_error.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db3cf95b6871dea9e9a64762a628f01498f6afec823eba660c3fc117691473ef
|
4
|
+
data.tar.gz: e65de428d99e04fe758e77aed2bdc606700b09ddad3f015185fa9e3fcc541431
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cc2ece8dd2e814dc26202a973e8527117463b96ba026c9ffe16207a51a5667d986a541024f083b1c9fe6dbafa990fcacd6cfe0af2cb045e483f808106b7a8ea
|
7
|
+
data.tar.gz: 1ccc820ab59101975480cf77cd84377421609dd5260a47973fa62a600a65015b50c1a99d48adced1a8cf52a17368f5d41b751ae2da7d91ef8fd3bc989fe20520
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active-campaign-simple/exception_handler'
|
2
|
+
|
1
3
|
module ActiveCampaign
|
2
4
|
class Event
|
3
5
|
|
@@ -16,7 +18,7 @@ module ActiveCampaign
|
|
16
18
|
|
17
19
|
resp = RestClient.post("https://trackcmp.net/event", form)
|
18
20
|
rescue RestClient::ExceptionWithResponse => err
|
19
|
-
|
21
|
+
ActiveCampaign::ExceptionHandler.new(err)
|
20
22
|
else
|
21
23
|
return resp.body if resp.body # Some calls respond w nothing
|
22
24
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'active-campaign-simple/exceptions'
|
2
|
+
|
3
|
+
module ActiveCampaign
|
4
|
+
class ExceptionHandler
|
5
|
+
|
6
|
+
ERRORS = {
|
7
|
+
'404 Not Found' => ActiveCampaign::NotFoundError
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize(error)
|
11
|
+
error_class = ERRORS[error.message]
|
12
|
+
if error_class
|
13
|
+
raise error_class.new(error)
|
14
|
+
else
|
15
|
+
raise ActiveCampaign::APIError.new(error)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ActiveCampaignAPIError < ::StandardError
|
2
|
+
def initialize(error)
|
3
|
+
ActiveCampaign.api_logger.error "ERROR: #{error}"
|
4
|
+
super(error)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module ActiveCampaign
|
9
|
+
class NotFoundError < ActiveCampaignAPIError; end
|
10
|
+
class APIError < ActiveCampaignAPIError; end
|
11
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rest-client'
|
2
|
-
require 'active-campaign-simple/
|
2
|
+
require 'active-campaign-simple/exception_handler'
|
3
3
|
require 'active-campaign-simple/event'
|
4
4
|
|
5
5
|
module ActiveCampaign
|
@@ -53,7 +53,7 @@ module ActiveCampaign
|
|
53
53
|
opts.merge!( { payload: payload.to_json }) unless payload.empty?
|
54
54
|
resp = RestClient::Request.execute(opts)
|
55
55
|
rescue RestClient::ExceptionWithResponse => err
|
56
|
-
|
56
|
+
ActiveCampaign::ExceptionHandler.new(err)
|
57
57
|
else
|
58
58
|
return JSON.parse(resp.body) if resp.body # Some calls respond w nothing
|
59
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-campaign-simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Leavitt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -51,10 +51,11 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- active-campaign-simple.gemspec
|
53
53
|
- lib/active-campaign-simple.rb
|
54
|
-
- lib/active-campaign-simple/api_error.rb
|
55
54
|
- lib/active-campaign-simple/client.rb
|
56
55
|
- lib/active-campaign-simple/config.rb
|
57
56
|
- lib/active-campaign-simple/event.rb
|
57
|
+
- lib/active-campaign-simple/exception_handler.rb
|
58
|
+
- lib/active-campaign-simple/exceptions.rb
|
58
59
|
- lib/active-campaign-simple/logger.rb
|
59
60
|
- lib/active-campaign-simple/request.rb
|
60
61
|
- lib/active-campaign-simple/version.rb
|
@@ -62,7 +63,7 @@ homepage: https://github.com/nateleavitt/active-campaign-simple
|
|
62
63
|
licenses:
|
63
64
|
- MIT
|
64
65
|
metadata: {}
|
65
|
-
post_install_message:
|
66
|
+
post_install_message:
|
66
67
|
rdoc_options: []
|
67
68
|
require_paths:
|
68
69
|
- lib
|
@@ -77,8 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: 3.0.0
|
79
80
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
81
|
-
signing_key:
|
81
|
+
rubygems_version: 3.3.3
|
82
|
+
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: Simple Ruby REST wrapper for the ActiveCampaign API
|
84
85
|
test_files: []
|