zuora_api 1.10.3 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zuora_api/exceptions.rb +0 -6
- data/lib/zuora_api/login.rb +7 -90
- data/lib/zuora_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcc70f9f6dc5b44374be1a328a8b278371f258c16f87a13ca454163eb48a2e61
|
4
|
+
data.tar.gz: 5044aa7d15bb20e4d137c6f9ddead29543fb0f83198ceac9c4db4eede7650e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d1a69613a273ef0105a4f0565f63fc653e4a811320890ef50d7be1e4727b1437764742c9c07dbca21806a4c5636cf0434a4169ca794afc351411e8f94eeed58
|
7
|
+
data.tar.gz: 5dd1e52dc4ddf48b921ea11cf948b362867723278a93ec39114aadd5c9e12c6d9d4847159bc94e1c310eeb507004affc9149951280dcdc2f44c7cca240261ef6
|
data/lib/zuora_api/exceptions.rb
CHANGED
@@ -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
|
data/lib/zuora_api/login.rb
CHANGED
@@ -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
|
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
|
@@ -744,12 +729,7 @@ module ZuoraAPI
|
|
744
729
|
codes_array = codes_array.push(body.dig("error", 'code')).compact
|
745
730
|
end
|
746
731
|
|
747
|
-
|
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::
|
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
|
-
|
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
|
|
data/lib/zuora_api/version.rb
CHANGED