zuora_api 1.6.08 → 1.6.10
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/Gemfile.lock +1 -1
- data/lib/zuora_api/login.rb +31 -18
- data/lib/zuora_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ab1f61ed70054d159fa7b9b8835d6706be1c2e3
|
4
|
+
data.tar.gz: 765e41e2106129176e32224ff448ad6134a39b61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4adb062487388da25439e813dfc8e5301e1ec6c3f56a229ca5acb10904f2ece0a088d6a30d0a2ba11d35eb74368a5eebbd007dd17c0c972339fa8198ce085754
|
7
|
+
data.tar.gz: d7663dbccd7a31ae63cc694caf1c66c12fa0dd8f4bd7e7f262e06d20b06724518db9c07d490fefd35705be08f8838e3787858effec00a70f9ed00d41843c1d9c
|
data/Gemfile.lock
CHANGED
data/lib/zuora_api/login.rb
CHANGED
@@ -549,7 +549,7 @@ module ZuoraAPI
|
|
549
549
|
return products, catalog_map
|
550
550
|
end
|
551
551
|
|
552
|
-
def get_file(url: nil, headers: {}, count: 3, z_session: true, tempfile: true, file_path: defined?(Rails.root.join('tmp')) ? Rails.root.join('tmp') : Pathname.new(Dir.pwd), timeout_retries: 2, timeout: 120, session_type: :basic, **execute_params)
|
552
|
+
def get_file(url: nil, headers: {}, count: 3, z_session: true, tempfile: true, output_file_name: nil, add_timestamp: true, file_path: defined?(Rails.root.join('tmp')) ? Rails.root.join('tmp') : Pathname.new(Dir.pwd), timeout_retries: 2, timeout: 120, session_type: :basic, **execute_params)
|
553
553
|
raise "file_path must be of class Pathname" if file_path.class != Pathname
|
554
554
|
|
555
555
|
#Make sure directory exists
|
@@ -562,7 +562,10 @@ module ZuoraAPI
|
|
562
562
|
http = Net::HTTP.new(uri.host, uri.port)
|
563
563
|
http.read_timeout = timeout #Seconds
|
564
564
|
http.use_ssl = true if uri.scheme.downcase == 'https'
|
565
|
-
|
565
|
+
if z_session
|
566
|
+
headers = headers.merge({"Authorization" => self.get_session(prefix: true)})
|
567
|
+
headers = headers.merge({"entityId" => self.entity_id}) if !self.entity_id.blank?
|
568
|
+
end
|
566
569
|
|
567
570
|
response_save = nil
|
568
571
|
http.request_get(uri.request_uri, headers) do |response|
|
@@ -575,13 +578,15 @@ module ZuoraAPI
|
|
575
578
|
raise
|
576
579
|
|
577
580
|
when Net::HTTPUnauthorized
|
581
|
+
if count <= 0
|
582
|
+
if z_session
|
583
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error)
|
584
|
+
else
|
585
|
+
raise
|
586
|
+
end
|
587
|
+
end
|
578
588
|
Rails.logger.fatal("Unauthorized: Retry")
|
579
|
-
if z_session
|
580
|
-
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error) if count <= 0
|
581
|
-
self.new_session
|
582
|
-
else
|
583
|
-
raise if count <= 0
|
584
|
-
end
|
589
|
+
self.new_session if z_session
|
585
590
|
return get_file(:url => url, :headers => headers, :count => count - 1, :z_session => z_session, :tempfile => tempfile, :file_path => file_path, :timeout_retries => timeout_retries, :timeout => timeout)
|
586
591
|
|
587
592
|
when Net::ReadTimeout, Net::OpenTimeout, Errno::EPIPE, Errno::ECONNRESET, OpenSSL::SSL::SSLError, Errno::ECONNREFUSED, SocketError
|
@@ -598,20 +603,30 @@ module ZuoraAPI
|
|
598
603
|
end
|
599
604
|
Rails.logger.debug("Headers: #{headers.to_s}")
|
600
605
|
|
606
|
+
if output_file_name.present?
|
607
|
+
file_ending ||= output_file_name.end_with?(".csv.zip") ? ".csv.zip" : File.extname(output_file_name)
|
608
|
+
filename ||= File.basename(output_file_name, file_ending)
|
609
|
+
end
|
610
|
+
|
601
611
|
size, export_progress = [0, 0]
|
602
612
|
encoding, type, full_filename = [nil, nil, nil]
|
603
613
|
if response.header["Content-Disposition"].present?
|
604
614
|
case response.header["Content-Disposition"]
|
605
615
|
when /.*; filename\*=.*/
|
606
|
-
full_filename
|
616
|
+
full_filename ||= /.*; filename\*=(.*)''(.*)/.match(response.header["Content-Disposition"])[2].strip
|
607
617
|
encoding = /.*; filename\*=(.*)''(.*)/.match(response.header["Content-Disposition"])[1].strip
|
608
618
|
when /.*; filename=/
|
609
|
-
full_filename
|
619
|
+
full_filename ||= /.*; filename=(.*)/.match(response.header["Content-Disposition"])[1].strip
|
620
|
+
else
|
621
|
+
raise "Can't parse Content-Disposition header: #{response.header["Content-Disposition"]}"
|
610
622
|
end
|
611
|
-
file_ending
|
623
|
+
file_ending ||= full_filename.end_with?(".csv.zip") ? ".csv.zip" : File.extname(full_filename)
|
624
|
+
filename ||= File.basename(full_filename, file_ending)
|
612
625
|
end
|
626
|
+
|
613
627
|
#If user supplied a filename use it, else default to content header filename, else default to uri pattern
|
614
|
-
|
628
|
+
file_ending ||= uri.path.end_with?(".csv.zip") ? ".csv.zip" : File.extname(uri.path)
|
629
|
+
filename ||= File.basename(uri.path, file_ending)
|
615
630
|
|
616
631
|
if response.header["Content-Type"].present?
|
617
632
|
case response.header["Content-Type"]
|
@@ -631,16 +646,14 @@ module ZuoraAPI
|
|
631
646
|
export_size = response.header["ContentLength"].to_i
|
632
647
|
end
|
633
648
|
|
634
|
-
|
635
|
-
timestamp = Time.now.to_i
|
649
|
+
file_prefix = add_timestamp ? "#{filename}_#{Time.now.to_i}" : filename
|
636
650
|
if tempfile
|
637
651
|
require 'tempfile'
|
638
|
-
file_handle = ::Tempfile.new([
|
639
|
-
file_handle.binmode
|
652
|
+
file_handle = ::Tempfile.new([file_prefix, "#{file_ending}"], file_path)
|
640
653
|
else
|
641
|
-
file_handle = File.new(file_path.join("#{
|
642
|
-
file_handle.binmode
|
654
|
+
file_handle = File.new(file_path.join("#{file_prefix}#{file_ending}"), "w+")
|
643
655
|
end
|
656
|
+
file_handle.binmode
|
644
657
|
|
645
658
|
response.read_body do |chunk|
|
646
659
|
file_handle << chunk.force_encoding(encoding)
|
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.6.
|
4
|
+
version: 1.6.10
|
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: 2018-09-
|
11
|
+
date: 2018-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|