vaulted_billing 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,8 +4,10 @@ module VaultedBilling
4
4
  attr_accessor :raw_response
5
5
  attr_accessor :response_message
6
6
  attr_accessor :error_code
7
+ attr_writer :connection_error
7
8
  attr_writer :success
8
9
  def success?; @success; end
10
+ def connection_error?; @connection_error; end
9
11
  end
10
12
 
11
13
  def add_customer(customer)
@@ -242,6 +242,7 @@ module VaultedBilling
242
242
  def respond_with(object, result, options = {}, &block)
243
243
  super(object, options, &block).tap do |o|
244
244
  o.raw_response = result.raw_response.try(:body)
245
+ o.connection_error = result.connection_error
245
246
  o.response_message = result.body[result.body.keys.first]['messages']['message']['text']
246
247
 
247
248
  unless result.success?
@@ -179,11 +179,13 @@ module VaultedBilling
179
179
 
180
180
  def respond_with(object, response = nil, options = {}, &block)
181
181
  super(object, options, &block).tap do |o|
182
- o.raw_response = response.raw_response.try(:body) if response
183
- o.response_message = (response.try(:body) || {})['responsetext']
184
-
185
- if response && !response.success?
186
- o.error_code = (response.try(:body) || {})['response_code']
182
+ if response
183
+ o.raw_response = response.raw_response.try(:body)
184
+ o.connection_error = response.connection_error
185
+ o.response_message = (response.body || {})['responsetext']
186
+ unless response.success?
187
+ o.error_code = (response.body || {})['response_code']
188
+ end
187
189
  end
188
190
  end
189
191
  end
@@ -23,6 +23,7 @@ module VaultedBilling
23
23
  attr_accessor :body
24
24
  attr_accessor :success
25
25
  attr_accessor :raw_response
26
+ attr_accessor :connection_error
26
27
 
27
28
  def initialize(http_response)
28
29
  if http_response
@@ -31,6 +32,7 @@ module VaultedBilling
31
32
  self.message = http_response.message
32
33
  self.body = http_response.body
33
34
  self.success = ((http_response.code =~ /^2\d{2}/) == 0)
35
+ self.connection_error = false
34
36
  end
35
37
  end
36
38
 
@@ -87,6 +89,7 @@ module VaultedBilling
87
89
  PostResponse.new(nil).tap do |post_response|
88
90
  post_response.success = false
89
91
  post_response.message = "%s - %s" % [$!.class.name, $!.message]
92
+ post_response.connection_error = true
90
93
  after_post_caller(post_response)
91
94
  after_post_on_exception(post_response, $!)
92
95
  end
@@ -1,3 +1,3 @@
1
1
  module VaultedBilling
2
- Version = '0.0.8'
2
+ Version = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vaulted_billing
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nathaniel Bibler