zuora_api 1.6.252 → 1.6.253
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/login.rb +95 -89
- 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: 75aaa525b01f8cb9dc61575b5ffbce6c45aeff5a
|
|
4
|
+
data.tar.gz: df7b4849281c83e10590c51088e0c3813ce305d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 91b63981c496283de20f9387aa616c36f3ea035f034480874bdc14f1c9a82ce3f15a66977cef94a5f08aa9019f121049bea979938133bae23ad700db264204f0
|
|
7
|
+
data.tar.gz: 57ba1131cdbb7480a7769fe306e53641df7d6608091465e765ef3a8c7d7c528cc3db96d2bb5b46edf0498f641d2fbe0467e8938a2add8755b6cb0cef134917b0
|
data/lib/zuora_api/login.rb
CHANGED
|
@@ -863,110 +863,116 @@ module ZuoraAPI
|
|
|
863
863
|
end
|
|
864
864
|
|
|
865
865
|
response_save = nil
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
if
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
866
|
+
begin
|
|
867
|
+
http.request_get(uri.request_uri, headers) do |response|
|
|
868
|
+
response_save = response
|
|
869
|
+
status_code = response.code if response
|
|
870
|
+
|
|
871
|
+
case response
|
|
872
|
+
when Net::HTTPNotFound
|
|
873
|
+
Rails.logger.fatal("404 - Not Found")
|
|
874
|
+
raise
|
|
875
|
+
|
|
876
|
+
when Net::HTTPUnauthorized
|
|
877
|
+
if count <= 0
|
|
878
|
+
if z_session
|
|
879
|
+
raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error)
|
|
880
|
+
else
|
|
881
|
+
raise
|
|
882
|
+
end
|
|
881
883
|
end
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
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)
|
|
884
|
+
Rails.logger.fatal("Unauthorized: Retry")
|
|
885
|
+
self.new_session if z_session
|
|
886
|
+
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)
|
|
886
887
|
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
return get_file(:url => url, :headers => headers, :count => count, :z_session => z_session, :tempfile => tempfile, :file_path => file_path, :timeout_retries => timeout_retries - 1, :timeout => timeout)
|
|
888
|
+
when Net::HTTPClientError
|
|
889
|
+
raise
|
|
890
890
|
|
|
891
|
-
|
|
892
|
-
|
|
891
|
+
when Net::HTTPOK
|
|
892
|
+
headers = {}
|
|
893
|
+
response.each_header do |k,v|
|
|
894
|
+
headers[k] = v
|
|
895
|
+
end
|
|
896
|
+
Rails.logger.debug("Headers: #{headers.to_s}")
|
|
893
897
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
end
|
|
899
|
-
Rails.logger.debug("Headers: #{headers.to_s}")
|
|
898
|
+
if output_file_name.present?
|
|
899
|
+
file_ending ||= output_file_name.end_with?(".csv.zip") ? ".csv.zip" : File.extname(output_file_name)
|
|
900
|
+
filename ||= File.basename(output_file_name, file_ending)
|
|
901
|
+
end
|
|
900
902
|
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
903
|
+
size, export_progress = [0, 0]
|
|
904
|
+
encoding, type, full_filename = [nil, nil, nil]
|
|
905
|
+
if response.header["Content-Disposition"].present?
|
|
906
|
+
case response.header["Content-Disposition"]
|
|
907
|
+
when /.*; filename\*=.*/
|
|
908
|
+
full_filename ||= /.*; filename\*=(.*)''(.*)/.match(response.header["Content-Disposition"])[2].strip
|
|
909
|
+
encoding = /.*; filename\*=(.*)''(.*)/.match(response.header["Content-Disposition"])[1].strip
|
|
910
|
+
when /.*; filename=/
|
|
911
|
+
full_filename ||= /.*; filename=(.*)/.match(response.header["Content-Disposition"])[1].strip
|
|
912
|
+
else
|
|
913
|
+
raise "Can't parse Content-Disposition header: #{response.header["Content-Disposition"]}"
|
|
914
|
+
end
|
|
915
|
+
file_ending ||= full_filename.end_with?(".csv.zip") ? ".csv.zip" : File.extname(full_filename)
|
|
916
|
+
filename ||= File.basename(full_filename, file_ending)
|
|
917
|
+
end
|
|
905
918
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
919
|
+
#If user supplied a filename use it, else default to content header filename, else default to uri pattern
|
|
920
|
+
file_ending ||= uri.path.end_with?(".csv.zip") ? ".csv.zip" : File.extname(uri.path)
|
|
921
|
+
filename ||= File.basename(uri.path, file_ending)
|
|
922
|
+
|
|
923
|
+
if response.header["Content-Type"].present?
|
|
924
|
+
case response.header["Content-Type"]
|
|
925
|
+
when /.*;charset=.*/
|
|
926
|
+
type = /(.*);charset=(.*)/.match(response.header["Content-Type"])[1]
|
|
927
|
+
encoding = /(.*);charset=(.*)/.match(response.header["Content-Type"])[2]
|
|
928
|
+
else
|
|
929
|
+
type = response.header["Content-Type"]
|
|
930
|
+
encoding ||= 'UTF-8'
|
|
931
|
+
end
|
|
917
932
|
end
|
|
918
|
-
|
|
919
|
-
filename ||= File.basename(full_filename, file_ending)
|
|
920
|
-
end
|
|
933
|
+
Rails.logger.info("File: #{filename}#{file_ending} #{encoding} #{type}")
|
|
921
934
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
935
|
+
if response.header["Content-Length"].present?
|
|
936
|
+
export_size = response.header["Content-Length"].to_i
|
|
937
|
+
elsif response.header["ContentLength"].present?
|
|
938
|
+
export_size = response.header["ContentLength"].to_i
|
|
939
|
+
end
|
|
925
940
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
encoding = /(.*);charset=(.*)/.match(response.header["Content-Type"])[2]
|
|
941
|
+
file_prefix = add_timestamp ? "#{filename}_#{Time.now.to_i}" : filename
|
|
942
|
+
if tempfile
|
|
943
|
+
require 'tempfile'
|
|
944
|
+
file_handle = ::Tempfile.new([file_prefix, "#{file_ending}"], file_path)
|
|
931
945
|
else
|
|
932
|
-
|
|
933
|
-
encoding ||= 'UTF-8'
|
|
946
|
+
file_handle = File.new(file_path.join("#{file_prefix}#{file_ending}"), "w+")
|
|
934
947
|
end
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
file_handle = ::Tempfile.new([file_prefix, "#{file_ending}"], file_path)
|
|
948
|
-
else
|
|
949
|
-
file_handle = File.new(file_path.join("#{file_prefix}#{file_ending}"), "w+")
|
|
950
|
-
end
|
|
951
|
-
file_handle.binmode
|
|
952
|
-
|
|
953
|
-
response.read_body do |chunk|
|
|
954
|
-
file_handle << chunk.force_encoding(encoding)
|
|
955
|
-
|
|
956
|
-
if defined?(export_size) && export_size != 0 && export_size.class == Integer
|
|
957
|
-
size += chunk.size
|
|
958
|
-
new_progress = (size * 100) / export_size
|
|
959
|
-
unless new_progress == export_progress
|
|
960
|
-
Rails.logger.debug("Login: Export Downloading %s (%3d%%)" % [filename, new_progress])
|
|
948
|
+
file_handle.binmode
|
|
949
|
+
|
|
950
|
+
response.read_body do |chunk|
|
|
951
|
+
file_handle << chunk.force_encoding(encoding)
|
|
952
|
+
|
|
953
|
+
if defined?(export_size) && export_size != 0 && export_size.class == Integer
|
|
954
|
+
size += chunk.size
|
|
955
|
+
new_progress = (size * 100) / export_size
|
|
956
|
+
unless new_progress == export_progress
|
|
957
|
+
Rails.logger.debug("Login: Export Downloading %s (%3d%%)" % [filename, new_progress])
|
|
958
|
+
end
|
|
959
|
+
export_progress = new_progress
|
|
961
960
|
end
|
|
962
|
-
export_progress = new_progress
|
|
963
961
|
end
|
|
964
|
-
end
|
|
965
962
|
|
|
966
|
-
|
|
967
|
-
|
|
963
|
+
file_handle.close
|
|
964
|
+
Rails.logger.debug("Filepath: #{file_handle.path} Size: #{File.size(file_handle.path).to_f/1000000} mb")
|
|
968
965
|
|
|
969
|
-
|
|
966
|
+
return file_handle
|
|
967
|
+
end
|
|
968
|
+
end
|
|
969
|
+
rescue *(CONNECTION_EXCEPTIONS).concat(CONNECTION_READ_EXCEPTIONS) => e
|
|
970
|
+
sleep(5)
|
|
971
|
+
if (timeout_retries -= 1) >= 0
|
|
972
|
+
Rails.logger.warn("Download Failed: #{e.class} : #{e.message}")
|
|
973
|
+
retry
|
|
974
|
+
else
|
|
975
|
+
raise
|
|
970
976
|
end
|
|
971
977
|
end
|
|
972
978
|
rescue Exception => e
|
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.253
|
|
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: 2019-02-
|
|
11
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|