active-campaign-simple 0.2.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e56a728f497b1f0ff61f013d442a5e6439e80fb853f8bdb448526beedbf3a47
4
- data.tar.gz: 985056dd5a8e2b0df6a9e6922ca29991c050f20c680a2919909009ba1fd9db15
3
+ metadata.gz: db3cf95b6871dea9e9a64762a628f01498f6afec823eba660c3fc117691473ef
4
+ data.tar.gz: e65de428d99e04fe758e77aed2bdc606700b09ddad3f015185fa9e3fcc541431
5
5
  SHA512:
6
- metadata.gz: 29658c69085579ee47af003fcf4889b6659de669cbb7164a7ed8e8a50bf451f185174c1a3fcb94584e4ca47e3770f7bf734d48242eaa4a087b3af75af511021b
7
- data.tar.gz: dfc2da00c8c554628becd7b2e1c6a7125ccc4546acca8be5942849ca104a5be12274fb120d290af0f0f39f64b3c67134b19da99981b967d0c0e7e4ebc147a52a
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
- raise APIError, err
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/api_error'
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
- raise APIError, err
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
@@ -1,4 +1,4 @@
1
1
  module ActiveCampaign
2
2
  # The version of the gem
3
- VERSION = '0.2.1'.freeze unless defined?(::ActiveCampaign::VERSION)
3
+ VERSION = '0.3.3'.freeze unless defined?(::ActiveCampaign::VERSION)
4
4
  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.2.1
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: 2021-09-21 00:00:00.000000000 Z
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.2.22
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: []
@@ -1,11 +0,0 @@
1
- module ActiveCampaign
2
-
3
- class APIError < StandardError
4
- def initialize(msg)
5
- ActiveCampaign.api_logger.error "ERROR: #{msg}"
6
- super(msg)
7
- end
8
- end
9
-
10
- end
11
-