active_campaign 0.1.8 → 0.1.9

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
  SHA1:
3
- metadata.gz: b53439d6a5d5498289c5e34017767cdaee91edae
4
- data.tar.gz: dd9aa787e9b3e2cf75ac084b84e1222cc3384f61
3
+ metadata.gz: 773816e174638b5fa75102b031ac13ed726e9112
4
+ data.tar.gz: 005d17ce9301bcadb204018be4154fb9990916ab
5
5
  SHA512:
6
- metadata.gz: 0be8d353d7a2f4615e96a2f09b44ff59dda01a1d26ff0b0f8a76b6c3cacd4aefbf18eef927a55feffce43d0ab700174e3f435a326260968aa72a45311a2acb45
7
- data.tar.gz: e0fd6a9567d57fb1498e8417ff3a6bc9008306b80835cc06b62bf210fdcc4b729aa02416018b0253aa0c64d7ecb58dfc8e696c8f80eec8acd2a63d1ff65579fa
6
+ metadata.gz: 4facfd3b06ece6db14864a65124cb96e8fe73bd670544bdef32ff0f07982de5ce37ef6d78f48a6b37f83e6f8d11d4817d9b729f0e2c3aa6f09fe659a79c5ccde
7
+ data.tar.gz: 640e94884732f0f66605c9777b29b1356d16d3178d4d699f7b6b572f2c4ba9a42ebf78a3a02da071cbce0afaae14003960d5bae35cbad8331764f212dc3aa913
data/.gitignore CHANGED
@@ -18,4 +18,5 @@ tmp
18
18
 
19
19
  .DS_Store
20
20
  .idea
21
- /.ruby-version
21
+ /.ruby-version
22
+ .watsonrc
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0-p247
1
+ 2.1.0
data/Gemfile CHANGED
@@ -16,8 +16,8 @@ group :test do
16
16
  gem 'coveralls', require: false
17
17
  gem 'rb-fsevent', '~> 0.9'
18
18
  gem 'rspec', '~> 2.14.0'
19
- gem 'vcr', '~> 2.6.0'
20
- gem 'webmock', '~> 1.13.0'
19
+ gem 'vcr', '~> 2.8.0'
20
+ gem 'webmock', '~> 1.15.0'
21
21
  end
22
22
 
23
23
  gemspec
@@ -57,10 +57,12 @@ module ActiveCampaign
57
57
 
58
58
 
59
59
  def create_request(method, api_method, options = {})
60
- request = HTTPI::Request.new :url => File.join(api_endpoint, api_path)
61
- request.headers = {"User-Agent" => user_agent}
62
- request.query = query(method, api_method, options)
63
- request.body = body(method, api_method, options)
60
+ request = HTTPI::Request.new url: File.join(api_endpoint, api_path)
61
+
62
+ request.headers = { "User-Agent" => user_agent }
63
+ request.auth.ssl.verify_mode = :none
64
+ request.query = query(method, api_method, options)
65
+ request.body = body(method, api_method, options)
64
66
 
65
67
  request
66
68
  end
@@ -42,19 +42,21 @@ module ActiveCampaign
42
42
  private
43
43
 
44
44
  def data
45
- @data ||=
46
- if (body = @response[:body]) && !body.empty?
47
- if body.is_a?(String) &&
48
- @response[:response_headers] &&
49
- @response[:response_headers][:content_type] =~ /json/
50
-
51
- Sawyer::Agent.serializer.decode(body)
52
- else
53
- body
54
- end
55
- else
56
- nil
57
- end
45
+ @data ||= parse_body
46
+ end
47
+
48
+ def parse_body
49
+ body = @response[:body]
50
+
51
+ if body.present? && body.is_a?(String)
52
+ return Sawyer::Agent.serializer.decode(body) if is_json?
53
+ end
54
+
55
+ body
56
+ end
57
+
58
+ def is_json?
59
+ @response[:response_headers] && @response[:response_headers][:content_type] =~ /json/
58
60
  end
59
61
 
60
62
  def response_message
@@ -94,41 +96,41 @@ module ActiveCampaign
94
96
  end
95
97
  end
96
98
 
97
- # Raised when GitHub returns a 400 HTTP status code
99
+ # Raised when ActiveCampaign returns a 400 HTTP status code
98
100
  class BadRequest < Error; end
