zuora_api 0.2.7.1 → 0.2.7.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e861be8997030565b43cf09a909a0daf0e54fb3
4
- data.tar.gz: e26feda4866af5ed05a6ea487b027c99b9558c7a
3
+ metadata.gz: 6f4eafeb52f39ee95d5a33e7caa504fc9e54d5d2
4
+ data.tar.gz: 922ec87b4c5cbeb927d0979dc78e424a78074314
5
5
  SHA512:
6
- metadata.gz: bd903fb7babf044e18581ea1c8b6449bad68bb60af1cb2b2e6324c32f0884fb3b12eae5f64ea974a3a45df7bacfe068fbcacb76c73a01ebacc3e1011a3e68f3d
7
- data.tar.gz: ff98abec36239a83a5769bd2afbf1b51857327824fcb8608eaa7538cd3bf26fa75277fc6dc57127b32d6db05fd821ea092868096db48569242d3c26805257ae7
6
+ metadata.gz: 6f5b2f7be8fe8ed0940f7f26537873970d842a28feef557f0e6c0132e6197605ce567051dd8aa68c3505a2ecccfcb0a4bef578f3a94861e4abb356e9383942e5
7
+ data.tar.gz: 30c8a81a7c676258569cd3f85ad658c633622f5112374d84a50d27cd5a561e36ea99b6b9a430a70942966169b1fcba3810b010495ac39270bdc97d4eee9b1b30
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zuora_api (0.2.7.1)
4
+ zuora_api (0.2.7.2)
5
5
  httparty
6
6
  nokogiri (~> 1.6.8)
7
7
  railties (>= 4.1.0, < 5.1)
@@ -0,0 +1,37 @@
1
+ module ZuoraAPI
2
+ module Exceptions
3
+ class Error < StandardError; end
4
+ class AuthorizationNotPerformed < Error; end
5
+
6
+ class ZuoraAPISessionError < Error
7
+ attr_reader :code, :response
8
+ attr_writer :default_message
9
+
10
+ def initialize(message = nil)
11
+ @message = message
12
+ @default_message = "Error with Zuora Session."
13
+ end
14
+
15
+ def to_s
16
+ @message || @default_message
17
+ end
18
+ end
19
+
20
+ class ZuoraAPIError < Error
21
+ attr_reader :code, :response
22
+ attr_writer :default_message
23
+
24
+ def initialize(message = nil,response=nil, code =nil)
25
+ @code = code
26
+ @message = message
27
+ @response = response
28
+ @default_message = "Error communicating with Zuora."
29
+ end
30
+
31
+ def to_s
32
+ @message || @default_message
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -169,7 +169,7 @@ module ZuoraAPI
169
169
  def get_session
170
170
  Rails.logger.debug("Create new session") if self.current_session.blank?
171
171
  self.new_session if self.current_session.blank?
172
- raise self.current_error if self.status != 'Active'
172
+ raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error) if self.status != 'Active'
173
173
  return self.current_session
174
174
  end
175
175
 
@@ -208,29 +208,24 @@ module ZuoraAPI
208
208
  response = HTTParty.post(self.url,:body => xml.doc.to_xml, :headers => {'Content-Type' => "text/xml; charset=utf-8"}, :timeout => 10)
209
209
  output_xml = Nokogiri::XML(response.body)
210
210
  Rails.logger.debug('Connect') {"Response SOAP XML: #{output_xml.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip}"} if debug
211
- raise "#{output_xml.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text}::#{output_xml.xpath('//fns:FaultMessage', 'fns' =>'http://fault.api.zuora.com/').text}" if !output_xml.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text.blank?
212
- raise "#{output_xml.xpath('//faultcode').text}::#{output_xml.xpath('//faultstring').text}" if !output_xml.xpath('//faultcode').text.blank?
213
- rescue => ex
211
+ raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{output_xml.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text}::#{output_xml.xpath('//fns:FaultMessage', 'fns' =>'http://fault.api.zuora.com/').text}") if !output_xml.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text.blank?
212
+ raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{output_xml.xpath('//faultcode').text}::#{output_xml.xpath('//faultstring').text}") if !output_xml.xpath('//faultcode').text.blank?
213
+ rescue ZuoraAPI::Exceptions::ZuoraAPISessionError => ex
214
214
  if !(tries -= 1).zero?
215
- case ex.to_s.split("::")[0]
216
- when "INVALID_SESSION"
217
- Rails.logger.debug {"Session Invalid"}
218
- self.new_session
219
- retry
220
- else
221
- if debug
222
- raise ex
223
- else
224
- return [output_xml, input_xml]
225
- end
226
- end
215
+ Rails.logger.debug {"Session Invalid"}
216
+ self.new_session
217
+ retry
227
218
  else
228
- if debug
229
- raise ex
230
- else
231
- return [output_xml, input_xml]
232
- end
219
+ raise ex
233
220
  end
221
+ rescue ZuoraAPI::Exceptions::ZuoraAPIError => ex
222
+ if debug
223
+ raise ex
224
+ else
225
+ return [output_xml, input_xml]
226
+ end
227
+ rescue => ex
228
+ raise ex
234
229
  else
235
230
  return [output_xml, input_xml]
236
231
  end
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "0.2.7.1"
2
+ VERSION = "0.2.7.2"
3
3
  end
data/lib/zuora_api.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rails'
2
2
 
3
3
  require "zuora_api/login"
4
+ require 'zuora_api/exceptions'
4
5
  module ZuoraAPI
5
6
  # Your code goes here...
6
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7.1
4
+ version: 0.2.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zuora Strategic Solutions Group
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-22 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,6 +131,7 @@ files:
131
131
  - bin/console
132
132
  - bin/setup
133
133
  - lib/zuora_api.rb
134
+ - lib/zuora_api/exceptions.rb
134
135
  - lib/zuora_api/login.rb
135
136
  - lib/zuora_api/version.rb
136
137
  - zuora_api.gemspec