zuora_api 1.7.46 → 1.7.47
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/Gemfile.lock +1 -1
- data/lib/zuora_api/exceptions.rb +6 -4
- data/lib/zuora_api/login.rb +51 -30
- data/lib/zuora_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eed1fa5dc6016e23c11ac0c31424666d506aae217df0dbef2955dc0cae4aa7f5
|
4
|
+
data.tar.gz: 30c162e44cc887d3fde37d7c77313703943bb4ea38d063db3f17d1f83ef215b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29fe139b91d70cd5765a767496ac752212939eec317406a261eabf2967aa682a5eca7bbdfede429190798033a1124ec53c8cf6ae91af60d7347c0e1819eb6066
|
7
|
+
data.tar.gz: 7c08435180b364b41d6861d87b8ca639ee6fd41f6b2deb99fad17ef1416b08fadbcd600957b0ec95abc2e65735a32fd2f7f709158e094a8675d480b8272c8426
|
data/Gemfile.lock
CHANGED
data/lib/zuora_api/exceptions.rb
CHANGED
@@ -45,14 +45,16 @@ module ZuoraAPI
|
|
45
45
|
@code = response.class.to_s == "HTTParty::Response" ? response.code : nil
|
46
46
|
|
47
47
|
case message
|
48
|
-
when
|
48
|
+
when /^Payment status should be Processed. Invalid payment is P-\d*./
|
49
49
|
@message = "Payment status should be Processed."
|
50
|
-
when
|
50
|
+
when /^Adjustment cannot be created for invoice(.*) with a zero balance./
|
51
51
|
@message = "Adjustment cannot be created for invoice with a zero balance."
|
52
|
-
when
|
52
|
+
when /^The balance of all the invoice items and tax items is 0. No write-off is needed for the invoice .*./
|
53
53
|
@message = "The balance of all the invoice items and tax items is 0. No write-off is needed for the invoice."
|
54
|
-
when
|
54
|
+
when /^Json input does not match schema. Error(s): string ".*" is too long .*/
|
55
55
|
@message = "Json input does not match schema. Error(s): String is too long."
|
56
|
+
when /^Query failed \(.*\): .* Table (.*) does not exist$/
|
57
|
+
@message = "Query failed: Table #{$1} does not exist"
|
56
58
|
else
|
57
59
|
@message = message
|
58
60
|
end
|
data/lib/zuora_api/login.rb
CHANGED
@@ -348,7 +348,7 @@ module ZuoraAPI
|
|
348
348
|
return "#{url_slash_apps_slash}api/#{url}"
|
349
349
|
end
|
350
350
|
|
351
|
-
def rest_endpoint(url="")
|
351
|
+
def rest_endpoint(url="", domain=true, prefix='/v1/')
|
352
352
|
update_environment
|
353
353
|
endpoint = url
|
354
354
|
|
@@ -356,33 +356,33 @@ module ZuoraAPI
|
|
356
356
|
when 'Sandbox'
|
357
357
|
case self.region
|
358
358
|
when 'US'
|
359
|
-
endpoint = "https://rest.apisandbox.zuora.com
|
359
|
+
endpoint = "https://rest.apisandbox.zuora.com"
|
360
360
|
when 'EU'
|
361
|
-
endpoint = "https://rest.sandbox.eu.zuora.com
|
361
|
+
endpoint = "https://rest.sandbox.eu.zuora.com"
|
362
362
|
when 'NA'
|
363
|
-
endpoint = "https://rest.sandbox.na.zuora.com
|
363
|
+
endpoint = "https://rest.sandbox.na.zuora.com"
|
364
364
|
end
|
365
365
|
when 'Production'
|
366
366
|
case self.region
|
367
367
|
when 'US'
|
368
|
-
endpoint = "https://rest.zuora.com
|
368
|
+
endpoint = "https://rest.zuora.com"
|
369
369
|
when 'EU'
|
370
|
-
endpoint = "https://rest.eu.zuora.com
|
370
|
+
endpoint = "https://rest.eu.zuora.com"
|
371
371
|
when 'NA'
|
372
|
-
endpoint = "https://rest.na.zuora.com
|
372
|
+
endpoint = "https://rest.na.zuora.com"
|
373
373
|
end
|
374
374
|
when 'Performance'
|
375
|
-
endpoint = "https://rest.pt1.zuora.com
|
375
|
+
endpoint = "https://rest.pt1.zuora.com"
|
376
376
|
when 'Services'
|
377
377
|
https = /https:\/\/|http:\/\//.match(self.url)[0]
|
378
378
|
host = self.hostname
|
379
|
-
endpoint = "#{https}rest#{host}
|
379
|
+
endpoint = "#{https}rest#{host}"
|
380
380
|
when 'Staging'
|
381
|
-
endpoint = "https://rest-staging2.zuora.com
|
381
|
+
endpoint = "https://rest-staging2.zuora.com"
|
382
382
|
when 'Unknown'
|
383
383
|
raise "Environment unknown, returning passed in parameter unaltered"
|
384
384
|
end
|
385
|
-
return endpoint
|
385
|
+
return domain ? endpoint.concat(prefix).concat(url) : prefix.concat(url)
|
386
386
|
end
|
387
387
|
|
388
388
|
def rest_domain
|
@@ -444,7 +444,6 @@ module ZuoraAPI
|
|
444
444
|
debug: false,
|
445
445
|
zuora_track_id: nil,
|
446
446
|
errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError].concat(ZUORA_API_ERRORS),
|
447
|
-
soft_errors: [],
|
448
447
|
z_session: true,
|
449
448
|
timeout_retry: false,
|
450
449
|
timeout: 120,
|
@@ -494,7 +493,7 @@ module ZuoraAPI
|
|
494
493
|
output_xml = Nokogiri::XML(response.body)
|
495
494
|
Rails.logger.debug("Response SOAP XML: #{output_xml.to_xml(:save_with => XML_SAVE_OPTIONS).strip}") if debug
|
496
495
|
|
497
|
-
raise_errors(type: :SOAP, body: output_xml, response: response
|
496
|
+
raise_errors(type: :SOAP, body: output_xml, response: response)
|
498
497
|
rescue ZuoraAPI::Exceptions::ZuoraAPISessionError => ex
|
499
498
|
if !tries.zero? && z_session
|
500
499
|
tries -= 1
|
@@ -571,7 +570,7 @@ module ZuoraAPI
|
|
571
570
|
return output_xml, input_xml, response
|
572
571
|
end
|
573
572
|
|
574
|
-
def raise_errors(type: :SOAP, body: nil, response: nil
|
573
|
+
def raise_errors(type: :SOAP, body: nil, response: nil)
|
575
574
|
if [502,503].include?(response.code)
|
576
575
|
raise ZuoraAPI::Exceptions::ZuoraAPIConnectionTimeout.new("Received #{response.code} from #{response.request.uri}", response)
|
577
576
|
end
|
@@ -593,11 +592,6 @@ module ZuoraAPI
|
|
593
592
|
'//ns1:records[@xsi:type="ns2:Export"]',
|
594
593
|
'ns1' => 'http://api.zuora.com/', 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
|
595
594
|
).present?
|
596
|
-
if body.xpath('//ns1:size', 'ns1' => 'http://api.zuora.com/').text.to_i < 1 && soft_errors.include?(:export_size_0)
|
597
|
-
error = 'UNEXPECTED_ERROR'
|
598
|
-
message = 'No export found.'
|
599
|
-
end
|
600
|
-
|
601
595
|
result = body.xpath('//ns2:Status', 'ns2' => 'http://object.api.zuora.com/').text
|
602
596
|
if result == 'Failed'
|
603
597
|
reason = body.xpath('//ns2:StatusReason', 'ns2' => 'http://object.api.zuora.com/').text
|
@@ -630,6 +624,24 @@ module ZuoraAPI
|
|
630
624
|
end
|
631
625
|
|
632
626
|
when :JSON
|
627
|
+
if body.class == Hash
|
628
|
+
request = response.request
|
629
|
+
match_string = "#{request.http_method.to_s.split("Net::HTTP::").last.upcase}::#{response.code}::#{request.path.path}"
|
630
|
+
case response.request.path.path
|
631
|
+
when /^\/query\/jobs.*/ #DataQuery Paths
|
632
|
+
case match_string
|
633
|
+
when /^GET::200::\/query\/jobs\/([a-zA-Z0-9\-_]*)$/ #Get DQ job
|
634
|
+
if (body.dig('data', "errorMessage").present? || body.dig('data', "queryStatus") == "failed") #&&
|
635
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(body.dig('data', "errorMessage"), response)
|
636
|
+
end
|
637
|
+
when /^GET::404::\/query\/jobs\/([a-zA-Z0-9\-_]*)$/ #Get DQ job not found
|
638
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(body.dig('message'), response) if body.dig('message').present?
|
639
|
+
when /^POST::400::\/query\/jobs$/ #Create DQ job
|
640
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(body.dig('message'), response) if body.dig('message').present?
|
641
|
+
end
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
633
645
|
body = body.dig("results").present? ? body["results"] : body if body.class == Hash
|
634
646
|
if body.class == Hash && (!body["success"] || !body["Success"] || response.code != 200)
|
635
647
|
messages_array = body.fetch("reasons", []).map {|error| error['message']}.compact
|
@@ -684,16 +696,21 @@ module ZuoraAPI
|
|
684
696
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{body['faultstring']}", response)
|
685
697
|
end
|
686
698
|
|
687
|
-
#Request exceeded limit
|
688
|
-
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(70)
|
689
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{messages_array.join(', ')}", response)
|
690
|
-
end
|
691
|
-
|
692
699
|
#Locking contention
|
693
700
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(50)
|
694
701
|
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{messages_array.join(', ')}", response)
|
695
702
|
end
|
696
703
|
|
704
|
+
#Internal Server Error
|
705
|
+
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(60)
|
706
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("#{messages_array.join(', ')}", response)
|
707
|
+
end
|
708
|
+
|
709
|
+
#Request exceeded limit
|
710
|
+
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(70)
|
711
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{messages_array.join(', ')}", response)
|
712
|
+
end
|
713
|
+
|
697
714
|
#All Errors catch
|
698
715
|
if codes_array.size > 0
|
699
716
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{messages_array.join(', ')}", response)
|
@@ -705,11 +722,15 @@ module ZuoraAPI
|
|
705
722
|
end
|
706
723
|
|
707
724
|
if body["Errors"].present? || body["errors"].present?
|
708
|
-
|
709
|
-
(
|
710
|
-
(
|
711
|
-
if
|
712
|
-
|
725
|
+
codes, messages = [[],[]]
|
726
|
+
body.fetch("Errors", []).select { |obj| messages.push(obj["Message"]); codes.push(obj["Code"]) }
|
727
|
+
body.fetch("errors", []).select { |obj| messages.push(obj["Message"]); codes.push(obj["Code"]) }
|
728
|
+
if codes.size > 0
|
729
|
+
if codes.uniq.size == 1
|
730
|
+
raise_errors_helper(error: codes.first, message: messages.first, response: response, errors: messages)
|
731
|
+
else
|
732
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{messages.join(", ")}", response, messages)
|
733
|
+
end
|
713
734
|
end
|
714
735
|
end
|
715
736
|
end
|
@@ -817,7 +838,7 @@ module ZuoraAPI
|
|
817
838
|
when /INVALID_ID/, /MAX_RECORDS_EXCEEDED/, /INVALID_FIELD/, /MALFORMED_QUERY/, /NO_PERMISSION/, /PDF_QUERY_ERROR/, /MISSING_REQUIRED_VALUE/, /INVALID_TYPE/, /TRANSACTION_FAILED/, /API_DISABLED/, /CANNOT_DELETE/, /ACCOUNTING_PERIOD_CLOSED/
|
818
839
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(message, response, errors, success)
|
819
840
|
when /.*UNEXPECTED_ERROR/
|
820
|
-
raise ZuoraAPI::Exceptions::ZuoraUnexpectedError.new(message
|
841
|
+
raise ZuoraAPI::Exceptions::ZuoraUnexpectedError.new(message, response, errors, success)
|
821
842
|
when /.*soapenv:Server.*/
|
822
843
|
if /Invalid value.*for type|Id is invalid/.match(message).present?
|
823
844
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(message, response, errors, success)
|
data/lib/zuora_api/version.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: 1.7.
|
4
|
+
version: 1.7.47
|
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: 2020-02-
|
11
|
+
date: 2020-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|