zuora_api 1.7.65e → 1.7.66
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 +3 -2
- data/lib/zuora_api/login.rb +184 -107
- data/lib/zuora_api/logins/oauth.rb +13 -19
- data/lib/zuora_api/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff05150108e2fbba1a069083c46b53d4b43d95d95d4cfb4bcd82d10881e80091
|
|
4
|
+
data.tar.gz: b8543c688b33ee85357716df5e1f93b7cafef3702074914355aa30960b8726dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b2a8309a4a1c88a13be63df6eb96c08d27e25076b379c740b7eddd1898a60f46249388e7279d98e67fd72469e49f1a6abdc5c7f3a62aa32905909c100de46ad
|
|
7
|
+
data.tar.gz: 0a706abfa46ed54f332f903a2af7c118dfda2aaa6f61a280b9c2f989fb19790484aefcabed72bbcdc9b5ab37a2befb46913d2771ab6a924095c34ec80a8a595c
|
data/lib/zuora_api/exceptions.rb
CHANGED
|
@@ -225,13 +225,14 @@ module ZuoraAPI
|
|
|
225
225
|
end
|
|
226
226
|
|
|
227
227
|
class ZuoraAPIReadTimeout < Net::ReadTimeout
|
|
228
|
-
attr_reader :code, :response
|
|
228
|
+
attr_reader :code, :response, :request
|
|
229
229
|
attr_writer :default_message
|
|
230
230
|
|
|
231
|
-
def initialize(message = nil,response=nil, errors = [], successes = [], *args)
|
|
231
|
+
def initialize(message = nil, response = nil, request = nil, errors = [], successes = [], *args)
|
|
232
232
|
@code = response.class.to_s == "HTTParty::Response" ? response.code : nil
|
|
233
233
|
@message = message
|
|
234
234
|
@response = response
|
|
235
|
+
@request = request
|
|
235
236
|
@default_message = "Authentication type is not supported by this Login"
|
|
236
237
|
end
|
|
237
238
|
|
data/lib/zuora_api/login.rb
CHANGED
|
@@ -474,12 +474,16 @@ module ZuoraAPI
|
|
|
474
474
|
headers = { 'Content-Type' => "text/xml; charset=utf-8", 'Accept' => 'text/xml'}
|
|
475
475
|
headers['Zuora-Track-Id'] = zuora_track_id if zuora_track_id.present?
|
|
476
476
|
|
|
477
|
-
|
|
477
|
+
request = HTTParty::Request.new(
|
|
478
|
+
Net::HTTP::Post,
|
|
478
479
|
self.url,
|
|
479
|
-
:
|
|
480
|
-
:
|
|
481
|
-
:
|
|
480
|
+
body: xml.doc.to_xml(:save_with => XML_SAVE_OPTIONS).strip,
|
|
481
|
+
headers: headers,
|
|
482
|
+
timeout: timeout,
|
|
482
483
|
)
|
|
484
|
+
|
|
485
|
+
response = request.perform
|
|
486
|
+
|
|
483
487
|
output_xml = Nokogiri::XML(response.body)
|
|
484
488
|
Rails.logger.debug("Response SOAP XML: #{output_xml.to_xml(:save_with => XML_SAVE_OPTIONS).strip}") if debug
|
|
485
489
|
|
|
@@ -544,7 +548,7 @@ module ZuoraAPI
|
|
|
544
548
|
Rails.logger.error("SOAP Call - #{ex.class} Timed out will retry after #{timeout_sleep_interval} seconds")
|
|
545
549
|
end
|
|
546
550
|
end
|
|
547
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received read timeout from #{url}") if ex.instance_of?(Net::ReadTimeout)
|
|
551
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received read timeout from #{url}", nil, request) if ex.instance_of?(Net::ReadTimeout)
|
|
548
552
|
raise ex
|
|
549
553
|
rescue => ex
|
|
550
554
|
raise ex
|
|
@@ -553,24 +557,33 @@ module ZuoraAPI
|
|
|
553
557
|
end
|
|
554
558
|
|
|
555
559
|
def raise_errors(type: :SOAP, body: nil, response: nil)
|
|
556
|
-
|
|
557
|
-
|
|
560
|
+
request_uri, request_path, match_string = "", "", ""
|
|
561
|
+
if response.class.to_s == "HTTP::Message"
|
|
562
|
+
request_uri = response.http_header.request_uri.to_s
|
|
563
|
+
request_path = response.http_header.request_uri.path
|
|
564
|
+
match_string = "#{response.http_header.request_method}::#{response.code}::#{request_uri}"
|
|
565
|
+
else
|
|
566
|
+
request = response.request
|
|
567
|
+
request_uri = response.request.uri
|
|
568
|
+
request_path = request.path.path
|
|
569
|
+
match_string = "#{request.http_method.to_s.split("Net::HTTP::").last.upcase}::#{response.code}::#{request_path}"
|
|
570
|
+
end
|
|
558
571
|
|
|
559
572
|
if [502,503].include?(response.code)
|
|
560
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIConnectionTimeout.new("Received #{response.code} from #{
|
|
573
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIConnectionTimeout.new("Received #{response.code} from #{request_uri}", response)
|
|
561
574
|
end
|
|
562
575
|
|
|
563
576
|
# Check failure response code
|
|
564
577
|
case response.code
|
|
565
578
|
when 504
|
|
566
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received 504 from #{
|
|
579
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received 504 from #{request_uri}", response)
|
|
567
580
|
when 429
|
|
568
581
|
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)
|
|
569
582
|
when 401
|
|
570
583
|
|
|
571
584
|
else
|
|
572
585
|
if body.class == Hash
|
|
573
|
-
case
|
|
586
|
+
case request_path
|
|
574
587
|
when /^\/v1\/connections$/
|
|
575
588
|
response_headers = response.headers.to_h
|
|
576
589
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("Missing cookies for authentication call", response) if response_headers['set-cookie'].blank?
|
|
@@ -594,7 +607,7 @@ module ZuoraAPI
|
|
|
594
607
|
reason = body.xpath('//ns2:StatusReason', 'ns2' => 'http://object.api.zuora.com/').text
|
|
595
608
|
if reason.present?
|
|
596
609
|
message = body.xpath('//ns2:StatusReason', 'ns2' => 'http://object.api.zuora.com/').text
|
|
597
|
-
error = message.match(/^[\w\d]{16}\: (Unexpected error.|No HTTP Response|Socket Timeout)/).present? ? 'UNEXPECTED_ERROR' : 'FATAL_ERROR'
|
|
610
|
+
error = message.match(/^[\w\d]{16}\: (Unexpected error.|No HTTP Response|Socket Timeout|There is an internal error, please try again later)/).present? ? 'UNEXPECTED_ERROR' : 'FATAL_ERROR'
|
|
598
611
|
else
|
|
599
612
|
error = 'FATAL_ERROR'
|
|
600
613
|
message = 'Export failed due to unknown reason. Consult api logs.'
|
|
@@ -616,23 +629,10 @@ module ZuoraAPI
|
|
|
616
629
|
end
|
|
617
630
|
end
|
|
618
631
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
elsif response.code == 500
|
|
622
|
-
if response.headers.fetch('content-type', []).include?('application/json')
|
|
623
|
-
begin
|
|
624
|
-
output_json = JSON.parse(response.body)
|
|
625
|
-
self.raise_errors(type: :JSON, body: output_json, response: response)
|
|
626
|
-
rescue JSON::ParserError => ex
|
|
627
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(response.body, response)
|
|
628
|
-
end
|
|
629
|
-
else
|
|
630
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(response.body, response)
|
|
631
|
-
end
|
|
632
|
-
end
|
|
633
|
-
|
|
632
|
+
self.errors_via_content_type(response: response, type: :xml)
|
|
633
|
+
|
|
634
634
|
when :JSON
|
|
635
|
-
case
|
|
635
|
+
case request_path
|
|
636
636
|
when /^\/query\/jobs.*/ #DataQuery Paths
|
|
637
637
|
return if body.class != Hash
|
|
638
638
|
case match_string
|
|
@@ -718,7 +718,6 @@ module ZuoraAPI
|
|
|
718
718
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(50)
|
|
719
719
|
raise ZuoraAPI::Exceptions::ZuoraAPILockCompetition.new("#{messages_array.join(', ')}", response)
|
|
720
720
|
end
|
|
721
|
-
|
|
722
721
|
#Internal Server Error
|
|
723
722
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(60)
|
|
724
723
|
if messages_array.uniq.size == 1
|
|
@@ -729,6 +728,11 @@ module ZuoraAPI
|
|
|
729
728
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("#{messages_array.join(', ')}", response)
|
|
730
729
|
end
|
|
731
730
|
|
|
731
|
+
#Retryiable Service Error
|
|
732
|
+
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(61)
|
|
733
|
+
raise ZuoraAPI::Exceptions::ZuoraAPITemporaryError.new("#{messages_array.join(', ')}", response)
|
|
734
|
+
end
|
|
735
|
+
|
|
732
736
|
#Request exceeded limit
|
|
733
737
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(70)
|
|
734
738
|
raise ZuoraAPI::Exceptions::ZuoraAPIRequestLimit.new("#{messages_array.join(', ')}", response)
|
|
@@ -781,32 +785,56 @@ module ZuoraAPI
|
|
|
781
785
|
end
|
|
782
786
|
end
|
|
783
787
|
|
|
788
|
+
if body.class == Hash && body['message'].present?
|
|
789
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(body['message'], response) if response.code == 500
|
|
790
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(body['message'], response) if ![200,201].include?(response.code)
|
|
791
|
+
end
|
|
792
|
+
|
|
793
|
+
self.errors_via_content_type(response: response, type: :json)
|
|
794
|
+
|
|
784
795
|
#All other errors
|
|
785
|
-
if response.code
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
else
|
|
789
|
-
response_content_types = response.headers.transform_keys(&:downcase).fetch('content-type', []).first || ''
|
|
796
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(response.body, response) if ![200,201].include?(response.code)
|
|
797
|
+
end
|
|
798
|
+
end
|
|
790
799
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
800
|
+
def errors_via_content_type(response: nil, type: :xml)
|
|
801
|
+
response_content_types = response.headers.transform_keys(&:downcase).fetch('content-type', []).first || ""
|
|
802
|
+
|
|
803
|
+
if response_content_types.include?('application/json') && type != :json
|
|
804
|
+
output_json = JSON.parse(response.body)
|
|
805
|
+
self.raise_errors(type: :JSON, body: output_json, response: response)
|
|
806
|
+
|
|
807
|
+
elsif (response_content_types.include?('application/xml') || response_content_types.include?('text/xml')) and type != :xml
|
|
808
|
+
output_xml = Nokogiri::XML(response.body)
|
|
809
|
+
self.raise_errors(type: :SOAP, body: output_xml, response: response)
|
|
810
|
+
|
|
811
|
+
elsif response_content_types.include?('text/html')
|
|
812
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("Akamai Error", response) if response.headers.fetch('server', '') == 'AkamaiGHost'
|
|
813
|
+
|
|
814
|
+
parse_body = Nokogiri::HTML(response.body)
|
|
815
|
+
error_title = parse_body.xpath('//h2').text
|
|
816
|
+
error_title = parse_body.xpath('//h1').text if error_title.blank?
|
|
817
|
+
error_message = parse_body.xpath('//p').text
|
|
818
|
+
|
|
819
|
+
error_message = error_title if error_message.blank?
|
|
820
|
+
|
|
821
|
+
if error_title.present?
|
|
822
|
+
case error_title
|
|
823
|
+
when /Service Unavailable/
|
|
824
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIConnectionTimeout.new(error_message, response)
|
|
825
|
+
when /Client sent a bad request./, /Bad Request/, /403 Forbidden/
|
|
826
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(error_message, response)
|
|
827
|
+
else
|
|
828
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(error_message, response)
|
|
806
829
|
end
|
|
807
830
|
end
|
|
831
|
+
|
|
832
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("Http response body is missing", response) if response.body.blank?
|
|
808
833
|
end
|
|
834
|
+
|
|
835
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(response.body, response) if response.code == 500
|
|
809
836
|
end
|
|
837
|
+
|
|
810
838
|
|
|
811
839
|
def get_soap_error_and_message(body)
|
|
812
840
|
error = body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text
|
|
@@ -870,9 +898,9 @@ module ZuoraAPI
|
|
|
870
898
|
when /.*UNEXPECTED_ERROR/
|
|
871
899
|
raise ZuoraAPI::Exceptions::ZuoraUnexpectedError.new(message, response, errors, success)
|
|
872
900
|
when /.*soapenv:Server.*/
|
|
873
|
-
if /^Invalid value.*for type.*|^Id is invalid
|
|
901
|
+
if /^Invalid value.*for type.*|^Id is invalid|^date string can not be less than 19 charactors$/.match(message).present?
|
|
874
902
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(message, response, errors, success)
|
|
875
|
-
elsif /^Invalid white space character \(.*\) in text to output$/.match(message).present?
|
|
903
|
+
elsif /^Invalid white space character \(.*\) in text to output$|^Invalid null character in text to output$/.match(message).present?
|
|
876
904
|
raise ZuoraAPI::Exceptions::ZuoraAPIUnkownError.new(message, response, errors, success)
|
|
877
905
|
end
|
|
878
906
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(message, response, errors, success)
|
|
@@ -1023,7 +1051,7 @@ module ZuoraAPI
|
|
|
1023
1051
|
modified_headers = {'Content-Type' => "application/json; charset=utf-8"}.merge(authentication_headers).merge(headers)
|
|
1024
1052
|
|
|
1025
1053
|
begin
|
|
1026
|
-
|
|
1054
|
+
request = HTTParty::Request.new(
|
|
1027
1055
|
"Net::HTTP::#{method.to_s.capitalize}".constantize,
|
|
1028
1056
|
url,
|
|
1029
1057
|
body: body,
|
|
@@ -1031,7 +1059,9 @@ module ZuoraAPI
|
|
|
1031
1059
|
timeout: timeout,
|
|
1032
1060
|
multipart: multipart,
|
|
1033
1061
|
stream_body: stream_body
|
|
1034
|
-
)
|
|
1062
|
+
)
|
|
1063
|
+
|
|
1064
|
+
response = request.perform(&block)
|
|
1035
1065
|
|
|
1036
1066
|
Rails.logger.debug("Response Code: #{response.code}") if debug
|
|
1037
1067
|
begin
|
|
@@ -1115,7 +1145,7 @@ module ZuoraAPI
|
|
|
1115
1145
|
Rails.logger.error("Rest Call - #{ex.class} Timed out will retry after #{timeout_sleep_interval} seconds")
|
|
1116
1146
|
end
|
|
1117
1147
|
end
|
|
1118
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received read timeout from #{url}") if ex.instance_of?(Net::ReadTimeout)
|
|
1148
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received read timeout from #{url}", nil, request) if ex.instance_of?(Net::ReadTimeout)
|
|
1119
1149
|
raise ex
|
|
1120
1150
|
rescue => ex
|
|
1121
1151
|
raise ex
|
|
@@ -1298,75 +1328,122 @@ module ZuoraAPI
|
|
|
1298
1328
|
end
|
|
1299
1329
|
end
|
|
1300
1330
|
|
|
1301
|
-
def getDataSourceExport(query, extract: true, encrypted: false, zip: true)
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1331
|
+
def getDataSourceExport(query, extract: true, encrypted: false, zip: true, z_track_id: "")
|
|
1332
|
+
begin
|
|
1333
|
+
tries ||= 3
|
|
1334
|
+
request = Nokogiri::XML::Builder.new do |xml|
|
|
1335
|
+
xml['SOAP-ENV'].Envelope('xmlns:SOAP-ENV' => "http://schemas.xmlsoap.org/soap/envelope/", 'xmlns:ns2' => "http://object.api.zuora.com/", 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xmlns:ns1' => "http://api.zuora.com/") do
|
|
1336
|
+
xml['SOAP-ENV'].Header do
|
|
1337
|
+
xml['ns1'].SessionHeader do
|
|
1338
|
+
xml['ns1'].session self.get_session(prefix: false, auth_type: :basic, zuora_track_id: z_track_id)
|
|
1339
|
+
end
|
|
1307
1340
|
end
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1341
|
+
xml['SOAP-ENV'].Body do
|
|
1342
|
+
xml['ns1'].create do
|
|
1343
|
+
xml['ns1'].zObjects('xsi:type' => "ns2:Export") do
|
|
1344
|
+
xml['ns2'].Format 'csv'
|
|
1345
|
+
xml['ns2'].Zip zip
|
|
1346
|
+
xml['ns2'].Name 'googman'
|
|
1347
|
+
xml['ns2'].Query query
|
|
1348
|
+
xml['ns2'].Encrypted encrypted
|
|
1349
|
+
end
|
|
1317
1350
|
end
|
|
1318
1351
|
end
|
|
1319
1352
|
end
|
|
1320
1353
|
end
|
|
1321
|
-
end
|
|
1322
1354
|
|
|
1323
|
-
|
|
1355
|
+
response_query = HTTParty.post(self.url, body: request.to_xml(:save_with => XML_SAVE_OPTIONS).strip, headers: {'Content-Type' => "application/json; charset=utf-8", "Z-Track-Id" => z_track_id}, :timeout => 120)
|
|
1324
1356
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
id = output_xml.xpath('//ns1:Id', 'ns1' =>'http://api.zuora.com/').text
|
|
1357
|
+
output_xml = Nokogiri::XML(response_query.body)
|
|
1358
|
+
raise_errors(type: :SOAP, body: output_xml, response: response_query) if output_xml.xpath('//ns1:Success', 'ns1' =>'http://api.zuora.com/').text != "true"
|
|
1328
1359
|
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1360
|
+
# raise "Export Creation Unsuccessful : #{response_query.code}: #{response_query.parsed_response}" if output_xml.xpath('//ns1:Success', 'ns1' =>'http://api.zuora.com/').text != "true"
|
|
1361
|
+
|
|
1362
|
+
id = output_xml.xpath('//ns1:Id', 'ns1' =>'http://api.zuora.com/').text
|
|
1363
|
+
|
|
1364
|
+
confirmRequest = Nokogiri::XML::Builder.new do |xml|
|
|
1365
|
+
xml['SOAP-ENV'].Envelope('xmlns:SOAP-ENV' => "http://schemas.xmlsoap.org/soap/envelope/", 'xmlns:ns2' => "http://object.api.zuora.com/", 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xmlns:ns1' => "http://api.zuora.com/") do
|
|
1366
|
+
xml['SOAP-ENV'].Header do
|
|
1367
|
+
xml['ns1'].SessionHeader do
|
|
1368
|
+
xml['ns1'].session self.get_session(prefix: false, auth_type: :basic, zuora_track_id: z_track_id)
|
|
1369
|
+
end
|
|
1334
1370
|
end
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1371
|
+
xml['SOAP-ENV'].Body do
|
|
1372
|
+
xml['ns1'].query do
|
|
1373
|
+
xml['ns1'].queryString "SELECT Id, CreatedById, CreatedDate, Encrypted, FileId, Format, Name, Query, Size, Status, StatusReason, UpdatedById, UpdatedDate, Zip From Export where Id = '#{id}'"
|
|
1374
|
+
end
|
|
1339
1375
|
end
|
|
1340
1376
|
end
|
|
1341
1377
|
end
|
|
1342
|
-
|
|
1343
|
-
result = 'Waiting'
|
|
1378
|
+
result = 'Waiting'
|
|
1344
1379
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1380
|
+
while result != "Completed"
|
|
1381
|
+
sleep 3
|
|
1382
|
+
response_query = HTTParty.post(self.url, body: confirmRequest.to_xml(:save_with => XML_SAVE_OPTIONS).strip, headers: {'Content-Type' => "application/json; charset=utf-8", "Z-Track-Id" => z_track_id}, :timeout => 120)
|
|
1348
1383
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
raise "Export Creation Unsuccessful : #{output_xml.xpath('//ns1:Message', 'ns1' =>'http://api.zuora.com/').text}" if result.blank? || result == "Failed"
|
|
1353
|
-
end
|
|
1384
|
+
output_xml = Nokogiri::XML(response_query.body)
|
|
1385
|
+
result = output_xml.xpath('//ns2:Status', 'ns2' =>'http://object.api.zuora.com/').text
|
|
1386
|
+
status_code = response_query.code if response_query
|
|
1354
1387
|
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1388
|
+
raise_errors(type: :SOAP, body: output_xml, response: response_query) if result.blank? || result == "Failed"
|
|
1389
|
+
# raise "Export Creation Unsuccessful : #{response_query.code}: #{response_query.parsed_response}" if result.blank? || result == "Failed"
|
|
1390
|
+
end
|
|
1391
|
+
|
|
1392
|
+
file_id = output_xml.xpath('//ns2:FileId', 'ns2' =>'http://object.api.zuora.com/').text
|
|
1393
|
+
export_file = get_file(:url => self.fileURL(file_id))
|
|
1394
|
+
export_file_path = export_file.path
|
|
1395
|
+
Rails.logger.debug("=====> Export path #{export_file.path}")
|
|
1396
|
+
|
|
1397
|
+
if extract && zip
|
|
1398
|
+
require "zip"
|
|
1399
|
+
new_path = export_file_path.partition('.zip').first
|
|
1400
|
+
zipped = Zip::File.open(export_file_path)
|
|
1401
|
+
file_handle = zipped.entries.first
|
|
1402
|
+
file_handle.extract(new_path)
|
|
1403
|
+
File.delete(export_file_path)
|
|
1404
|
+
return new_path
|
|
1405
|
+
else
|
|
1406
|
+
return export_file_path
|
|
1407
|
+
end
|
|
1408
|
+
rescue ZuoraAPI::Exceptions::ZuoraAPISessionError => ex
|
|
1409
|
+
if !(tries -= 1).zero?
|
|
1410
|
+
Rails.logger.info("Export call failed - Trace ID: #{z_track_id}")
|
|
1411
|
+
self.new_session
|
|
1412
|
+
retry
|
|
1413
|
+
else
|
|
1414
|
+
raise ex
|
|
1415
|
+
end
|
|
1416
|
+
|
|
1417
|
+
rescue ZuoraAPI::Exceptions::ZuoraUnexpectedError => ex
|
|
1418
|
+
if !(tries -= 1).zero?
|
|
1419
|
+
Rails.logger.info("Trace ID: #{z_track_id} UnexpectedError, will retry after 10 seconds")
|
|
1420
|
+
sleep 10
|
|
1421
|
+
retry
|
|
1422
|
+
else
|
|
1423
|
+
raise ex
|
|
1424
|
+
end
|
|
1425
|
+
|
|
1426
|
+
rescue *ZUORA_API_ERRORS => ex
|
|
1427
|
+
raise ex
|
|
1428
|
+
|
|
1429
|
+
rescue *(CONNECTION_EXCEPTIONS + CONNECTION_READ_EXCEPTIONS) => ex
|
|
1430
|
+
if !(tries -= 1).zero?
|
|
1431
|
+
Rails.logger.info("Trace ID: #{z_track_id} Timed out will retry after 5 seconds")
|
|
1432
|
+
sleep 5
|
|
1433
|
+
retry
|
|
1434
|
+
else
|
|
1435
|
+
raise ex
|
|
1436
|
+
end
|
|
1437
|
+
|
|
1438
|
+
rescue Errno::ECONNRESET => ex
|
|
1439
|
+
if !(tries -= 1).zero? && ex.message.include?('SSL_connect')
|
|
1440
|
+
retry
|
|
1441
|
+
else
|
|
1442
|
+
raise ex
|
|
1443
|
+
end
|
|
1444
|
+
|
|
1445
|
+
rescue ZuoraAPI::Exceptions::BadEntityError => ex
|
|
1446
|
+
raise ex
|
|
1370
1447
|
end
|
|
1371
1448
|
end
|
|
1372
1449
|
|
|
@@ -46,34 +46,28 @@ module ZuoraAPI
|
|
|
46
46
|
Rails.logger.debug {"Session Invalid"}
|
|
47
47
|
self.new_session(auth_type: :bearer)
|
|
48
48
|
retry
|
|
49
|
-
else
|
|
50
|
-
if errors.include?(ex.class)
|
|
51
|
-
raise ex
|
|
52
|
-
else
|
|
53
|
-
return [output_json, response]
|
|
54
|
-
end
|
|
55
49
|
end
|
|
50
|
+
raise ex if errors.include?(ex.class)
|
|
51
|
+
return [output_json, response]
|
|
52
|
+
|
|
56
53
|
rescue ZuoraAPI::Exceptions::ZuoraAPIError, ZuoraAPI::Exceptions::ZuoraAPIRequestLimit, ZuoraAPI::Exceptions::ZuoraAPILockCompetition => ex
|
|
57
|
-
if errors.include?(ex.class)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return [output_json, response]
|
|
61
|
-
end
|
|
54
|
+
raise ex if errors.include?(ex.class)
|
|
55
|
+
return [output_json, response]
|
|
56
|
+
|
|
62
57
|
rescue *(CONNECTION_EXCEPTIONS + CONNECTION_READ_EXCEPTIONS) => ex
|
|
63
58
|
if !tries.zero?
|
|
64
59
|
tries -= 1
|
|
65
60
|
sleep(self.timeout_sleep)
|
|
66
61
|
retry
|
|
62
|
+
end
|
|
63
|
+
if Rails.logger.class.to_s == "Ougai::Logger"
|
|
64
|
+
Rails.logger.error("OAuthLogin - Timed out", ex)
|
|
67
65
|
else
|
|
68
|
-
|
|
69
|
-
Rails.logger.error("OAuthLogin - Timed out", ex)
|
|
70
|
-
else
|
|
71
|
-
Rails.logger.error("OAuthLogin - #{ex.class} Timed out")
|
|
72
|
-
end
|
|
73
|
-
self.current_error = "Request timed out. Try again"
|
|
74
|
-
self.status = 'Timeout'
|
|
75
|
-
return self.status
|
|
66
|
+
Rails.logger.error("OAuthLogin - #{ex.class} Timed out")
|
|
76
67
|
end
|
|
68
|
+
self.current_error = "Request timed out. Try again"
|
|
69
|
+
self.status = 'Timeout'
|
|
70
|
+
return self.status
|
|
77
71
|
end
|
|
78
72
|
|
|
79
73
|
def get_bearer_token(zuora_track_id: nil)
|
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.7.
|
|
4
|
+
version: 1.7.66
|
|
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-
|
|
11
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -182,9 +182,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
182
182
|
version: '0'
|
|
183
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
requirements:
|
|
185
|
-
- - "
|
|
185
|
+
- - ">="
|
|
186
186
|
- !ruby/object:Gem::Version
|
|
187
|
-
version:
|
|
187
|
+
version: '0'
|
|
188
188
|
requirements: []
|
|
189
189
|
rubygems_version: 3.0.3
|
|
190
190
|
signing_key:
|