zuora_api 0.2.7.1 → 0.2.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/zuora_api/exceptions.rb +37 -0
- data/lib/zuora_api/login.rb +16 -21
- data/lib/zuora_api/version.rb +1 -1
- data/lib/zuora_api.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f4eafeb52f39ee95d5a33e7caa504fc9e54d5d2
|
4
|
+
data.tar.gz: 922ec87b4c5cbeb927d0979dc78e424a78074314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f5b2f7be8fe8ed0940f7f26537873970d842a28feef557f0e6c0132e6197605ce567051dd8aa68c3505a2ecccfcb0a4bef578f3a94861e4abb356e9383942e5
|
7
|
+
data.tar.gz: 30c8a81a7c676258569cd3f85ad658c633622f5112374d84a50d27cd5a561e36ea99b6b9a430a70942966169b1fcba3810b010495ac39270bdc97d4eee9b1b30
|
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/zuora_api/login.rb
CHANGED
@@ -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}"
|
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
|
-
|
216
|
-
|
217
|
-
|
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
|
-
|
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
|
data/lib/zuora_api/version.rb
CHANGED
data/lib/zuora_api.rb
CHANGED
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.
|
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-
|
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
|