zuora_api 1.9.07 → 1.9.08
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/lib/zuora_api/exceptions.rb +6 -0
- data/lib/zuora_api/login.rb +87 -11
- 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
|
@@ -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': '
|
|
10
|
+
MIN_Endpoints = {'Test': '107.0', 'Sandbox': '107.0', 'Production': '107.0', 'Performance': '107.0', 'Services': '96.0', 'Unknown': '96.0', 'Staging': '107.0'}.freeze
|
|
11
11
|
XML_SAVE_OPTIONS = Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
|
|
12
12
|
|
|
13
13
|
CONNECTION_EXCEPTIONS = [
|
|
@@ -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,
|
|
@@ -138,14 +140,13 @@ module ZuoraAPI
|
|
|
138
140
|
def reporting_url(path)
|
|
139
141
|
map = {"US" => {"Sandbox" => "https://zconnectsandbox.zuora.com/api/rest/v1/",
|
|
140
142
|
"Production" => "https://zconnect.zuora.com/api/rest/v1/",
|
|
141
|
-
"Test" => "https://
|
|
143
|
+
"Test" => "https://reporting-sbx.zan.0001.sbx.auw2.zuora.com/api/rest/v1/",
|
|
142
144
|
"Staging" => "https://reporting-stg11.zan.svc.auw2.zuora.com/api/rest/v1/",
|
|
143
145
|
"Performance" => "https://zconnectpt1.zuora.com/api/rest/v1/",
|
|
144
146
|
"Services" => "https://reporting-svc08.svc.auw2.zuora.com/api/rest/v1/"},
|
|
145
147
|
"EU" => {"Sandbox" => "https://zconnect.sandbox.eu.zuora.com/api/rest/v1/",
|
|
146
148
|
"Production" => "https://zconnect.eu.zuora.com/api/rest/v1/",
|
|
147
|
-
"Services"=> "https://reporting-sbx0000.sbx.aec1.zuora.com/api/rest/v1/",
|
|
148
|
-
"Test" => "https://zconnect-services0002.test.eu.zuora.com/api/rest/v1/"},
|
|
149
|
+
"Services"=> "https://reporting-sbx0000.sbx.aec1.zuora.com/api/rest/v1/"},
|
|
149
150
|
"NA" => {"Sandbox" => "https://zconnect.sandbox.na.zuora.com/api/rest/v1/",
|
|
150
151
|
"Production" => "https://zconnect.na.zuora.com/api/rest/v1/",
|
|
151
152
|
"Services"=> ""}
|
|
@@ -612,10 +613,7 @@ module ZuoraAPI
|
|
|
612
613
|
case response.code
|
|
613
614
|
when 504
|
|
614
615
|
raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received 504 from 'https://#{rest_domain(endpoint: request_uri)}'", response)
|
|
615
|
-
when 429
|
|
616
|
-
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)
|
|
617
|
-
when 401
|
|
618
|
-
|
|
616
|
+
when 401, 429
|
|
619
617
|
else
|
|
620
618
|
if body.class == Hash
|
|
621
619
|
case request_path
|
|
@@ -632,6 +630,21 @@ module ZuoraAPI
|
|
|
632
630
|
when :SOAP
|
|
633
631
|
error, success, message = get_soap_error_and_message(body)
|
|
634
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
|
+
|
|
635
648
|
if body.xpath('//fns:LoginFault', 'fns' =>'http://fault.api.zuora.com/').present?
|
|
636
649
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(message, response)
|
|
637
650
|
end
|
|
@@ -724,7 +737,12 @@ module ZuoraAPI
|
|
|
724
737
|
codes_array = codes_array.push(body.dig("error", 'code')).compact
|
|
725
738
|
end
|
|
726
739
|
|
|
727
|
-
|
|
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')
|
|
728
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)
|
|
729
747
|
end
|
|
730
748
|
|
|
@@ -796,7 +814,7 @@ module ZuoraAPI
|
|
|
796
814
|
|
|
797
815
|
#Request exceeded limit
|
|
798
816
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(70)
|
|
799
|
-
raise ZuoraAPI::Exceptions::
|
|
817
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIRequestConcurrentLimit.new("#{messages_array.join(', ')}", response)
|
|
800
818
|
end
|
|
801
819
|
|
|
802
820
|
#All Errors catch
|
|
@@ -804,6 +822,10 @@ module ZuoraAPI
|
|
|
804
822
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("#{messages_array.join(', ')}", response)
|
|
805
823
|
end
|
|
806
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
|
+
|
|
807
829
|
#Zuora REST Query Errors
|
|
808
830
|
if body["faultcode"].present?
|
|
809
831
|
raise_errors_helper(error: body["faultcode"], message: body["faultstring"], response: response)
|
|
@@ -939,7 +961,11 @@ module ZuoraAPI
|
|
|
939
961
|
when /.*INVALID_SESSION/
|
|
940
962
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(message, response, errors, success)
|
|
941
963
|
when /.*REQUEST_EXCEEDED_LIMIT/
|
|
942
|
-
|
|
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
|
|
943
969
|
when /.*LOCK_COMPETITION/
|
|
944
970
|
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new(message, response, errors, success)
|
|
945
971
|
when /.*BATCH_FAIL_ERROR/
|
|
@@ -1397,6 +1423,56 @@ module ZuoraAPI
|
|
|
1397
1423
|
raise
|
|
1398
1424
|
end
|
|
1399
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
|
+
|
|
1400
1476
|
def getDataSourceExport(query, extract: true, encrypted: false, zip: true, z_track_id: "")
|
|
1401
1477
|
tries ||= 3
|
|
1402
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-05-
|
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|