99
101
 
100
- # Raised when GitHub returns a 401 HTTP status code
102
+ # Raised when ActiveCampaign returns a 401 HTTP status code
101
103
  class Unauthorized < Error; end
102
104
 
103
- # Raised when GitHub returns a 403 HTTP status code
105
+ # Raised when ActiveCampaign returns a 403 HTTP status code
104
106
  class Forbidden < Error; end
105
107
 
106
- # Raised when GitHub returns a 403 HTTP status code
108
+ # Raised when ActiveCampaign returns a 403 HTTP status code
107
109
  # and body matches 'rate limit exceeded'
108
110
  class TooManyRequests < Forbidden; end
109
111
 
110
- # Raised when GitHub returns a 403 HTTP status code
112
+ # Raised when ActiveCampaign returns a 403 HTTP status code
111
113
  # and body matches 'login attempts exceeded'
112
114
  class TooManyLoginAttempts < Forbidden; end
113
115
 
114
- # Raised when GitHub returns a 404 HTTP status code
116
+ # Raised when ActiveCampaign returns a 404 HTTP status code
115
117
  class NotFound < Error; end
116
118
 
117
- # Raised when GitHub returns a 406 HTTP status code
119
+ # Raised when ActiveCampaign returns a 406 HTTP status code
118
120
  class NotAcceptable < Error; end
119
121
 
120
- # Raised when GitHub returns a 422 HTTP status code
122
+ # Raised when ActiveCampaign returns a 422 HTTP status code
121
123
  class UnprocessableEntity < Error; end
122
124
 
123
- # Raised when GitHub returns a 500 HTTP status code
125
+ # Raised when ActiveCampaign returns a 500 HTTP status code
124
126
  class InternalServerError < Error; end
125
127
 
126
- # Raised when GitHub returns a 501 HTTP status code
128
+ # Raised when ActiveCampaign returns a 501 HTTP status code
127
129
  class NotImplemented < Error; end
128
130
 
129
- # Raised when GitHub returns a 502 HTTP status code
131
+ # Raised when ActiveCampaign returns a 502 HTTP status code
130
132
  class BadGateway < Error; end
131
133
 
132
- # Raised when GitHub returns a 503 HTTP status code
134
+ # Raised when ActiveCampaign returns a 503 HTTP status code
133
135
  class ServiceUnavailable < Error; end
134
136
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveCampaign
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -41,7 +41,7 @@ VCR.configure do |c|
41
41
 
42
42
  c.default_cassette_options = {
43
43
  serialize_with: :json,
44
- # TODO: Track down UTF-8 issue and remove
44
+
45
45
  preserve_exact_body_bytes: true,
46
46
  decode_compressed_response: true,
47
47
  record: ENV['CI'] ? :none : :once
@@ -61,14 +61,14 @@ end
61
61
 
62
62
  def initialize_new_client
63
63
  before do
64
- @client = ActiveCampaign::Client.new({
64
+ @client = ActiveCampaign::Client.new(
65
65
  mash: true,
66
66
  debug: true,
67
67
  api_endpoint: test_api_endpoint,
68
68
  api_key: test_api_key,
69
69
  log_level: :debug,
70
70
  log: true
71
- })
71
+ )
72
72
  end
73
73
  end
74
74
 
metadata CHANGED
@@ -1,22 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_campaign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-06 00:00:00.000000000 Z
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- prerelease: false
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
14
  name: httpi
21
15
  requirement: !ruby/object:Gem::Requirement
22
16
  requirements:
@@ -24,13 +18,13 @@ dependencies:
24
18
  - !ruby/object:Gem::Version
25
19
  version: '0'
26
20
  type: :runtime
27
- - !ruby/object:Gem::Dependency
28
21
  prerelease: false
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
24
  - - ">="
32
25
  - !ruby/object:Gem::Version
33
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
34
28
  name: hashie
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
@@ -38,6 +32,12 @@ dependencies:
38
32
  - !ruby/object:Gem::Version
39
33
  version: '0'
40
34
  type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
41
  description: A simple ruby wrapper for the ActiveCampaign API
42
42
  email:
43
43
  - mikael@zoolutions.se
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.1.5
101
+ rubygems_version: 2.2.0.rc.1
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: See http://www.activecampaign.com/api/overview.php for more information