zuora_api 1.10.3 → 1.10.6

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: cb8a07811203b9141471afb4cb85bc7b3c62b6e2ce6c9254985d3ad7683f2540
4
- data.tar.gz: 58fefaba666d1999c169fcc02208b6df7fca95aa0bc9b219d7aa1fb8c02e1599
3
+ metadata.gz: 8026eb651925fa47b997421f3a1fe105f2ca59b70e7795683cc1d963cb7648dc
4
+ data.tar.gz: 1debeeeefad00e4694698a89735c2e3926adfdbc0b8e6ba670c5d71a94179af1
5
5
  SHA512:
6
- metadata.gz: 1c3c2d7503e8afb612edf442105d6c78d8feb6b480d625dc119ce2cd49645bbd2ad60e9090c93489e56af2921cc97921178c31aa0384a966fb3ed74efb5d2d32
7
- data.tar.gz: ec1bc529dba10ef46600ae676fe693d63a3852ee466acd10332cdfb611beb4bee52d3c909a2b4d39d4b303f42782391fd0e32c63ecd54d5006c3cd1cbea8ca5f
6
+ metadata.gz: 96ef4a7b2ef99802e16ff693873004a9c9a01aa805ab8cd072cd3442664b047c8d7a696ddb7ac624d06abfa9be4caefe8b009ed5e234b623b94ec429a7bd3130
7
+ data.tar.gz: 5836126e0bf9cc9ef1ace7de763a774ab16d2739d75b2482f21423e01d42dbba037edf54edd5aefaf44e36751f030101873c8a985b9a5d6e6cbab2bddcc0f1f6
@@ -125,12 +125,6 @@ module ZuoraAPI
125
125
  end
126
126
  end
127
127
 
128
- class ZuoraAPIRequestConcurrentLimit < ZuoraAPIRequestLimit
129
- end
130
-
131
- class ZuoraAPIRequestRateLimit < ZuoraAPIRequestLimit
132
- end
133
-
134
128
  class ZuoraAPIUnkownError < Error
135
129
  attr_reader :code, :response
136
130
  attr_writer :default_message
@@ -7,7 +7,7 @@ module ZuoraAPI
7
7
  class Login
8
8
  ENVIRONMENTS = [TEST = 'Test', SANDBOX = 'Sandbox', PRODUCTION = 'Production', PREFORMANCE = 'Preformance', SERVICES = 'Services', UNKNOWN = 'Unknown', STAGING = 'Staging' ]
9
9
  REGIONS = [EU = 'EU', US = 'US', NA = 'NA' ]
10
- MIN_Endpoints = {'Test': '108.0', 'Sandbox': '108.0', 'Production': '108.0', 'Performance': '108.0', 'Services': '96.0', 'Unknown': '96.0', 'Staging': '108.0'}.freeze
10
+ MIN_Endpoints = {'Test': '115.0', 'Sandbox': '115.0', 'Production': '115.0', 'Performance': '115.0', 'Services': '96.0', 'Unknown': '96.0', 'Staging': '115.0'}.freeze
11
11
  XML_SAVE_OPTIONS = Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
12
12
  USER_AGENT = "Zuora#{ENV['Z_APPLICATION_NAME']&.capitalize}/#{ENV['Z_APPLICATION_VERSION']&.delete('v')}"
13
13
 
