zuora_api 1.7.46 → 1.7.47

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f054d8062406905de090c7b6776c14025c5c3c5c35c0e4956d6e31f3a9db0d4b
4
- data.tar.gz: be94cd7bd5ffa2c462bd177a7e099efdc495da806bc770a4ca7dfefb1f82b4b6
3
+ metadata.gz: eed1fa5dc6016e23c11ac0c31424666d506aae217df0dbef2955dc0cae4aa7f5
4
+ data.tar.gz: 30c162e44cc887d3fde37d7c77313703943bb4ea38d063db3f17d1f83ef215b4
5
5
  SHA512:
6
- metadata.gz: ab855eef02dcdb0250909817cb08d6f5e6dbb0cafccdeba9189d3b35d4e4097e144ddb55c4a14828b43b57082a3bf3a31e1cd95533d3f259ad61b2f8856296f0
7
- data.tar.gz: 65066319073e08211bdb469286d0657a0abf565ff0d8e687b37c0ebbcbcd867d4fa36d66f56e9adfb43ea00016671403522bbd5388f64135de6b7d4e2e1302d9
6
+ metadata.gz: 29fe139b91d70cd5765a767496ac752212939eec317406a261eabf2967aa682a5eca7bbdfede429190798033a1124ec53c8cf6ae91af60d7347c0e1819eb6066
7
+ data.tar.gz: 7c08435180b364b41d6861d87b8ca639ee6fd41f6b2deb99fad17ef1416b08fadbcd600957b0ec95abc2e65735a32fd2f7f709158e094a8675d480b8272c8426
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zuora_api (1.7.46)
4
+ zuora_api (1.7.47)
5
5
  httparty
6
6
  nokogiri
7
7
  railties (>= 4.1.0, < 6)
@@ -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 /Payment status should be Processed. Invalid payment is P-\d*./
48
+ when /^Payment status should be Processed. Invalid payment is P-\d*./
49
49
  @message = "Payment status should be Processed."
50
- when /Adjustment cannot be created for invoice(.*) with a zero balance./
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 /The balance of all the invoice items and tax items is 0. No write-off is needed for the invoice .*./
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 /Json input does not match schema. Error(s): string ".*" is too long .*/
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
@@ -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/v1/".concat(url)
359
+ endpoint = "https://rest.apisandbox.zuora.com"
360
360
  when 'EU'
361
- endpoint = "https://rest.sandbox.eu.zuora.com/v1/".concat(url)
361
+ endpoint = "https://rest.sandbox.eu.zuora.com"
362
362
  when 'NA'
363
- endpoint = "https://rest.sandbox.na.zuora.com/v1/".concat(url)
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/v1/".concat(url)
368
+ endpoint = "https://rest.zuora.com"
369
369
  when 'EU'
370
- endpoint = "https://rest.eu.zuora.com/v1/".concat(url)
370
+ endpoint = "https://rest.eu.zuora.com"
371
371
  when 'NA'
372
- endpoint = "https://rest.na.zuora.com/v1/".concat(url)
372
+ endpoint = "https://rest.na.zuora.com"
373
373
  end
374
374
  when 'Performance'
375
- endpoint = "https://rest.pt1.zuora.com/v1/".concat(url)
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}/v1/#{url}"
379
+ endpoint = "#{https}rest#{host}"
380
380
  when 'Staging'
381
- endpoint = "https://rest-staging2.zuora.com/v1/".concat(url)
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, soft_errors: soft_errors)
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, soft_errors: [])
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
- errors = []
709
- (body["Errors"] || []).select { |obj| errors.push(obj["Message"]) }.compact
710
- (body["errors"] || []).select { |obj| errors.push(obj["Message"]) }.compact
711
- if errors.size > 0
712
- raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{errors.join(", ")}", response, errors)
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.to_s, response, errors, success)
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)
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "1.7.46"
2
+ VERSION = "1.7.47"
3
3
  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: 1.7.46
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-15 00:00:00.000000000 Z
11
+ date: 2020-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler