zuora_api 1.4.08 → 1.4.09
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +21 -21
- data/lib/zuora_api/exceptions.rb +3 -1
- data/lib/zuora_api/login.rb +48 -28
- data/lib/zuora_api/version.rb +1 -1
- data/zuora_api.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 795e782dca68d2153bb987dbdc2e42c4bf5864d6
|
4
|
+
data.tar.gz: 280ca629bff273729c291f53f7ad453728ef2e8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daaad5659d3fac1554c0d12971134f2ebb1788eaeee366983e5838ba11c5ac85b6523acc7f9579577260d9bc4b1247e7efb45a305c623a44c2bd251a80194ab3
|
7
|
+
data.tar.gz: 1a04d03bbf766657355fb32b80cae0e57988ea92cae36c9e3143175f5aac492e4da4b4db7a23fe98ce3a208c8284dc9d50749bd6e3ca66189388c74df441974f
|
data/Gemfile.lock
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zuora_api (1.4.
|
4
|
+
zuora_api (1.4.09)
|
5
5
|
httparty
|
6
|
-
nokogiri
|
6
|
+
nokogiri
|
7
7
|
railties (>= 4.1.0, < 5.1)
|
8
8
|
rubyzip
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actionpack (5.0.
|
14
|
-
actionview (= 5.0.
|
15
|
-
activesupport (= 5.0.
|
13
|
+
actionpack (5.0.7)
|
14
|
+
actionview (= 5.0.7)
|
15
|
+
activesupport (= 5.0.7)
|
16
16
|
rack (~> 2.0)
|
17
17
|
rack-test (~> 0.6.3)
|
18
18
|
rails-dom-testing (~> 2.0)
|
19
19
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
20
|
-
actionview (5.0.
|
21
|
-
activesupport (= 5.0.
|
20
|
+
actionview (5.0.7)
|
21
|
+
activesupport (= 5.0.7)
|
22
22
|
builder (~> 3.1)
|
23
23
|
erubis (~> 2.7.0)
|
24
24
|
rails-dom-testing (~> 2.0)
|
25
25
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
26
|
-
activesupport (5.0.
|
26
|
+
activesupport (5.0.7)
|
27
27
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
|
-
i18n (
|
28
|
+
i18n (>= 0.7, < 2)
|
29
29
|
minitest (~> 5.1)
|
30
30
|
tzinfo (~> 1.1)
|
31
31
|
addressable (2.5.2)
|
@@ -34,25 +34,25 @@ GEM
|
|
34
34
|
concurrent-ruby (1.0.5)
|
35
35
|
crack (0.4.3)
|
36
36
|
safe_yaml (~> 1.0.0)
|
37
|
-
crass (1.0.
|
37
|
+
crass (1.0.4)
|
38
38
|
diff-lcs (1.3)
|
39
39
|
docile (1.1.5)
|
40
40
|
erubis (2.7.0)
|
41
41
|
hashdiff (0.3.7)
|
42
|
-
httparty (0.16.
|
42
|
+
httparty (0.16.2)
|
43
43
|
multi_xml (>= 0.5.2)
|
44
|
-
i18n (0.
|
44
|
+
i18n (1.0.0)
|
45
45
|
concurrent-ruby (~> 1.0)
|
46
46
|
json (2.1.0)
|
47
|
-
loofah (2.2.
|
47
|
+
loofah (2.2.2)
|
48
48
|
crass (~> 1.0.2)
|
49
49
|
nokogiri (>= 1.5.9)
|
50
50
|
method_source (0.9.0)
|
51
|
-
mini_portile2 (2.
|
51
|
+
mini_portile2 (2.3.0)
|
52
52
|
minitest (5.11.3)
|
53
53
|
multi_xml (0.6.0)
|
54
|
-
nokogiri (1.
|
55
|
-
mini_portile2 (~> 2.
|
54
|
+
nokogiri (1.8.2)
|
55
|
+
mini_portile2 (~> 2.3.0)
|
56
56
|
public_suffix (3.0.1)
|
57
57
|
rack (2.0.4)
|
58
58
|
rack-test (0.6.3)
|
@@ -60,11 +60,11 @@ GEM
|
|
60
60
|
rails-dom-testing (2.0.3)
|
61
61
|
activesupport (>= 4.2.0)
|
62
62
|
nokogiri (>= 1.6)
|
63
|
-
rails-html-sanitizer (1.0.
|
64
|
-
loofah (~> 2.
|
65
|
-
railties (5.0.
|
66
|
-
actionpack (= 5.0.
|
67
|
-
activesupport (= 5.0.
|
63
|
+
rails-html-sanitizer (1.0.4)
|
64
|
+
loofah (~> 2.2, >= 2.2.2)
|
65
|
+
railties (5.0.7)
|
66
|
+
actionpack (= 5.0.7)
|
67
|
+
activesupport (= 5.0.7)
|
68
68
|
method_source
|
69
69
|
rake (>= 0.8.7)
|
70
70
|
thor (>= 0.18.1, < 2.0)
|
data/lib/zuora_api/exceptions.rb
CHANGED
@@ -7,8 +7,10 @@ module ZuoraAPI
|
|
7
7
|
attr_reader :code, :response
|
8
8
|
attr_writer :default_message
|
9
9
|
|
10
|
-
def initialize(message = nil)
|
10
|
+
def initialize(message = nil,response=nil, code =nil)
|
11
|
+
@code = code
|
11
12
|
@message = message
|
13
|
+
@response = response
|
12
14
|
@default_message = "Error with Zuora Session."
|
13
15
|
end
|
14
16
|
|
data/lib/zuora_api/login.rb
CHANGED
@@ -283,27 +283,47 @@ module ZuoraAPI
|
|
283
283
|
error = body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text
|
284
284
|
message = body.xpath('//fns:FaultMessage', 'fns' =>'http://fault.api.zuora.com/').text
|
285
285
|
|
286
|
+
if error.blank? || message.blank?
|
287
|
+
error = body.xpath('//faultcode').text
|
288
|
+
message = body.xpath('//faultstring').text
|
289
|
+
end
|
290
|
+
|
286
291
|
if error.blank? || message.blank?
|
287
292
|
error = body.xpath('//ns1:Code', 'ns1' =>'http://api.zuora.com/').text
|
288
293
|
message = body.xpath('//ns1:Message', 'ns1' =>'http://api.zuora.com/').text
|
289
294
|
end
|
290
|
-
|
291
|
-
|
292
|
-
|
295
|
+
|
296
|
+
#Update/Create/Delete Calls with multiple requests and responses
|
297
|
+
if body.xpath('//ns1:result', 'ns1' =>'http://api.zuora.com/').size > 0 && body.xpath('//ns1:Errors', 'ns1' =>'http://api.zuora.com/').size > 0
|
298
|
+
error = []
|
299
|
+
success = []
|
300
|
+
body.xpath('//ns1:result', 'ns1' =>'http://api.zuora.com/').each_with_index do |call, object_index|
|
301
|
+
|
302
|
+
if call.xpath('./ns1:Success', 'ns1' =>'http://api.zuora.com/').text == 'false'
|
303
|
+
message = "#{call.xpath('./*/ns1:Code', 'ns1' =>'http://api.zuora.com/').text}::#{call.xpath('./*/ns1:Message', 'ns1' =>'http://api.zuora.com/').text}"
|
304
|
+
error.push(message)
|
305
|
+
else
|
306
|
+
success.push(call.xpath('./ns1:Id', 'ns1' =>'http://api.zuora.com/').text)
|
307
|
+
end
|
308
|
+
end
|
293
309
|
end
|
294
310
|
|
295
311
|
if error.present?
|
296
|
-
if error ==
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
312
|
+
if error.class == String
|
313
|
+
if error == "INVALID_SESSION"
|
314
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{error}::#{message}", body, response.code)
|
315
|
+
end
|
316
|
+
if error == "REQUEST_EXCEEDED_LIMIT"
|
317
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{error}::#{message}", body, response.code)
|
318
|
+
end
|
319
|
+
if error == "LOCK_COMPETITION"
|
320
|
+
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{error}::#{message}", body, response.code)
|
321
|
+
end
|
322
|
+
if error.present?
|
323
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{error}::#{message}", body, response.code)
|
324
|
+
end
|
325
|
+
elsif error.class == Array
|
326
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(error.group_by {|v| v}.map {|k,v| "(#{v.size}x) - #{k}"}.join(', '), body, response.code, error, success)
|
307
327
|
end
|
308
328
|
end
|
309
329
|
|
@@ -314,42 +334,42 @@ module ZuoraAPI
|
|
314
334
|
|
315
335
|
#Authentication failed
|
316
336
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(11) || response.code == 401
|
317
|
-
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{messages_array.join(', ')}")
|
337
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{messages_array.join(', ')}", body, response.code)
|
318
338
|
end
|
319
339
|
|
320
340
|
#Zuora REST Create Amendment error #Authentication failed
|
321
341
|
if body["faultcode"].present? && body["faultcode"] == "fns:INVALID_SESSION"
|
322
|
-
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{body['faultstring']}")
|
342
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{body['faultstring']}", body, response.code)
|
323
343
|
end
|
324
344
|
|
325
345
|
#Request exceeded limit
|
326
346
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(70)
|
327
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{messages_array.join(', ')}")
|
347
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{messages_array.join(', ')}", body, response.code)
|
328
348
|
end
|
329
349
|
|
330
350
|
#Locking contention
|
331
351
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(50)
|
332
|
-
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{messages_array.join(', ')}")
|
352
|
+
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{messages_array.join(', ')}", body, response.code)
|
333
353
|
end
|
334
354
|
|
335
355
|
#All Errors catch
|
336
356
|
if codes_array.size > 0
|
337
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{messages_array.join(', ')}")
|
357
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{messages_array.join(', ')}", body, response.code)
|
338
358
|
end
|
339
359
|
|
340
360
|
#Zuora REST Query Errors
|
341
361
|
if body["faultcode"].present?
|
342
362
|
case body["faultcode"]
|
343
363
|
when "fns:MALFORMED_QUERY"
|
344
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{body["faultcode"]}::#{body["faultstring"]}")
|
364
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{body["faultcode"]}::#{body["faultstring"]}", body, response.code)
|
345
365
|
when "fns:REQUEST_EXCEEDED_LIMIT"
|
346
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{body["faultcode"]}::#{body["faultstring"]}")
|
366
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{body["faultcode"]}::#{body["faultstring"]}", body, response.code)
|
347
367
|
when "fns:LOCK_COMPETITION"
|
348
|
-
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{body["faultcode"]}::#{body["faultstring"]}")
|
368
|
+
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{body["faultcode"]}::#{body["faultstring"]}", body, response.code)
|
349
369
|
when "INVALID_SESSION"
|
350
|
-
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{body["faultcode"]}::#{body["faultstring"]}")
|
370
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{body["faultcode"]}::#{body["faultstring"]}", body, response.code)
|
351
371
|
else
|
352
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{body["faultcode"]}::#{body["faultstring"]}")
|
372
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{body["faultcode"]}::#{body["faultstring"]}", body, response.code)
|
353
373
|
end
|
354
374
|
end
|
355
375
|
|
@@ -358,7 +378,7 @@ module ZuoraAPI
|
|
358
378
|
(body["Errors"] || []).select { |obj| errors.push(obj["Message"]) }.compact
|
359
379
|
(body["errors"] || []).select { |obj| errors.push(obj["Message"]) }.compact
|
360
380
|
if errors.size > 0
|
361
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{errors.join(", ")}",
|
381
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{errors.join(", ")}", body, response.code, errors)
|
362
382
|
end
|
363
383
|
end
|
364
384
|
end
|
@@ -369,13 +389,13 @@ module ZuoraAPI
|
|
369
389
|
all_success = body.select {|obj| obj['Success'] || obj['success']}.compact
|
370
390
|
|
371
391
|
if all_errors.size > 0
|
372
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{all_errors.flatten.group_by {|error| error['Message']}.keys.uniq.join(' ')}",
|
392
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{all_errors.flatten.group_by {|error| error['Message']}.keys.uniq.join(' ')}", body, response.code, all_errors, all_success )
|
373
393
|
end
|
374
394
|
end
|
375
395
|
|
376
396
|
#All other errors
|
377
397
|
if response.code != 200
|
378
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{response.message}")
|
398
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{response.message}", body, response.code)
|
379
399
|
end
|
380
400
|
end
|
381
401
|
end
|
@@ -670,7 +690,7 @@ module ZuoraAPI
|
|
670
690
|
end
|
671
691
|
end
|
672
692
|
rescue Exception => e
|
673
|
-
Rails.logger.fatal('GetFile') {"Download Failed: #{response_save} - #{e.message}"}
|
693
|
+
Rails.logger.fatal('GetFile') {"Download Failed: #{response_save} - #{e.class} : #{e.message}"}
|
674
694
|
Rails.logger.fatal('GetFile') {"Download Failed: #{e.backtrace.join("\n")}"}
|
675
695
|
raise
|
676
696
|
end
|
data/lib/zuora_api/version.rb
CHANGED
data/zuora_api.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
24
|
spec.add_development_dependency("webmock")
|
25
25
|
spec.add_development_dependency("simplecov")
|
26
|
-
spec.add_dependency("nokogiri"
|
26
|
+
spec.add_dependency("nokogiri")
|
27
27
|
spec.add_dependency("httparty")
|
28
28
|
spec.add_dependency("rubyzip")
|
29
29
|
spec.add_dependency("railties", ">= 4.1.0", "< 5.1")
|
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.4.
|
4
|
+
version: 1.4.09
|
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: 2018-
|
11
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: nokogiri
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: httparty
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|