zuora_api 1.3.9993 → 1.3.9994
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 +4 -4
- data/.gitlab-ci.yml +1 -2
- data/lib/zuora_api/login.rb +80 -30
- data/lib/zuora_api/version.rb +1 -1
- data/zuora_api.gemspec +2 -0
- metadata +30 -3
- data/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb771efe44918a884178a46340720e08717a0e35
|
4
|
+
data.tar.gz: 0d22b870b2ed2543d57fed05f0ac56cc16636b98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65e01572cf4210b43f4718aecd47d62952204b33e5a8772d1a2764913129326e1097cadbdb30fd1e004ecea52873f9596860cae091459114a596e42d5a32b771
|
7
|
+
data.tar.gz: acef40f0eaac21596127aea716f321bf7b99d17f61a13cd81340e4fc68f8d8e612dfbb20f9416fb94d071af71d171c3cfcd71de4157d7335192c0ab12116f665
|
data/.gitlab-ci.yml
CHANGED
data/lib/zuora_api/login.rb
CHANGED
@@ -5,7 +5,7 @@ module ZuoraAPI
|
|
5
5
|
class Login
|
6
6
|
ENVIRONMENTS = [SANDBOX = 'Sandbox', PRODUCTION = 'Production', PREFORMANCE = 'Preformance', SERVICES = 'Services', UNKNOWN = 'Unknown' ]
|
7
7
|
REGIONS = [EU = 'EU', US = 'US' ]
|
8
|
-
attr_accessor :username, :password, :region,:url, :wsdl_number, :
|
8
|
+
attr_accessor :username, :password, :region,:url, :wsdl_number, :current_session, :environment, :status, :errors, :current_error, :user_info, :tenant_id, :tenant_name, :entity_id
|
9
9
|
|
10
10
|
def initialize(username: nil, password: nil, url: nil, entity_id: nil, session: nil, **keyword_args)
|
11
11
|
@username = username
|
@@ -115,6 +115,7 @@ module ZuoraAPI
|
|
115
115
|
end
|
116
116
|
@response_query = HTTParty.post(self.url,:body => request.to_xml, :headers => {'Content-Type' => "text/xml; charset=utf-8"}, :timeout => 10)
|
117
117
|
@output_xml = Nokogiri::XML(@response_query.body)
|
118
|
+
|
118
119
|
if !@response_query.success?
|
119
120
|
self.current_session = nil
|
120
121
|
if @output_xml.namespaces.size > 0 && @output_xml.xpath('//soapenv:Fault').size > 0
|
@@ -162,8 +163,18 @@ module ZuoraAPI
|
|
162
163
|
self.status = 'No Service'
|
163
164
|
end
|
164
165
|
else
|
165
|
-
|
166
|
-
|
166
|
+
#If Session only is used for Gem TODO Depercate
|
167
|
+
if (self.password.blank? && self.current_session.present?)
|
168
|
+
self.current_session = self.current_session
|
169
|
+
self.username = @output_xml.xpath('//ns1:Username', 'ns1' =>'http://api.zuora.com/').text if self.username.blank?
|
170
|
+
|
171
|
+
#Username & password combo
|
172
|
+
elsif (self.password.present? && self.username.present?)
|
173
|
+
retrieved_session = @output_xml.xpath('//ns1:Session', 'ns1' =>'http://api.zuora.com/').text
|
174
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("No session found for api call.") if retrieved_session.blank?
|
175
|
+
self.current_session = retrieved_session
|
176
|
+
end
|
177
|
+
|
167
178
|
self.current_error = nil
|
168
179
|
self.status = 'Active'
|
169
180
|
end
|
@@ -252,35 +263,69 @@ module ZuoraAPI
|
|
252
263
|
def raise_errors(type: :SOAP, body: nil, response: nil)
|
253
264
|
case type
|
254
265
|
when :SOAP
|
255
|
-
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text}::#{body.xpath('//fns:FaultMessage', 'fns' =>'http://fault.api.zuora.com/').text}") if (!body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text.blank? && body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text == "INVALID_SESSION")
|
256
|
-
|
257
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text}::#{body.xpath('//fns:FaultMessage', 'fns' =>'http://fault.api.zuora.com/').text}") if (!body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text.blank? && body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text == "REQUEST_EXCEEDED_LIMIT")
|
258
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{body.xpath('//ns1:Code', 'ns1' =>'http://api.zuora.com/').text}::#{body.xpath('//ns1:Message', 'ns1' =>'http://api.zuora.com/').text}") if (!body.xpath('//ns1:Code', 'ns1' =>'http://api.zuora.com/').text.blank? && body.xpath('//ns1:Code', 'ns1' =>'http://api.zuora.com/').text == "REQUEST_EXCEEDED_LIMIT")
|
259
266
|
|
260
|
-
|
261
|
-
|
267
|
+
error = body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text
|
268
|
+
message = body.xpath('//fns:FaultMessage', 'fns' =>'http://fault.api.zuora.com/').text
|
262
269
|
|
263
|
-
|
264
|
-
|
270
|
+
if error.blank? || message.blank?
|
271
|
+
error = body.xpath('//ns1:Code', 'ns1' =>'http://api.zuora.com/').text
|
272
|
+
message = body.xpath('//ns1:Message', 'ns1' =>'http://api.zuora.com/').text
|
273
|
+
end
|
274
|
+
if error.blank? || message.blank?
|
275
|
+
error = body.xpath('//faultcode').text
|
276
|
+
message = body.xpath('//faultstring').text
|
277
|
+
end
|
278
|
+
|
279
|
+
if error.present?
|
280
|
+
if error == "INVALID_SESSION"
|
281
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{error}::#{message}")
|
282
|
+
end
|
283
|
+
if error == "REQUEST_EXCEEDED_LIMIT"
|
284
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{error}::#{message}")
|
285
|
+
end
|
286
|
+
if error == "LOCK_COMPETITION"
|
287
|
+
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{error}::#{message}")
|
288
|
+
end
|
289
|
+
if error.present?
|
290
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}")
|
291
|
+
end
|
292
|
+
end
|
265
293
|
|
266
|
-
when :JSON
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{body["reasons"][0]["message"]}") if (!body["success"] && !body["reasons"].blank? && body["reasons"] == Array && body["reasons"][0]["code"] == 53200050)
|
294
|
+
when :JSON
|
295
|
+
if body.class == Hash && (!body["success"] || !body["Success"] || response.code != 200)
|
296
|
+
messages_array = (body["reasons"] || []).map {|error| error['message']}.compact
|
297
|
+
codes_array = (body["reasons"] || []).map {|error| error['code']}.compact
|
298
|
+
|
299
|
+
#Authentication failed
|
300
|
+
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(11) || response.code == 401
|
301
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{messages_array.join(', ')}")
|
302
|
+
end
|
276
303
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
304
|
+
#Request exceeded limit
|
305
|
+
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(70)
|
306
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{messages_array.join(', ')}")
|
307
|
+
end
|
308
|
+
|
309
|
+
#Locking contention
|
310
|
+
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(50)
|
311
|
+
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{messages_array.join(', ')}")
|
312
|
+
end
|
313
|
+
|
314
|
+
#Zuora REST Query Errors
|
315
|
+
if body["faultcode"].present?
|
316
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{body["faultcode"]}::#{body["faultstring"]}")
|
317
|
+
end
|
318
|
+
end
|
283
319
|
|
320
|
+
if body.class == Array && (!body[0]["Success"])
|
321
|
+
#Zuora REST Actions error (Create, Update, Delete)
|
322
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{body[0]["Errors"][0]["Code"]}::#{body[0]["Errors"][0]["Message"]}")
|
323
|
+
end
|
324
|
+
|
325
|
+
#All other errors
|
326
|
+
if response.code != 200
|
327
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{response.message}")
|
328
|
+
end
|
284
329
|
end
|
285
330
|
end
|
286
331
|
|
@@ -365,9 +410,14 @@ module ZuoraAPI
|
|
365
410
|
headers["entityId"] = self.entity_id if !self.entity_id.blank?
|
366
411
|
raise "Method not supported, supported methods include: :get, :post, :put, :delete, :patch, :head, :options" if ![:get, :post, :put, :delete, :patch, :head, :options].include?(method)
|
367
412
|
response = HTTParty::Request.new("Net::HTTP::#{method.to_s.capitalize}".constantize, url, body: body, headers: {'Content-Type' => "application/json; charset=utf-8"}.merge(z_session ? {"Authorization" => "ZSession #{self.get_session}"} : {}).merge(headers), timeout: 120).perform
|
368
|
-
|
369
|
-
|
370
|
-
|
413
|
+
|
414
|
+
Rails.logger.debug('Connect') {"Response Code: #{response.code}" } if debug
|
415
|
+
begin
|
416
|
+
output_json = JSON.parse(response.body)
|
417
|
+
rescue JSON::ParserError => ex
|
418
|
+
output_json = {}
|
419
|
+
end
|
420
|
+
Rails.logger.debug('Connect') {"Response JSON: #{output_json}"} if debug && output_json.present?
|
371
421
|
|
372
422
|
raise_errors(type: :JSON, body: output_json, response: response)
|
373
423
|
|
data/lib/zuora_api/version.rb
CHANGED
data/zuora_api.gemspec
CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.12"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency("webmock")
|
25
|
+
spec.add_development_dependency("simplecov")
|
24
26
|
spec.add_dependency("nokogiri", "~>1.6.8")
|
25
27
|
spec.add_dependency("httparty")
|
26
28
|
spec.add_dependency("rubyzip")
|
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: 1.3.
|
4
|
+
version: 1.3.9994
|
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: 2017-09-
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: nokogiri
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,7 +149,6 @@ executables: []
|
|
121
149
|
extensions: []
|
122
150
|
extra_rdoc_files: []
|
123
151
|
files:
|
124
|
-
- ".DS_Store"
|
125
152
|
- ".gitignore"
|
126
153
|
- ".gitlab-ci.yml"
|
127
154
|
- ".rspec"
|
data/.DS_Store
DELETED
Binary file
|