@@ -30,8 +30,6 @@ module ZuoraAPI
30
30
  ZUORA_API_ERRORS = [
31
31
  ZuoraAPI::Exceptions::ZuoraAPIError,
32
32
  ZuoraAPI::Exceptions::ZuoraAPIRequestLimit,
33
- ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit,
34
- ZuoraAPI::Exceptions::ZuoraAPIRequestRateLimit,
35
33
  ZuoraAPI::Exceptions::ZuoraAPILockCompetition,
36
34
  ZuoraAPI::Exceptions::ZuoraAPITemporaryError,
37
35
  ZuoraAPI::Exceptions::ZuoraDataIntegrity,
@@ -459,7 +457,6 @@ module ZuoraAPI
459
457
  headers.merge!({ 'Content-Type' => "text/xml; charset=utf-8", 'Accept' => 'text/xml'})
460
458
  headers['Zuora-Track-Id'] = zuora_track_id if zuora_track_id.present?
461
459
  headers['X-Amzn-Trace-Id'] = zuora_track_id if zuora_track_id.present?
462
-
463
460
  headers["User-Agent"] = USER_AGENT
464
461
 
465
462
  request = HTTParty::Request.new(
@@ -620,7 +617,10 @@ module ZuoraAPI
620
617
  case response.code
621
618
  when 504
622
619
  raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received 504 from 'https://#{rest_domain(endpoint: request_uri)}'", response)
623
- when 401, 429
620
+ when 429
621
+ raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("The total number of concurrent requests has exceeded the limit allowed by the system. Please resubmit your request later.", response)
622
+ when 401
623
+
624
624
  else
625
625
  if body.class == Hash
626
626
  case request_path
@@ -637,21 +637,6 @@ module ZuoraAPI
637
637
  when :SOAP
638
638
  error, success, message = get_soap_error_and_message(body)
639
639
 
640
- if response.code == 429
641
- if message.to_s.downcase.include?('concurrent')
642
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit.new(
643
- "The total number of concurrent requests has exceeded the limit allowed by the system. " \
644
- "Please resubmit your request later.",
645
- response
646
- )
647
- else
648
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestRateLimit.new(
649
- "Rate limiting. Please resubmit your request later.",
650
- response
651
- )
652
- end
653
- end
654
-
655
640
  if body.xpath('//fns:LoginFault', 'fns' =>'http://fault.api.zuora.com/').present?
656
641
  raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(message, response)
657
642
  end
@@ -727,7 +712,7 @@ module ZuoraAPI
727
712
  end
728
713
 
729
714
  body = body.dig("results").present? ? body["results"] : body if body.class == Hash
730
- if body.class == Hash && (!body["success"] || !body["Success"] || response.code != 200)
715
+ if body.class == Hash && (!(body["success"] || body["Success"]) || response.code != 200)
731
716
  reason_keys = %w(reasons errors)
732
717
  message_keys = %w(message title)
733
718
  messages_array, codes_array = [[],[]]
@@ -744,12 +729,7 @@ module ZuoraAPI
744
729
  codes_array = codes_array.push(body.dig("error", 'code')).compact
745
730
  end
746
731
 
747
- body_message = body.fetch('message', '').downcase
748
- if body_message.include?('rate limit exceeded')
749
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestRateLimit.new("The total number of requests has exceeded the rate limit allowed by the system. Please resubmit your request later.", response)
750
- end
751
-
752
- if body_message.include?('request exceeded limit')
732
+ if body['message'] == 'request exceeded limit'
753
733
  raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("The total number of concurrent requests has exceeded the limit allowed by the system. Please resubmit your request later.", response)
754
734
  end
755
735
 
@@ -821,7 +801,7 @@ module ZuoraAPI
821
801
 
822
802
  #Request exceeded limit
823
803
  if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(70)
824
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit.new("#{messages_array.join(', ')}", response)
804
+ raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{messages_array.join(', ')}", response)
825
805
  end
826
806
 
827
807
  #All Errors catch
@@ -829,10 +809,6 @@ module ZuoraAPI
829
809
  raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{messages_array.join(', ')}", response)
830
810
  end
831
811
 
832
- if response.code == 429
833
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("The total number of concurrent requests has exceeded the limit allowed by the system. Please resubmit your request later.", response)
834
- end
835
-
836
812
  #Zuora REST Query Errors
837
813
  if body["faultcode"].present?
838
814
  raise_errors_helper(error: body["faultcode"], message: body["faultstring"], response: response)
@@ -968,11 +944,7 @@ module ZuoraAPI
968
944
  when /.*INVALID_SESSION/
969
945
  raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(message, response, errors, success)
970
946
  when /.*REQUEST_EXCEEDED_LIMIT/
971
- if message.to_s.downcase.include?('concurrent')
972
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit.new(message, response, errors, success)
973
- else
974
- raise ZuoraAPI::Exceptions::ZuoraAPIRequestRateLimit.new(message, response, errors, success)
975
- end
947
+ raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new(message, response, errors, success)
976
948
  when /.*LOCK_COMPETITION/
977
949
  raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new(message, response, errors, success)
978
950
  when /.*BATCH_FAIL_ERROR/
@@ -1083,14 +1055,11 @@ module ZuoraAPI
1083
1055
 
1084
1056
  def describe_call(object = nil, log_errors = true)
1085
1057
  tries ||= 2
1086
-
1087
1058
  base = self.url.include?(".com") ? self.url.split(".com")[0].concat(".com") : self.url.split(".eu")[0].concat(".eu")
1088
-
1089
1059
  version = self.url.scan(/(\d+\.\d)$/).dig(0,0).to_f
1090
1060
  url = object ? "#{base}/apps/api/#{version}/describe/#{object}" : "#{base}/apps/api/#{version}/describe/"
1091
1061
 
1092
1062
  headers = { "Content-Type" => "text/xml; charset=utf-8" }.merge(self.entity_header)
1093
-
1094
1063
  response = HTTParty.get(url, headers: {"Authorization" => self.get_session(prefix: true, auth_type: :basic), "User-Agent" => USER_AGENT}.merge(headers), :timeout => 130)
1095
1064
 
1096
1065
  raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error.present? ? self.current_error : 'Describe call 401', response) if response.code == 401
@@ -1182,7 +1151,6 @@ module ZuoraAPI
1182
1151
  end
1183
1152
  headers['Zuora-Track-Id'] = zuora_track_id if zuora_track_id.present?
1184
1153
  headers['X-Amzn-Trace-Id'] = zuora_track_id if zuora_track_id.present?
1185
-
1186
1154
  headers['User-Agent'] = USER_AGENT
1187
1155
 
1188
1156
  modified_headers = {'Content-Type' => "application/json; charset=utf-8"}.merge(authentication_headers).merge(headers)
@@ -1351,7 +1319,6 @@ module ZuoraAPI
1351
1319
 
1352
1320
  headers['Zuora-Track-Id'] = zuora_track_id if zuora_track_id.present?
1353
1321
  headers['X-Amzn-Trace-Id'] = zuora_track_id if zuora_track_id.present?
1354
-
1355
1322
  headers["User-Agent"] = USER_AGENT
1356
1323
 
1357
1324
  response_save = nil
@@ -1467,56 +1434,6 @@ module ZuoraAPI
1467
1434
  raise
1468
1435
  end
1469
1436
 
1470
- def create_data_source_export(query: "", encrypted: false, zip: true, z_track_id: "")
1471
- begin
1472
- output_xml, input_xml = self.soap_call(debug: false, timeout_retry: true, zuora_track_id: z_track_id) do |xml|
1473
- xml['ns1'].create do
1474
- xml['ns1'].zObjects('xsi:type' => "ns2:Export") do
1475
- xml['ns2'].Format 'csv'
1476
- xml['ns2'].Zip zip
1477
- xml['ns2'].Name 'googman'
1478
- xml['ns2'].Query query
1479
- xml['ns2'].Encrypted encrypted
1480
- end
1481
- end
1482
- end
1483
-
1484
- return output_xml.xpath('//ns1:Id', 'ns1' =>'http://api.zuora.com/').text
1485
- rescue Exception => ex
1486
- raise ex.class.new("#{z_track_id} #{ex.message}")
1487
- end
1488
- end
1489
-
1490
- def check_export_status(export_id: "")
1491
- begin
1492
- response, full_response = self.rest_call(method: :get,url: self.rest_endpoint("object/export/#{export_id}"))
1493
-
1494
- return full_response.parsed_response
1495
- rescue Exception => ex
1496
- raise ex
1497
- end
1498
- end
1499
-
1500
- def get_export_file(file_id: "", extract: true, zip: true)
1501
- begin
1502
- export_file_path = self.get_file(:url => self.rest_endpoint("files/#{file_id}")).path
1503
-
1504
- if extract && zip
1505
- require "zip"
1506
- new_path = export_file_path.partition('.zip').first
1507
- zipped = Zip::File.open(export_file_path)
1508
- file_handle = zipped.entries.first
1509
- file_handle.extract(new_path)
1510
- File.delete(export_file_path)
1511
- return new_path
1512
- else
1513
- return export_file_path
1514
- end
1515
- rescue Exception => ex
1516
- raise ex
1517
- end
1518
- end
1519
-
1520
1437
  def getDataSourceExport(query, extract: true, encrypted: false, zip: true, z_track_id: "")
1521
1438
  tries ||= 3
1522
1439
 
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "1.10.3"
2
+ VERSION = "1.10.6"
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.10.3
4
+ version: 1.10.6
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: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler