zuora_api 1.6.252 → 1.6.253

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f36543b739da8affca96e7879ceffb1c9bb9db3
4
- data.tar.gz: 21753e9b98a2e7d8f5d1b84cdfc84868f2663f31
3
+ metadata.gz: 75aaa525b01f8cb9dc61575b5ffbce6c45aeff5a
4
+ data.tar.gz: df7b4849281c83e10590c51088e0c3813ce305d2
5
5
  SHA512:
6
- metadata.gz: fc8c96cb1d707a94901bfee70abef611799a9d19b3cfd9e42cee8380ab9d0ef71f8552860429feb38157a7a93f82ac51305814e4c7e0927ba68e45e3273ec0bf
7
- data.tar.gz: 02c478ab7b96a0274e304669bdc0ae7f22a5a9929979051da06bd4cc97e05a71cfb8c1147da1afdbed5ea011786051c2cc55f14eddeb9b02e3de634856085032
6
+ metadata.gz: 91b63981c496283de20f9387aa616c36f3ea035f034480874bdc14f1c9a82ce3f15a66977cef94a5f08aa9019f121049bea979938133bae23ad700db264204f0
7
+ data.tar.gz: 57ba1131cdbb7480a7769fe306e53641df7d6608091465e765ef3a8c7d7c528cc3db96d2bb5b46edf0498f641d2fbe0467e8938a2add8755b6cb0cef134917b0
@@ -863,110 +863,116 @@ module ZuoraAPI
863
863
  end
864
864
 
865
865
  response_save = nil
866
- http.request_get(uri.request_uri, headers) do |response|
867
- response_save = response
868
- status_code = response.code if response
869
-
870
- case response
871
- when Net::HTTPNotFound
872
- Rails.logger.fatal("404 - Not Found")
873
- raise
874
-
875
- when Net::HTTPUnauthorized
876
- if count <= 0
877
- if z_session
878
- raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new(self.current_error)
879
- else
880
- raise
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
- end
883
- Rails.logger.fatal("Unauthorized: Retry")
884
- self.new_session if z_session
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
- when *(CONNECTION_EXCEPTIONS).concat(CONNECTION_READ_EXCEPTIONS)
888
- Rails.logger.fatal("#{response.class} timeout - retry")
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
- when Net::HTTPClientError
892
- raise
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
- when Net::HTTPOK
895
- headers = {}
896
- response.each_header do |k,v|
897
- headers[k] = v
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
- if output_file_name.present?
902
- file_ending ||= output_file_name.end_with?(".csv.zip") ? ".csv.zip" : File.extname(output_file_name)
903
- filename ||= File.basename(output_file_name, file_ending)
904
- end
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
- size, export_progress = [0, 0]
907
- encoding, type, full_filename = [nil, nil, nil]
908
- if response.header["Content-Disposition"].present?
909
- case response.header["Content-Disposition"]
910
- when /.*; filename\*=.*/
911
- full_filename ||= /.*; filename\*=(.*)''(.*)/.match(response.header["Content-Disposition"])[2].strip
912
- encoding = /.*; filename\*=(.*)''(.*)/.match(response.header["Content-Disposition"])[1].strip
913
- when /.*; filename=/
914
- full_filename ||= /.*; filename=(.*)/.match(response.header["Content-Disposition"])[1].strip
915
- else
916
- raise "Can't parse Content-Disposition header: #{response.header["Content-Disposition"]}"
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
- file_ending ||= full_filename.end_with?(".csv.zip") ? ".csv.zip" : File.extname(full_filename)
919
- filename ||= File.basename(full_filename, file_ending)
920
- end
933
+ Rails.logger.info("File: #{filename}#{file_ending} #{encoding} #{type}")
921
934
 
922
- #If user supplied a filename use it, else default to content header filename, else default to uri pattern
923
- file_ending ||= uri.path.end_with?(".csv.zip") ? ".csv.zip" : File.extname(uri.path)
924
- filename ||= File.basename(uri.path, file_ending)
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
- if response.header["Content-Type"].present?
927
- case response.header["Content-Type"]
928
- when /.*;charset=.*/
929
- type = /(.*);charset=(.*)/.match(response.header["Content-Type"])[1]
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
- type = response.header["Content-Type"]
933
- encoding ||= 'UTF-8'
946
+ file_handle = File.new(file_path.join("#{file_prefix}#{file_ending}"), "w+")
934
947
  end
935
- end
936
- Rails.logger.info("File: #{filename}#{file_ending} #{encoding} #{type}")
937
-
938
- if response.header["Content-Length"].present?
939
- export_size = response.header["Content-Length"].to_i
940
- elsif response.header["ContentLength"].present?
941
- export_size = response.header["ContentLength"].to_i
942
- end
943
-
944
- file_prefix = add_timestamp ? "#{filename}_#{Time.now.to_i}" : filename
945
- if tempfile
946
- require 'tempfile'
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
- file_handle.close
967
- Rails.logger.debug("Filepath: #{file_handle.path} Size: #{File.size(file_handle.path).to_f/1000000} mb")
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
- return file_handle
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
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "1.6.252"
2
+ VERSION = "1.6.253"
3
3
  end
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.252
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-08 00:00:00.000000000 Z
11
+ date: 2019-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler