zuora_api 1.9.03 → 1.9.08
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 +6 -0
- data/lib/zuora_api/login.rb +85 -8
- 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: a012abdd5eacb3b9743866d78557e5bb97f52067de92a9aec0e46d45252e190c
|
4
|
+
data.tar.gz: 005d7186d019c95060f7ec531f0b548382dc6e274e80522d97a79500ee645938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81d8472647c0b37ceee7fadf82610b28deb9b52b35f84740840de68b65f07ded753114e5e86ab6f936740eedf730a9a42f57bdf0e08b91c8a63b711300fb8c5b
|
7
|
+
data.tar.gz: 2aef7becdbfa2b9b4bdf5d598bd5be23f528f1a09181178df233d8ef218f1c801978d1d1c60d20808b07b7e83981d2bb4dbe1c786a5616977713c064f8fade62
|
data/lib/zuora_api/exceptions.rb
CHANGED
@@ -125,6 +125,12 @@ module ZuoraAPI
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
class ZuoraAPIRequestConcurrentLimit < ZuoraAPIRequestLimit
|
129
|
+
end
|
130
|
+
|
131
|
+
class ZuoraAPIRequestRateLimit < ZuoraAPIRequestLimit
|
132
|
+
end
|
133
|
+
|
128
134
|
class ZuoraAPIUnkownError < Error
|
129
135
|
attr_reader :code, :response
|
130
136
|
attr_writer :default_message
|
data/lib/zuora_api/login.rb
CHANGED
@@ -29,6 +29,8 @@ module ZuoraAPI
|
|
29
29
|
ZUORA_API_ERRORS = [
|
30
30
|
ZuoraAPI::Exceptions::ZuoraAPIError,
|
31
31
|
ZuoraAPI::Exceptions::ZuoraAPIRequestLimit,
|
32
|
+
ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit,
|
33
|
+
ZuoraAPI::Exceptions::ZuoraAPIRequestRateLimit,
|
32
34
|
ZuoraAPI::Exceptions::ZuoraAPILockCompetition,
|
33
35
|
ZuoraAPI::Exceptions::ZuoraAPITemporaryError,
|
34
36
|
ZuoraAPI::Exceptions::ZuoraDataIntegrity,
|
@@ -611,10 +613,7 @@ module ZuoraAPI
|
|
611
613
|
case response.code
|
612
614
|
when 504
|
613
615
|
raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received 504 from 'https://#{rest_domain(endpoint: request_uri)}'", response)
|
614
|
-
when 429
|
615
|
-
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)
|
616
|
-
when 401
|
617
|
-
|
616
|
+
when 401, 429
|
618
617
|
else
|
619
618
|
if body.class == Hash
|
620
619
|
case request_path
|
@@ -631,6 +630,21 @@ module ZuoraAPI
|
|
631
630
|
when :SOAP
|
632
631
|
error, success, message = get_soap_error_and_message(body)
|
633
632
|
|
633
|
+
if response.code == 429
|
634
|
+
if message.to_s.downcase.include?('concurrent')
|
635
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit.new(
|
636
|
+
"The total number of concurrent requests has exceeded the limit allowed by the system. " \
|
637
|
+
"Please resubmit your request later.",
|
638
|
+
response
|
639
|
+
)
|
640
|
+
else
|
641
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestRateLimit.new(
|
642
|
+
"Rate limiting. Please resubmit your request later.",
|
643
|
+
response
|
644
|
+
)
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
634
648
|
if body.xpath('//fns:LoginFault', 'fns' =>'http://fault.api.zuora.com/').present?
|
635
649
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(message, response)
|
636
650
|
end
|
@@ -643,7 +657,7 @@ module ZuoraAPI
|
|
643
657
|
result = body.xpath('//ns2:Status', 'ns2' => 'http://object.api.zuora.com/').text
|
644
658
|
if result == 'Failed'
|
645
659
|
message = body.xpath('//ns2:StatusReason', 'ns2' => 'http://object.api.zuora.com/').text
|
646
|
-
error = '
|
660
|
+
error = 'UNEXPECTED_ERROR'
|
647
661
|
if message.present?
|
648
662
|
identifier, new_message = message.scan(/^([\w\d]{16})\: (.*)/).first
|
649
663
|
error, message = ['UNEXPECTED_ERROR', new_message] if new_message.present?
|
@@ -723,7 +737,12 @@ module ZuoraAPI
|
|
723
737
|
codes_array = codes_array.push(body.dig("error", 'code')).compact
|
724
738
|
end
|
725
739
|
|
726
|
-
|
740
|
+
body_message = body.fetch('message', '').downcase
|
741
|
+
if body_message.include?('rate limit exceeded')
|
742
|
+
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)
|
743
|
+
end
|
744
|
+
|
745
|
+
if body_message.include?('request exceeded limit')
|
727
746
|
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)
|
728
747
|
end
|
729
748
|
|
@@ -795,7 +814,7 @@ module ZuoraAPI
|
|
795
814
|
|
796
815
|
#Request exceeded limit
|
797
816
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(70)
|
798
|
-
raise ZuoraAPI::Exceptions::
|
817
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit.new("#{messages_array.join(', ')}", response)
|
799
818
|
end
|
800
819
|
|
801
820
|
#All Errors catch
|
@@ -803,6 +822,10 @@ module ZuoraAPI
|
|
803
822
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{messages_array.join(', ')}", response)
|
804
823
|
end
|
805
824
|
|
825
|
+
if response.code == 429
|
826
|
+
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)
|
827
|
+
end
|
828
|
+
|
806
829
|
#Zuora REST Query Errors
|
807
830
|
if body["faultcode"].present?
|
808
831
|
raise_errors_helper(error: body["faultcode"], message: body["faultstring"], response: response)
|
@@ -938,7 +961,11 @@ module ZuoraAPI
|
|
938
961
|
when /.*INVALID_SESSION/
|
939
962
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(message, response, errors, success)
|
940
963
|
when /.*REQUEST_EXCEEDED_LIMIT/
|
941
|
-
|
964
|
+
if message.to_s.downcase.include?('concurrent')
|
965
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit.new(message, response, errors, success)
|
966
|
+
else
|
967
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestRateLimit.new(message, response, errors, success)
|
968
|
+
end
|
942
969
|
when /.*LOCK_COMPETITION/
|
943
970
|
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new(message, response, errors, success)
|
944
971
|
when /.*BATCH_FAIL_ERROR/
|
@@ -1396,6 +1423,56 @@ module ZuoraAPI
|
|
1396
1423
|
raise
|
1397
1424
|
end
|
1398
1425
|
|
1426
|
+
def create_data_source_export(query: "", encrypted: false, zip: true, z_track_id: "")
|
1427
|
+
begin
|
1428
|
+
output_xml, input_xml = self.soap_call(debug: false, timeout_retry: true, zuora_track_id: z_track_id) do |xml|
|
1429
|
+
xml['ns1'].create do
|
1430
|
+
xml['ns1'].zObjects('xsi:type' => "ns2:Export") do
|
1431
|
+
xml['ns2'].Format 'csv'
|
1432
|
+
xml['ns2'].Zip zip
|
1433
|
+
xml['ns2'].Name 'googman'
|
1434
|
+
xml['ns2'].Query query
|
1435
|
+
xml['ns2'].Encrypted encrypted
|
1436
|
+
end
|
1437
|
+
end
|
1438
|
+
end
|
1439
|
+
|
1440
|
+
return output_xml.xpath('//ns1:Id', 'ns1' =>'http://api.zuora.com/').text
|
1441
|
+
rescue Exception => ex
|
1442
|
+
raise ex.class.new("#{z_track_id} #{ex.message}")
|
1443
|
+
end
|
1444
|
+
end
|
1445
|
+
|
1446
|
+
def check_export_status(export_id: "")
|
1447
|
+
begin
|
1448
|
+
response, full_response = self.rest_call(method: :get,url: self.rest_endpoint("object/export/#{export_id}"))
|
1449
|
+
|
1450
|
+
return full_response.parsed_response
|
1451
|
+
rescue Exception => ex
|
1452
|
+
raise ex
|
1453
|
+
end
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
def get_export_file(file_id: "", extract: true, zip: true)
|
1457
|
+
begin
|
1458
|
+
export_file_path = self.get_file(:url => self.rest_endpoint("files/#{file_id}")).path
|
1459
|
+
|
1460
|
+
if extract && zip
|
1461
|
+
require "zip"
|
1462
|
+
new_path = export_file_path.partition('.zip').first
|
1463
|
+
zipped = Zip::File.open(export_file_path)
|
1464
|
+
file_handle = zipped.entries.first
|
1465
|
+
file_handle.extract(new_path)
|
1466
|
+
File.delete(export_file_path)
|
1467
|
+
return new_path
|
1468
|
+
else
|
1469
|
+
return export_file_path
|
1470
|
+
end
|
1471
|
+
rescue Exception => ex
|
1472
|
+
raise ex
|
1473
|
+
end
|
1474
|
+
end
|
1475
|
+
|
1399
1476
|
def getDataSourceExport(query, extract: true, encrypted: false, zip: true, z_track_id: "")
|
1400
1477
|
tries ||= 3
|
1401
1478
|
|
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.9.
|
4
|
+
version: 1.9.08
|
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: 2021-
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|