zuora_api 1.8.21 → 1.9.02
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/README.md +9 -0
- data/lib/zuora_api.rb +2 -0
- data/lib/zuora_api/exceptions.rb +1 -1
- data/lib/zuora_api/login.rb +80 -118
- data/lib/zuora_api/version.rb +1 -1
- metadata +38 -25
- data/.gitignore +0 -11
- data/.gitlab-ci.yml +0 -63
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/CHANGELOG.md +0 -105
- data/Gemfile +0 -4
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/catalog-info.yaml +0 -12
- data/docs/index.md +0 -147
- data/gemfiles/Gemfile-rails.5.0.x +0 -5
- data/gemfiles/Gemfile-rails.5.1.x +0 -5
- data/gemfiles/Gemfile-rails.5.2.x +0 -5
- data/gemfiles/Gemfile-rails.6.0.x +0 -5
- data/zuora_api.gemspec +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 920e55fd117bee280019ee427eaa7ab863c2815845589dd635410d0748d0758d
|
4
|
+
data.tar.gz: f491d59d805dcdccfa3c4ede48ca0bf45ed4e14d3325a6ab4d7da90a3c682eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94956aa752fef26412f20338aa0172a2a66dfb96f0c61f5a18c9953ab3ee63353e6e6ca220e4dc08a23b21f2b6bb53f00cb2e6f47a2e6325f3e1d7c2bb594d97
|
7
|
+
data.tar.gz: 7d7d858162755f632cce0daf4bdd605c96af943477e55b5f17f2bda5d5b6e2cfb80c3a5325d86572f5d9e93ee3384ce1ecd2ba16e86da7dbcd32c1a450128333
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2021 Zuora, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -145,3 +145,12 @@ Both do the same thing except one returns a url(data_export_insights) to downloa
|
|
145
145
|
objectype: "ACCOUNT/USER"
|
146
146
|
|
147
147
|
segmentuuid: A single or array of string or int of a segment uuid(s) that you get from the describe call. The csv holds a column with a bool that represents if that User or Account belongs to that segment.
|
148
|
+
|
149
|
+
### License Information
|
150
|
+
IN THE EVENT YOU ARE AN EXISTING ZUORA CUSTOMER, USE OF THIS SOFTWARE IS GOVERNEDBY THE MIT LICENSE SET FORTH BELOW AND NOT THE MASTER SUBSCRIPTION AGREEMENT OR OTHER COMMERCIAL AGREEMENT ENTERED INTO BETWEEN YOU AND ZUORA (“AGREEMENT”). FOR THE AVOIDANCE OF DOUBT, ZUORA’S OBLIGATIONS WITH RESPECT TO TECHNICAL SUPPORT, UPTIME, INDEMNIFICATION, AND SECURITY SET FORTH IN THE AGREEMENT DO NOT APPLY TO THE USE OF THIS SOFTWARE.
|
151
|
+
|
152
|
+
Copyright 2021 Zuora, Inc.
|
153
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
154
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
155
|
+
|
156
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/zuora_api.rb
CHANGED
data/lib/zuora_api/exceptions.rb
CHANGED
data/lib/zuora_api/login.rb
CHANGED
@@ -21,7 +21,7 @@ module ZuoraAPI
|
|
21
21
|
].freeze
|
22
22
|
|
23
23
|
CONNECTION_READ_EXCEPTIONS = [
|
24
|
-
|
24
|
+
Timeout::Error,
|
25
25
|
Errno::ECONNRESET,
|
26
26
|
Errno::EPIPE
|
27
27
|
].freeze
|
@@ -43,7 +43,7 @@ module ZuoraAPI
|
|
43
43
|
ZuoraAPI::Exceptions::ZuoraAPIReadTimeout,
|
44
44
|
ZuoraAPI::Exceptions::ZuoraUnexpectedError
|
45
45
|
].freeze
|
46
|
-
|
46
|
+
|
47
47
|
attr_accessor :region, :url, :wsdl_number, :current_session, :bearer_token, :oauth_session_expires_at, :environment, :status, :errors, :current_error, :user_info, :tenant_id, :tenant_name, :entity_id, :timeout_sleep, :hostname, :zconnect_provider
|
48
48
|
|
49
49
|
def initialize(url: nil, entity_id: nil, session: nil, status: nil, bearer_token: nil, oauth_session_expires_at: nil, **keyword_args)
|
@@ -299,7 +299,7 @@ module ZuoraAPI
|
|
299
299
|
update_environment
|
300
300
|
endpoint = url
|
301
301
|
url_postfix = {"US" => ".", "EU" => ".eu.", "NA" => ".na."}[self.region]
|
302
|
-
|
302
|
+
|
303
303
|
case self.environment
|
304
304
|
when 'Test'
|
305
305
|
endpoint = "https://rest.test#{url_postfix}zuora.com"
|
@@ -351,7 +351,7 @@ module ZuoraAPI
|
|
351
351
|
retries -= 1
|
352
352
|
sleep(self.timeout_sleep)
|
353
353
|
retry
|
354
|
-
|
354
|
+
|
355
355
|
rescue *(CONNECTION_EXCEPTIONS + CONNECTION_READ_EXCEPTIONS) => ex
|
356
356
|
self.log(location: "BasicLogin", exception: ex, message: "Timed out", level: :error)
|
357
357
|
|
@@ -402,18 +402,18 @@ module ZuoraAPI
|
|
402
402
|
end
|
403
403
|
|
404
404
|
def soap_call(
|
405
|
-
ns1: 'ns1',
|
406
|
-
ns2: 'ns2',
|
405
|
+
ns1: 'ns1',
|
406
|
+
ns2: 'ns2',
|
407
407
|
batch_size: nil,
|
408
408
|
headers: {},
|
409
|
-
single_transaction: false,
|
410
|
-
debug: false,
|
411
|
-
zuora_track_id: nil,
|
412
|
-
errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError].concat(ZUORA_API_ERRORS),
|
413
|
-
z_session: true,
|
414
|
-
timeout_retry: false,
|
409
|
+
single_transaction: false,
|
410
|
+
debug: false,
|
411
|
+
zuora_track_id: nil,
|
412
|
+
errors: [ZuoraAPI::Exceptions::ZuoraAPISessionError].concat(ZUORA_API_ERRORS),
|
413
|
+
z_session: true,
|
414
|
+
timeout_retry: false,
|
415
415
|
timeout: 130,
|
416
|
-
timeout_sleep_interval: self.timeout_sleep,
|
416
|
+
timeout_sleep_interval: self.timeout_sleep,
|
417
417
|
output_exception_messages: true,
|
418
418
|
skip_session: false,
|
419
419
|
**keyword_args)
|
@@ -484,17 +484,17 @@ module ZuoraAPI
|
|
484
484
|
|
485
485
|
retry
|
486
486
|
end
|
487
|
-
|
487
|
+
|
488
488
|
raise ex if errors.include?(ex.class)
|
489
|
-
|
489
|
+
|
490
490
|
return output_xml, input_xml, response
|
491
|
-
|
491
|
+
|
492
492
|
rescue *ZUORA_API_ERRORS => ex
|
493
493
|
raise ex if errors.include?(ex.class)
|
494
|
-
|
494
|
+
|
495
495
|
response = ex.response unless response
|
496
496
|
return output_xml, input_xml, response
|
497
|
-
|
497
|
+
|
498
498
|
rescue *CONNECTION_EXCEPTIONS => ex
|
499
499
|
if !tries.zero?
|
500
500
|
tries -= 1
|
@@ -504,8 +504,8 @@ module ZuoraAPI
|
|
504
504
|
end
|
505
505
|
|
506
506
|
self.log(location: "SOAP Call", exception: ex, message: "Timed out", level: :error) if output_exception_messages
|
507
|
-
raise ex
|
508
|
-
|
507
|
+
raise ex
|
508
|
+
|
509
509
|
rescue *CONNECTION_READ_EXCEPTIONS => ex
|
510
510
|
if !tries.zero?
|
511
511
|
tries -= 1
|
@@ -519,16 +519,18 @@ module ZuoraAPI
|
|
519
519
|
end
|
520
520
|
|
521
521
|
self.log(location: "SOAP Call", exception: ex, message: "Timed out", level: :error) if output_exception_messages
|
522
|
-
ex = ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received read timeout from 'https://#{rest_domain(endpoint: url)}'", nil, request) if ex.instance_of?(
|
522
|
+
ex = ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received read/write timeout from 'https://#{rest_domain(endpoint: url)}'", nil, request) if ex.is_a?(Timeout::Error) && !ex.instance_of?(ZuoraAPI::Exceptions::ZuoraAPIReadTimeout)
|
523
523
|
raise ex
|
524
524
|
|
525
525
|
rescue => ex
|
526
526
|
raise ex
|
527
|
-
ensure
|
528
|
-
self.error_logger(ex) if defined?(ex)
|
527
|
+
ensure
|
528
|
+
self.error_logger(ex) if defined?(ex)
|
529
529
|
end
|
530
530
|
|
531
531
|
def error_logger(ex)
|
532
|
+
return unless Rails.logger.is_a? Ougai::Logger
|
533
|
+
|
532
534
|
exception_args = Rails.logger.with_fields.merge(self.exception_args(ex))
|
533
535
|
case ex
|
534
536
|
when ZuoraAPI::Exceptions::ZuoraAPIUnkownError, ZuoraAPI::Exceptions::ZuoraDataIntegrity
|
@@ -544,10 +546,10 @@ module ZuoraAPI
|
|
544
546
|
|
545
547
|
def log(location: "Rest Call", exception: nil, message: "Timed out will retry after #{self.timeout_sleep} seconds", level: :info )
|
546
548
|
level = :debug if ![:debug, :info, :warn, :error, :fatal].include?(level)
|
547
|
-
if Rails.logger.
|
548
|
-
Rails.logger.send(level.to_sym, "#{location} - #{message}", exception)
|
549
|
+
if Rails.logger.is_a? Ougai::Logger
|
550
|
+
Rails.logger.send(level.to_sym, "#{location} - #{message}", exception)
|
549
551
|
else
|
550
|
-
Rails.logger.send(level.to_sym, "#{location} - #{exception.class} #{message}")
|
552
|
+
Rails.logger.send(level.to_sym, "#{location} - #{exception.class} #{message}")
|
551
553
|
end
|
552
554
|
end
|
553
555
|
|
@@ -555,27 +557,27 @@ module ZuoraAPI
|
|
555
557
|
args = {}
|
556
558
|
if defined?(ex.response) && ex.response.present?
|
557
559
|
args.merge!({
|
560
|
+
url: {full: ex.response.request.path.to_s},
|
558
561
|
request: {
|
559
|
-
path: ex.response.request.path.to_s,
|
560
562
|
method: ex.response.request.http_method.to_s.split("Net::HTTP::").last.upcase,
|
561
563
|
params: ex.response.request.raw_body.to_s,
|
562
|
-
|
564
|
+
headers_blob: ex.response.request.options[:headers].map{|k,v| [k.to_s, k.to_s.downcase.strip == "authorization" ? "VALUE FILTERED" : v]}.to_h.to_s,
|
563
565
|
},
|
564
566
|
response: {
|
565
567
|
status: ex.response.code,
|
566
568
|
params: ex.response.body.to_s,
|
567
|
-
|
569
|
+
headers_blob: ex.response.headers.to_s,
|
568
570
|
},
|
569
571
|
zuora_trace_id: ex.response.headers["zuora-request-id"],
|
570
572
|
zuora_track_id: ex.response.request.options[:headers]["Zuora-Track-Id"],
|
571
573
|
})
|
572
574
|
elsif defined?(ex.request) && ex.request.present?
|
573
575
|
args.merge!({
|
576
|
+
url: {full: ex.request.path.to_s},
|
574
577
|
request: {
|
575
|
-
path: ex.request.path.to_s,
|
576
578
|
method: ex.request.http_method.to_s.split("Net::HTTP::").last.upcase,
|
577
579
|
params: ex.request.options[:body],
|
578
|
-
|
580
|
+
headers_blob: ex.request.options[:headers].map{|k,v| [k.to_s, k.to_s.downcase.strip == "authorization" ? "VALUE FILTERED" : v]}.to_h.to_s
|
579
581
|
}
|
580
582
|
})
|
581
583
|
args.merge!({
|
@@ -612,14 +614,14 @@ module ZuoraAPI
|
|
612
614
|
when 429
|
613
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)
|
614
616
|
when 401
|
615
|
-
|
617
|
+
|
616
618
|
else
|
617
619
|
if body.class == Hash
|
618
620
|
case request_path
|
619
621
|
when /^\/v1\/connections$/
|
620
|
-
response_headers = response.headers.to_h
|
622
|
+
response_headers = response.headers.to_h
|
621
623
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("Missing cookies for authentication call", response) if response_headers['set-cookie'].blank?
|
622
|
-
z_session_cookie = response_headers.fetch('set-cookie', []).select{|x| x.match(/^ZSession=.*/) }.first
|
624
|
+
z_session_cookie = response_headers.fetch('set-cookie', []).select{|x| x.match(/^ZSession=.*/) }.first
|
623
625
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("Missing ZSession cookie for authentication call", response) if z_session_cookie.blank?
|
624
626
|
end
|
625
627
|
end
|
@@ -629,7 +631,7 @@ module ZuoraAPI
|
|
629
631
|
when :SOAP
|
630
632
|
error, success, message = get_soap_error_and_message(body)
|
631
633
|
|
632
|
-
if body.xpath('//fns:LoginFault', 'fns' =>'http://fault.api.zuora.com/').present?
|
634
|
+
if body.xpath('//fns:LoginFault', 'fns' =>'http://fault.api.zuora.com/').present?
|
633
635
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(message, response)
|
634
636
|
end
|
635
637
|
|
@@ -645,6 +647,7 @@ module ZuoraAPI
|
|
645
647
|
if message.present?
|
646
648
|
identifier, new_message = message.scan(/^([\w\d]{16})\: (.*)/).first
|
647
649
|
error, message = ['UNEXPECTED_ERROR', new_message] if new_message.present?
|
650
|
+
error, message = ['TRANSACTION_FAILED', new_message.concat(" Please see KC for the Max Timeout Specification https://community.zuora.com/t5/Release-Notifications/Upcoming-Change-for-AQuA-and-Data-Source-Export-January-2021/ba-p/35024")] if new_message.include?("The query exceeded maximum processing time")
|
648
651
|
else
|
649
652
|
message = 'Export failed due to unknown reason. Consult api logs.'
|
650
653
|
end
|
@@ -666,19 +669,19 @@ module ZuoraAPI
|
|
666
669
|
end
|
667
670
|
|
668
671
|
self.errors_via_content_type(response: response, type: :xml)
|
669
|
-
|
672
|
+
|
670
673
|
when :JSON
|
671
674
|
case request_path
|
672
675
|
when /^\/query\/jobs.*/ #DataQuery Paths
|
673
676
|
return if body.class != Hash
|
674
677
|
case match_string
|
675
|
-
when /^GET::200::\/query\/jobs\/([a-zA-Z0-9\-_]+)$/ #Get DQ job, Capture of the id is present if needed in future error responses.
|
678
|
+
when /^GET::200::\/query\/jobs\/([a-zA-Z0-9\-_]+)$/ #Get DQ job, Capture of the id is present if needed in future error responses.
|
676
679
|
if body.dig('data', "errorCode") == "LINK_10000005"
|
677
680
|
raise ZuoraAPI::Exceptions::ZuoraAPITemporaryError.new(body.dig('data', "errorMessage"), response)
|
678
|
-
elsif (body.dig('data', "errorMessage").present? || body.dig('data', "queryStatus") == "failed")
|
681
|
+
elsif (body.dig('data', "errorMessage").present? || body.dig('data', "queryStatus") == "failed")
|
679
682
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(body.dig('data', "errorMessage"), response)
|
680
683
|
end
|
681
|
-
when /^GET::404::\/query\/jobs\/([a-zA-Z0-9\-_]+)$/ #Get DQ job not found, capture of the id is present if needed in future error responses.
|
684
|
+
when /^GET::404::\/query\/jobs\/([a-zA-Z0-9\-_]+)$/ #Get DQ job not found, capture of the id is present if needed in future error responses.
|
682
685
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(body.dig('message'), response) if body.dig('message').present?
|
683
686
|
when /^POST::400::\/query\/jobs$/ #Create DQ job
|
684
687
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(body.dig('message'), response) if body.dig('message').present?
|
@@ -741,7 +744,7 @@ module ZuoraAPI
|
|
741
744
|
end
|
742
745
|
|
743
746
|
#Oauth Tokens - User deactivated
|
744
|
-
if body['path'] == '/oauth/token'
|
747
|
+
if body['path'] == '/oauth/token'
|
745
748
|
if body['status'] == 403 && response.code == 403
|
746
749
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("Forbidden", response)
|
747
750
|
elsif body['status'] == 400 && response.code == 400 && body['message'].include?("Invalid client id")
|
@@ -752,7 +755,7 @@ module ZuoraAPI
|
|
752
755
|
if body['error'] == 'Unauthorized' && body['status'] == 401
|
753
756
|
if body['message'].present?
|
754
757
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(body['message'], response)
|
755
|
-
else
|
758
|
+
else
|
756
759
|
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("#{messages_array.join(', ')}", response)
|
757
760
|
end
|
758
761
|
end
|
@@ -777,7 +780,7 @@ module ZuoraAPI
|
|
777
780
|
end
|
778
781
|
#Internal Server Error
|
779
782
|
if codes_array.map{|code| code.to_s.slice(6,7).to_i}.include?(60)
|
780
|
-
if messages_array.uniq.size == 1
|
783
|
+
if messages_array.uniq.size == 1
|
781
784
|
if messages_array.first.match(/^Transaction declined.*|^There is an invoice pending tax.*|^The Zuora GetTax call to Avalara.*|^The tax calculation call to Zuora Connect returned the following error: Status Code: 4.*/)
|
782
785
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(messages_array.first, response)
|
783
786
|
end
|
@@ -850,17 +853,17 @@ module ZuoraAPI
|
|
850
853
|
self.errors_via_content_type(response: response, type: :json)
|
851
854
|
|
852
855
|
#All other errors
|
853
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(response.body, response) if ![200,201].include?(response.code)
|
856
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(response.body, response) if ![200,201].include?(response.code)
|
854
857
|
end
|
855
858
|
end
|
856
859
|
|
857
860
|
def errors_via_content_type(response: nil, type: :xml)
|
858
861
|
response_content_types = response.headers.transform_keys(&:downcase).fetch('content-type', []).first || ""
|
859
|
-
|
862
|
+
|
860
863
|
if response_content_types.include?('application/json') && type != :json
|
861
864
|
output_json = JSON.parse(response.body)
|
862
865
|
self.raise_errors(type: :JSON, body: output_json, response: response)
|
863
|
-
|
866
|
+
|
864
867
|
elsif (response_content_types.include?('application/xml') || response_content_types.include?('text/xml') || response_content_types.include?('application/soap+xml')) and type != :xml
|
865
868
|
output_xml = Nokogiri::XML(response.body)
|
866
869
|
self.raise_errors(type: :SOAP, body: output_xml, response: response)
|
@@ -880,10 +883,10 @@ module ZuoraAPI
|
|
880
883
|
when /Service Unavailable/
|
881
884
|
raise ZuoraAPI::Exceptions::ZuoraAPIConnectionTimeout.new(error_message, response)
|
882
885
|
when /Client sent a bad request./, /Bad Request/, /403 Forbidden/
|
883
|
-
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(error_message, response)
|
886
|
+
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(error_message, response)
|
884
887
|
when /414 Request-URI Too Large/
|
885
888
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("Request URL is too long", response)
|
886
|
-
else
|
889
|
+
else
|
887
890
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(error_message, response)
|
888
891
|
end
|
889
892
|
end
|
@@ -893,7 +896,7 @@ module ZuoraAPI
|
|
893
896
|
|
894
897
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(response.body, response) if response.code == 500
|
895
898
|
end
|
896
|
-
|
899
|
+
|
897
900
|
|
898
901
|
def get_soap_error_and_message(body)
|
899
902
|
error = body.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text
|
@@ -973,7 +976,7 @@ module ZuoraAPI
|
|
973
976
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new(message, response, errors, success)
|
974
977
|
end
|
975
978
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new(message, response, errors, success)
|
976
|
-
else
|
979
|
+
else
|
977
980
|
raise ZuoraAPI::Exceptions::ZuoraAPIInternalServerError.new("Z:#{error}::#{message}", response, errors, success)
|
978
981
|
end
|
979
982
|
end
|
@@ -1093,7 +1096,7 @@ module ZuoraAPI
|
|
1093
1096
|
session_type: :basic,
|
1094
1097
|
timeout_retry: false,
|
1095
1098
|
timeout: 130,
|
1096
|
-
timeout_sleep_interval: self.timeout_sleep,
|
1099
|
+
timeout_sleep_interval: self.timeout_sleep,
|
1097
1100
|
multipart: false,
|
1098
1101
|
stream_body: false,
|
1099
1102
|
output_exception_messages: true,
|
@@ -1152,7 +1155,7 @@ module ZuoraAPI
|
|
1152
1155
|
end
|
1153
1156
|
Rails.logger.debug("Rest Call - Session Bad Auth type")
|
1154
1157
|
raise ex
|
1155
|
-
|
1158
|
+
|
1156
1159
|
rescue ZuoraAPI::Exceptions::ZuoraAPISessionError => ex
|
1157
1160
|
if !tries.zero? && z_session
|
1158
1161
|
tries -= 1
|
@@ -1169,13 +1172,13 @@ module ZuoraAPI
|
|
1169
1172
|
|
1170
1173
|
raise ex if errors.include?(ex.class)
|
1171
1174
|
return [output_json, response]
|
1172
|
-
|
1175
|
+
|
1173
1176
|
rescue *ZUORA_API_ERRORS => ex
|
1174
1177
|
raise ex if errors.include?(ex.class)
|
1175
|
-
|
1178
|
+
|
1176
1179
|
response = ex.response unless response
|
1177
1180
|
return [output_json, response]
|
1178
|
-
|
1181
|
+
|
1179
1182
|
rescue ZuoraAPI::Exceptions::BadEntityError => ex
|
1180
1183
|
raise ex
|
1181
1184
|
rescue *CONNECTION_EXCEPTIONS => ex
|
@@ -1187,8 +1190,8 @@ module ZuoraAPI
|
|
1187
1190
|
end
|
1188
1191
|
|
1189
1192
|
self.log(location: "Rest Call", exception: ex, message: "Timed out", level: :error) if output_exception_messages
|
1190
|
-
raise ex
|
1191
|
-
|
1193
|
+
raise ex
|
1194
|
+
|
1192
1195
|
rescue *CONNECTION_READ_EXCEPTIONS => ex
|
1193
1196
|
|
1194
1197
|
if !tries.zero?
|
@@ -1201,15 +1204,15 @@ module ZuoraAPI
|
|
1201
1204
|
retry
|
1202
1205
|
end
|
1203
1206
|
end
|
1204
|
-
|
1207
|
+
|
1205
1208
|
self.log(location: "Rest Call", exception: ex, message: "Timed out", level: :error) if output_exception_messages
|
1206
|
-
ex = ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received read timeout from 'https://#{rest_domain(endpoint: url)}'", nil, request) if ex.instance_of?(
|
1209
|
+
ex = ZuoraAPI::Exceptions::ZuoraAPIReadTimeout.new("Received read/write timeout from 'https://#{rest_domain(endpoint: url)}'", nil, request) if ex.is_a?(Timeout::Error) && !ex.instance_of?(ZuoraAPI::Exceptions::ZuoraAPIReadTimeout)
|
1207
1210
|
raise ex
|
1208
1211
|
|
1209
1212
|
rescue => ex
|
1210
1213
|
raise ex
|
1211
|
-
ensure
|
1212
|
-
self.error_logger(ex) if defined?(ex)
|
1214
|
+
ensure
|
1215
|
+
self.error_logger(ex) if defined?(ex)
|
1213
1216
|
end
|
1214
1217
|
|
1215
1218
|
def update_create_tenant
|
@@ -1266,7 +1269,7 @@ module ZuoraAPI
|
|
1266
1269
|
|
1267
1270
|
#Make sure directory exists
|
1268
1271
|
require 'fileutils'
|
1269
|
-
FileUtils.mkdir_p(file_path) unless File.
|
1272
|
+
FileUtils.mkdir_p(file_path) unless File.exist?(file_path)
|
1270
1273
|
|
1271
1274
|
status_code = nil
|
1272
1275
|
uri = URI.parse(url)
|
@@ -1395,68 +1398,34 @@ module ZuoraAPI
|
|
1395
1398
|
|
1396
1399
|
def getDataSourceExport(query, extract: true, encrypted: false, zip: true, z_track_id: "")
|
1397
1400
|
tries ||= 3
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
xml['
|
1407
|
-
xml['ns1'].zObjects('xsi:type' => "ns2:Export") do
|
1408
|
-
xml['ns2'].Format 'csv'
|
1409
|
-
xml['ns2'].Zip zip
|
1410
|
-
xml['ns2'].Name 'googman'
|
1411
|
-
xml['ns2'].Query query
|
1412
|
-
xml['ns2'].Encrypted encrypted
|
1413
|
-
end
|
1414
|
-
end
|
1401
|
+
|
1402
|
+
output_xml, input_xml = self.soap_call(debug: false, timeout_retry: true, zuora_track_id: z_track_id) do |xml|
|
1403
|
+
xml['ns1'].create do
|
1404
|
+
xml['ns1'].zObjects('xsi:type' => "ns2:Export") do
|
1405
|
+
xml['ns2'].Format 'csv'
|
1406
|
+
xml['ns2'].Zip zip
|
1407
|
+
xml['ns2'].Name 'googman'
|
1408
|
+
xml['ns2'].Query query
|
1409
|
+
xml['ns2'].Encrypted encrypted
|
1415
1410
|
end
|
1416
1411
|
end
|
1417
1412
|
end
|
1418
|
-
|
1419
|
-
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 => 130)
|
1420
|
-
|
1421
|
-
output_xml = Nokogiri::XML(response_query.body)
|
1422
|
-
raise_errors(type: :SOAP, body: output_xml, response: response_query) if output_xml.xpath('//ns1:Success', 'ns1' =>'http://api.zuora.com/').text != "true"
|
1423
|
-
|
1424
|
-
# raise "Export Creation Unsuccessful : #{response_query.code}: #{response_query.parsed_response}" if output_xml.xpath('//ns1:Success', 'ns1' =>'http://api.zuora.com/').text != "true"
|
1425
|
-
|
1426
1413
|
id = output_xml.xpath('//ns1:Id', 'ns1' =>'http://api.zuora.com/').text
|
1427
1414
|
|
1428
|
-
confirmRequest = Nokogiri::XML::Builder.new do |xml|
|
1429
|
-
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
|
1430
|
-
xml['SOAP-ENV'].Header do
|
1431
|
-
xml['ns1'].SessionHeader do
|
1432
|
-
xml['ns1'].session self.get_session(prefix: false, auth_type: :basic, zuora_track_id: z_track_id)
|
1433
|
-
end
|
1434
|
-
end
|
1435
|
-
xml['SOAP-ENV'].Body do
|
1436
|
-
xml['ns1'].query do
|
1437
|
-
xml['ns1'].queryString "SELECT Id, CreatedById, CreatedDate, Encrypted, FileId, Format, Name, Query, Size, Status, StatusReason, UpdatedById, UpdatedDate, Zip From Export where Id = '#{id}'"
|
1438
|
-
end
|
1439
|
-
end
|
1440
|
-
end
|
1441
|
-
end
|
1442
1415
|
result = 'Waiting'
|
1443
|
-
|
1444
1416
|
while result != "Completed"
|
1445
1417
|
sleep 3
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1418
|
+
output_xml, input_xml = self.soap_call(debug: false, timeout_retry: true, zuora_track_id: z_track_id) do |xml|
|
1419
|
+
xml['ns1'].query do
|
1420
|
+
xml['ns1'].queryString "SELECT Id, CreatedById, CreatedDate, Encrypted, FileId, Format, Name, Query, Size, Status, StatusReason, UpdatedById, UpdatedDate, Zip From Export where Id = '#{id}'"
|
1421
|
+
end
|
1422
|
+
end
|
1449
1423
|
result = output_xml.xpath('//ns2:Status', 'ns2' =>'http://object.api.zuora.com/').text
|
1450
|
-
status_code = response_query.code if response_query
|
1451
|
-
|
1452
|
-
raise_errors(type: :SOAP, body: output_xml, response: response_query) if result.blank? || result == "Failed"
|
1453
|
-
# raise "Export Creation Unsuccessful : #{response_query.code}: #{response_query.parsed_response}" if result.blank? || result == "Failed"
|
1454
1424
|
end
|
1455
1425
|
|
1456
1426
|
file_id = output_xml.xpath('//ns2:FileId', 'ns2' =>'http://object.api.zuora.com/').text
|
1457
1427
|
export_file = get_file(:url => self.fileURL(file_id))
|
1458
1428
|
export_file_path = export_file.path
|
1459
|
-
Rails.logger.debug("=====> Export path #{export_file.path}")
|
1460
1429
|
|
1461
1430
|
if extract && zip
|
1462
1431
|
require "zip"
|
@@ -1480,24 +1449,17 @@ module ZuoraAPI
|
|
1480
1449
|
rescue ZuoraAPI::Exceptions::ZuoraUnexpectedError => ex
|
1481
1450
|
if !(tries -= 1).zero?
|
1482
1451
|
Rails.logger.info("Trace ID: #{z_track_id} UnexpectedError, will retry after 10 seconds")
|
1483
|
-
sleep
|
1452
|
+
sleep(self.timeout_sleep)
|
1484
1453
|
retry
|
1485
1454
|
end
|
1486
1455
|
raise ex
|
1487
|
-
|
1488
|
-
rescue *ZUORA_API_ERRORS => ex
|
1489
|
-
raise ex
|
1490
|
-
|
1491
1456
|
rescue *(CONNECTION_EXCEPTIONS + CONNECTION_READ_EXCEPTIONS) => ex
|
1492
1457
|
if !(tries -= 1).zero?
|
1493
1458
|
Rails.logger.info("Trace ID: #{z_track_id} Timed out will retry after 5 seconds")
|
1494
|
-
sleep
|
1459
|
+
sleep(self.timeout_sleep)
|
1495
1460
|
retry
|
1496
1461
|
end
|
1497
1462
|
raise ex
|
1498
|
-
|
1499
|
-
rescue ZuoraAPI::Exceptions::BadEntityError => ex
|
1500
|
-
raise ex
|
1501
1463
|
end
|
1502
1464
|
|
1503
1465
|
def query(query, parse = false)
|
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.
|
4
|
+
version: 1.9.02
|
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-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_junit_formatter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: webmock
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +84,30 @@ dependencies:
|
|
70
84
|
name: simplecov
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov-cobertura
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
103
|
+
version: '0'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
|
-
- - "
|
108
|
+
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
110
|
+
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: ougai
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +173,7 @@ dependencies:
|
|
145
173
|
version: 4.1.0
|
146
174
|
- - "<"
|
147
175
|
- !ruby/object:Gem::Version
|
148
|
-
version: '6.
|
176
|
+
version: '6.2'
|
149
177
|
type: :runtime
|
150
178
|
prerelease: false
|
151
179
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -155,7 +183,7 @@ dependencies:
|
|
155
183
|
version: 4.1.0
|
156
184
|
- - "<"
|
157
185
|
- !ruby/object:Gem::Version
|
158
|
-
version: '6.
|
186
|
+
version: '6.2'
|
159
187
|
description: Gem that provides easy integration to Zuora
|
160
188
|
email:
|
161
189
|
- connect@zuora.com
|
@@ -163,23 +191,9 @@ executables: []
|
|
163
191
|
extensions: []
|
164
192
|
extra_rdoc_files: []
|
165
193
|
files:
|
166
|
-
-
|
167
|
-
- ".gitlab-ci.yml"
|
168
|
-
- ".rspec"
|
169
|
-
- ".travis.yml"
|
170
|
-
- CHANGELOG.md
|
171
|
-
- Gemfile
|
172
|
-
- Gemfile.lock
|
194
|
+
- MIT-LICENSE
|
173
195
|
- README.md
|
174
196
|
- Rakefile
|
175
|
-
- bin/console
|
176
|
-
- bin/setup
|
177
|
-
- catalog-info.yaml
|
178
|
-
- docs/index.md
|
179
|
-
- gemfiles/Gemfile-rails.5.0.x
|
180
|
-
- gemfiles/Gemfile-rails.5.1.x
|
181
|
-
- gemfiles/Gemfile-rails.5.2.x
|
182
|
-
- gemfiles/Gemfile-rails.6.0.x
|
183
197
|
- lib/insights_api/login.rb
|
184
198
|
- lib/zuora_api.rb
|
185
199
|
- lib/zuora_api/exceptions.rb
|
@@ -187,7 +201,6 @@ files:
|
|
187
201
|
- lib/zuora_api/logins/basic.rb
|
188
202
|
- lib/zuora_api/logins/oauth.rb
|
189
203
|
- lib/zuora_api/version.rb
|
190
|
-
- zuora_api.gemspec
|
191
204
|
homepage: https://connect.zuora.com
|
192
205
|
licenses: []
|
193
206
|
metadata: {}
|
@@ -206,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
219
|
- !ruby/object:Gem::Version
|
207
220
|
version: '0'
|
208
221
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
222
|
+
rubygems_version: 3.2.15
|
210
223
|
signing_key:
|
211
224
|
specification_version: 4
|
212
225
|
summary: Gem that provides easy integration to Zuora
|
data/.gitignore
DELETED
data/.gitlab-ci.yml
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
image: ruby:2.7
|
2
|
-
stages:
|
3
|
-
- test
|
4
|
-
- deploy
|
5
|
-
|
6
|
-
rubocop-testing:
|
7
|
-
stage: test
|
8
|
-
allow_failure: true
|
9
|
-
script:
|
10
|
-
- gem install rubocop
|
11
|
-
- rubocop --lint
|
12
|
-
|
13
|
-
security-testing:
|
14
|
-
stage: test
|
15
|
-
allow_failure: true
|
16
|
-
script:
|
17
|
-
- gem install brakeman
|
18
|
-
- brakeman
|
19
|
-
|
20
|
-
ruby:test:
|
21
|
-
stage: test
|
22
|
-
cache:
|
23
|
-
key: ruby:$RUBY_VERSION-rails:$RAILS_VERSION
|
24
|
-
paths:
|
25
|
-
- vendor/ruby
|
26
|
-
parallel:
|
27
|
-
matrix:
|
28
|
-
- RUBY_VERSION: "2.7"
|
29
|
-
RAILS_VERSION: ["5.0", "5.1", "5.2", "6.0"]
|
30
|
-
before_script:
|
31
|
-
- bundle config set path 'vendor/ruby'
|
32
|
-
- bundle config --global gemfile "gemfiles/Gemfile-rails.$RAILS_VERSION.x"
|
33
|
-
- bundle install
|
34
|
-
script:
|
35
|
-
- bundle exec rails -v
|
36
|
-
- bundle exec rspec
|
37
|
-
coverage: '/\(\d+.\d+\%\) covered/'
|
38
|
-
|
39
|
-
rubygems-deploy:
|
40
|
-
stage: deploy
|
41
|
-
allow_failure: false
|
42
|
-
script:
|
43
|
-
- echo "deb http://ftp.us.debian.org/debian testing main contrib non-free" >> /etc/apt/sources.list
|
44
|
-
- apt-get update
|
45
|
-
- apt-get install -y git
|
46
|
-
- apt-get clean all
|
47
|
-
- gem install dpl
|
48
|
-
- if [[ "staging" == $CI_BUILD_REF_SLUG ]];then export VERSION=`git describe --match "[0-9]*\.[0-9]*\.[0-9]*[a-z]" --abbrev=0 --tags HEAD`; fi
|
49
|
-
- if [[ "master" == $CI_BUILD_REF_SLUG ]];then export VERSION=`git describe --exclude "[0-9]*\.[0-9]*\.[0-9]*[a-z]" --abbrev=0 --tags HEAD`; fi
|
50
|
-
- echo $VERSION
|
51
|
-
- sed -i "s/0.0.1/$VERSION/" lib/zuora_api/version.rb
|
52
|
-
- git add lib/zuora_api/version.rb
|
53
|
-
- git config --global user.email "connect@zuora.com"
|
54
|
-
- git config --global user.name "Connect Automation"
|
55
|
-
- git commit -m "Automated Version Update $VERSION"
|
56
|
-
- bundle install
|
57
|
-
- gem install rake
|
58
|
-
- version=$(rake install | grep -o 'pkg/zuora_api-.*gem')
|
59
|
-
- curl -u $USERNAME:$PASSWORD https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
|
60
|
-
- gem push $version
|
61
|
-
only:
|
62
|
-
- master
|
63
|
-
- staging
|
data/.rspec
DELETED
data/.travis.yml
DELETED
data/CHANGELOG.md
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
All notable changes to this project will be documented in this file.
|
3
|
-
|
4
|
-
## [1.7.07] - 2018-9-10
|
5
|
-
### Changed
|
6
|
-
- Cookie name for service endpoint integration
|
7
|
-
|
8
|
-
## [1.7.06] - 2018-8-25
|
9
|
-
### Added
|
10
|
-
- Retry for 502/503
|
11
|
-
- Standard exception for 504
|
12
|
-
|
13
|
-
## [1.7.05] - 2018-8-25
|
14
|
-
### Added
|
15
|
-
- Added support for oauth token forbidden
|
16
|
-
|
17
|
-
## [1.7.02] - 2018-8-23
|
18
|
-
### Added
|
19
|
-
- Added mulit part support for rest call
|
20
|
-
|
21
|
-
## [1.7.01] - 2018-8-06
|
22
|
-
### Changed
|
23
|
-
- Changed library used to determine host
|
24
|
-
- Added retry for 504 timouts in file download
|
25
|
-
|
26
|
-
## [1.7.00] - 2018-8-05
|
27
|
-
### Changed
|
28
|
-
- Raise proper exception when oauth client is from deactivated user.
|
29
|
-
- Support for rails < 6
|
30
|
-
|
31
|
-
## [1.6.53] - 2018-7-29
|
32
|
-
### Changed
|
33
|
-
- Don't attempt zsession login if bearer token is bad
|
34
|
-
|
35
|
-
## [1.6.51 - 1.6.51] - 2018-7-22
|
36
|
-
### Changed
|
37
|
-
- Retry on address not available.
|
38
|
-
|
39
|
-
## [1.6.47 - 1.6.48] - 2018-6-26
|
40
|
-
### Changed
|
41
|
-
- Changed error raise statements when incorrect credentials are supplied to Basic/Oauth Logins
|
42
|
-
|
43
|
-
## [1.6.45] - 2018-5-30
|
44
|
-
### Changed
|
45
|
-
- Fix retry so headers are reinstaniated on session failure.
|
46
|
-
|
47
|
-
## [1.6.41] - 2018-5-30
|
48
|
-
### Changed
|
49
|
-
- Retry added on SSL connection failure
|
50
|
-
|
51
|
-
## [1.6.39-1.6.40] - 2018-5-30
|
52
|
-
### Changed
|
53
|
-
- Added validation to fix bad urls entered into object initialization
|
54
|
-
|
55
|
-
## [1.6.38] - 2018-5-26
|
56
|
-
### Changed
|
57
|
-
- HttpParty validation before code extraction
|
58
|
-
|
59
|
-
## [1.6.37] - 2018-5-23
|
60
|
-
### Added
|
61
|
-
- Added method to determine rest endpoint domain
|
62
|
-
|
63
|
-
## [1.6.36] - 2018-5-22
|
64
|
-
### Changed
|
65
|
-
- Fixed zuora staging 2 endpoint
|
66
|
-
|
67
|
-
## [1.6.33] - 2018-5-15
|
68
|
-
### Changed
|
69
|
-
- Added Errno::EHOSTUNREACH to list of retriable error codes
|
70
|
-
|
71
|
-
## [1.6.32] - 2018-5-14
|
72
|
-
### Changed
|
73
|
-
- Don't log fatal errors, allow application to decide for file download
|
74
|
-
- Don't change api url if the user set a high api url
|
75
|
-
|
76
|
-
###Removed
|
77
|
-
- Force encoding
|
78
|
-
|
79
|
-
## [1.6.28] - 2018-3-12
|
80
|
-
### Added
|
81
|
-
- Way to avoid force encoding for filedownload
|
82
|
-
|
83
|
-
## [1.6.28] - 2018-3-12
|
84
|
-
### Added
|
85
|
-
- Way to avoid force encoding for filedownload
|
86
|
-
|
87
|
-
## [1.6.22] - 2019-01-03
|
88
|
-
### Changed
|
89
|
-
- get_identity method - supports ZSession auth now
|
90
|
-
- updated rspecs accordingly
|
91
|
-
|
92
|
-
## [1.6.18] - 2018-12-06
|
93
|
-
### Added
|
94
|
-
- zconnect_provider attribute accessor for identifying ZConnect cookies
|
95
|
-
- Methods for Hallway integration:
|
96
|
-
- get_identity
|
97
|
-
- get_full_nav
|
98
|
-
- set_nav
|
99
|
-
- refresh_nav
|
100
|
-
- get_oauth_client
|
101
|
-
|
102
|
-
### Changed
|
103
|
-
- The way environment and region are set
|
104
|
-
|
105
|
-
|
data/Gemfile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "zuora"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/catalog-info.yaml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
---
|
2
|
-
apiVersion: backstage.io/v1alpha1
|
3
|
-
kind: Component
|
4
|
-
metadata:
|
5
|
-
annotations:
|
6
|
-
backstage.io/techdocs-ref: "gitlab:https://gitlab.zeta.tools/extension-products/shared-libraries/zuora-gem.git"
|
7
|
-
description: "Zuora API Rails Gem"
|
8
|
-
name: Zuora-Gem
|
9
|
-
spec:
|
10
|
-
lifecycle: production
|
11
|
-
owner: connect@zuora.com
|
12
|
-
type: library
|
data/docs/index.md
DELETED
@@ -1,147 +0,0 @@
|
|
1
|
-
# Zuora Gem
|
2
|
-
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/zuora_api.svg)](https://badge.fury.io/rb/zuora_api) [![coverage report](https://gitlab.0.ecc.auw2.zuora/extension-products/shared-libraries/zuora-gem/badges/master/coverage.svg)](https://gitlab.0.ecc.auw2.zuora/extension-products/shared-libraries/zuora-gem/commits/master)
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
Add this line to your application's Gemfile:
|
7
|
-
|
8
|
-
```ruby
|
9
|
-
gem 'zuora_api'
|
10
|
-
```
|
11
|
-
Then execute `bundle install` in your terminal
|
12
|
-
|
13
|
-
## Usage
|
14
|
-
|
15
|
-
### Zuora Login Object
|
16
|
-
In order to make API calls a Zuora Login object must be created
|
17
|
-
|
18
|
-
```ruby
|
19
|
-
zuora_client = ZuoraAPI::Login.new(username: "username", password: "password", url: "url")
|
20
|
-
```
|
21
|
-
|
22
|
-
| Name | Type | Description | Example |
|
23
|
-
| ------------------- | ----------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
24
|
-
| username | `Attribute` | Username to the Zuora environment | `zuora_client.username = "username"` |
|
25
|
-
| password | `Attribute` | password to the Zuora environment | `zuora_client.password = "Password"` |
|
26
|
-
| url | `Attribute` | Endpoint to the Zuora tenant | `zuora_client.url = "www.zuora.com"` |
|
27
|
-
| wsdl_number | `Attribute` | WSDL number of the zuora login | `wsdl = zuora_client.wsdl_number` |
|
28
|
-
| status | `Attribute` | Status of the login | `zuora_client.status` |
|
29
|
-
| current_session | `Attribute` | Current session for the login | `zuora_client.current_session` |
|
30
|
-
| environment | `Attribute` | environment of the login | `zuora_client.environment` |
|
31
|
-
| errors | `Attribute` | Any errors that the login has based on the login call | `zuora_client.errors` |
|
32
|
-
| current_error | `Attribute` | Current error from the new_session call | `zuora_client.current_error` |
|
33
|
-
| user_info | `Attribute` | Information related to the login | `zuora_client.user_info` |
|
34
|
-
| tenant_id | `Attribute` | Tenant ID the login is associated to | `zuora_client.tenant_id` |
|
35
|
-
| tenant_name | `Attribute` | Tenant Name of tenant the login is associated to | `zuora_client.tenant_name` |
|
36
|
-
| entity_id | `Attribute` | Current entity the login session is associated to | `zuora_client.entity_id` |
|
37
|
-
| rest_call | `Method` | Executes a REST call | `zuora_client.rest_call()` |
|
38
|
-
| soap_call | `Method` | Executes a SOAP call | `output_xml, input_xml = zuora_client.soap_call() do `|xml, args|` xml['ns1'].query do xml['ns1'].queryString "select id, name from account" end end` |
|
39
|
-
| query | `Method` | Executes a query call | `zuora_client.query("select id, name from account")` |
|
40
|
-
| getDataSourceExport | `Method` | Pulls a data source export with the given query and returns the file location | `zuora_client.getDataSourceExport("select id, name from account")` |
|
41
|
-
| describe_call | `Method` | Performs the describe call against the Zuora tenant for all objects or a specific object | `response = zuora_client.describe_call("Account")` |
|
42
|
-
| createJournalRun | `Method` | Creates a Journal Run | `zuora_client.createJournalRun(call)` |
|
43
|
-
| checkJRStatus | `Method` | Checks the status of a journal run | `zuora_client.checkJRStatus(journal_run_id)` |
|
44
|
-
| update_environment | `Method` | Sets the login's environment based on the url | `zuora_client.update_environment` |
|
45
|
-
| aqua_endpoint | `Method` | Returns the AQuA endpoint for the login based off the environment | `zuora_client.aqua_endpoint` |
|
46
|
-
| rest_endpoint | `Method` | Returns the REST endpoint for the login based off the environment | `zuora_client.rest_endpoint` |
|
47
|
-
| fileURL | `Method` | Returns the URL for files | `zuora_client.fileURL` |
|
48
|
-
| dateFormat | `Method` | Returns the data format syntax based on the wsdl_number | `zuora_client.dateFormat` |
|
49
|
-
| new_session | `Method` | Create a new session | `zuora_client.new_session` |
|
50
|
-
| get_session | `Method` | Returns the current session | `zuora_client.get_session`|
|
51
|
-
|
52
|
-
## Rest Call
|
53
|
-
```ruby
|
54
|
-
zuora_client.rest_call(method: :get, body: {}, url: zuora_client.rest_endpoint("catalog/products?pageSize=4"))
|
55
|
-
```
|
56
|
-
|
57
|
-
### Soap Call
|
58
|
-
Returns both output and input XML
|
59
|
-
|
60
|
-
```ruby
|
61
|
-
zuora_client.soap_call(ns1: 'ns1', ns2: 'ns2', batch_size: nil, single_transaction: false)
|
62
|
-
```
|
63
|
-
|
64
|
-
Example Call
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
output_xml, input_xml = zuora_client.soap_call() do |xml, args|
|
68
|
-
xml['ns1'].query do
|
69
|
-
xml['ns1'].queryString "select id, name from account"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
```
|
73
|
-
### Query
|
74
|
-
```ruby
|
75
|
-
zuora_client.query("select id from account")
|
76
|
-
```
|
77
|
-
### Data Export
|
78
|
-
Returns the file location of the data source export after downloading from Zuora
|
79
|
-
|
80
|
-
```ruby
|
81
|
-
zuora_client.getDataSourceExport("select id from account")
|
82
|
-
```
|
83
|
-
|
84
|
-
| Name | Description | Default | Example |
|
85
|
-
| --------- | ---------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------- |
|
86
|
-
| query | The query to execute | `N/A` | `zuora_client.getDataSourceExport("select id from account")` |
|
87
|
-
| zip | Indicates if the data source export should be a zip | `true` | `zuora_client.getDataSourceExport("select id from account", zip: false)` |
|
88
|
-
| extract | Indicates if the data source export should be extracted if it is a zip | `true` | `zuora_client.getDataSourceExport("select id from account", extract: false)` |
|
89
|
-
| encrypted | Indicates if the data source export should be encrypted | `false` | `zuora_client.getDataSourceExport("select id from account", encrypted: true)` |
|
90
|
-
|
91
|
-
### Describe Call
|
92
|
-
This returns all available objects from the describe call as a hash. This response can be accessed by using response["Account"] to retrieve all related data about that object.
|
93
|
-
|
94
|
-
```ruby
|
95
|
-
response = zuora_client.describe_call("Account")
|
96
|
-
```
|
97
|
-
This returns all information and fields related to that object model as a hash.
|
98
|
-
|
99
|
-
```ruby
|
100
|
-
response = zuora_client.describe_call()
|
101
|
-
```
|
102
|
-
|
103
|
-
### Journal Run
|
104
|
-
```ruby
|
105
|
-
zuora_client.createJournalRun(call)
|
106
|
-
```
|
107
|
-
|
108
|
-
## Insights API
|
109
|
-
|
110
|
-
In order to make API calls a Zuora Login object must be created by running:
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
insightsapi = InsightsAPI::Login.new(api_token: "api token", url: "Nw1.api.insights.zuora.com/api/")
|
114
|
-
```
|
115
|
-
|
116
|
-
Note that the login will default to the insights production url.
|
117
|
-
|
118
|
-
```ruby
|
119
|
-
Date format: "YYYY-MM-DDT00:00:00Z"
|
120
|
-
```
|
121
|
-
|
122
|
-
### Uploading Data into Insights
|
123
|
-
```ruby
|
124
|
-
insightsapi.upload_into_insights(dataSourceName, recordType, batchDate, filePath)
|
125
|
-
```
|
126
|
-
dataSourceName: What system the data is coming from.
|
127
|
-
recordType: The type of records ie: "EVENTS, ATTRIBUTES, and METRICS"
|
128
|
-
batachDate: The date the data applies to.
|
129
|
-
|
130
|
-
### Describing Insights Data
|
131
|
-
```ruby
|
132
|
-
insightsapi.describe(type: "ACCOUNT/USER", object: "ATTRIBUTES/EVENTS/SEGMENTS/METRICS")
|
133
|
-
```
|
134
|
-
Returns json payload describing attributes, events, metrics for each Account or User.
|
135
|
-
|
136
|
-
### Downloading Data from Insights
|
137
|
-
```ruby
|
138
|
-
insightsapi.data_export_insights(objecttype, segmentuuid, startDate: nil, endDate: nil, tries: 30)
|
139
|
-
```
|
140
|
-
```ruby
|
141
|
-
insightsapi.data_export_insights_file(objecttype, segmentuuid, startDate: nil, endDate: nil, tries: 30)
|
142
|
-
```
|
143
|
-
Both do the same thing except one returns a url(data_export_insights) to download the file yourself and the other returns an actual Ruby temporary file(data_export_insights_file).
|
144
|
-
|
145
|
-
objectype: "ACCOUNT/USER"
|
146
|
-
|
147
|
-
segmentuuid: A single or array of string or int of a segment uuid(s) that you get from the describe call. The csv holds a column with a bool that represents if that User or Account belongs to that segment.
|
data/zuora_api.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'zuora_api/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "zuora_api"
|
8
|
-
spec.version = ZuoraAPI::VERSION
|
9
|
-
spec.authors = ["Zuora Strategic Solutions Group"]
|
10
|
-
spec.email = ["connect@zuora.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{Gem that provides easy integration to Zuora}
|
13
|
-
spec.description = %q{Gem that provides easy integration to Zuora}
|
14
|
-
spec.homepage = "https://connect.zuora.com"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir = "exe"
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler"
|
22
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
-
spec.add_development_dependency("webmock")
|
25
|
-
spec.add_development_dependency("simplecov", "~> 0.18.5")
|
26
|
-
spec.add_dependency("ougai")
|
27
|
-
spec.add_dependency("nokogiri")
|
28
|
-
spec.add_dependency("httparty")
|
29
|
-
spec.add_dependency("rubyzip")
|
30
|
-
spec.add_dependency 'railties', '>= 4.1.0', '< 6.1'
|
31
|
-
end
|