diff --git a/lib/stripe.rb b/lib/stripe.rb index c6d5a2993..73a186e79 100644 --- a/lib/stripe.rb +++ b/lib/stripe.rb @@ -103,7 +103,7 @@ module Stripe @api_base = "https://api.stripe.com" @connect_base = "https://connect.stripe.com" - @uploads_base = "https://uploads.stripe.com" + @uploads_base = "https://files.stripe.com" @log_level = nil @logger = nil diff --git a/lib/stripe/file.rb b/lib/stripe/file.rb index b4cd50350..eef999fac 100644 --- a/lib/stripe/file.rb +++ b/lib/stripe/file.rb @@ -16,13 +16,6 @@ def self.resource_url "/v1/files" end - def self.request(method, url, params = {}, opts = {}) - opts = { - api_base: Stripe.uploads_base, - }.merge(Util.normalize_opts(opts)) - super - end - def self.create(params = {}, opts = {}) # rest-client would accept a vanilla `File` for upload, but Faraday does # not. Support the old API by wrapping a `File`-like object with an @@ -32,6 +25,7 @@ def self.create(params = {}, opts = {}) end opts = { + api_base: Stripe.uploads_base, content_type: "multipart/form-data", }.merge(Util.normalize_opts(opts)) super diff --git a/test/stripe/file_test.rb b/test/stripe/file_test.rb index 1a5393028..cbdd957c0 100644 --- a/test/stripe/file_test.rb +++ b/test/stripe/file_test.rb @@ -6,12 +6,14 @@ module Stripe class FileTest < Test::Unit::TestCase should "be listable" do files = Stripe::File.list + assert_requested :get, "#{Stripe.api_base}/v1/files" assert files.data.is_a?(Array) assert files.data[0].is_a?(Stripe::File) end should "be retrievable" do file = Stripe::File.retrieve("file_123") + assert_requested :get, "#{Stripe.api_base}/v1/files/file_123" assert file.is_a?(Stripe::File) end @@ -20,6 +22,7 @@ class FileTest < Test::Unit::TestCase purpose: "dispute_evidence", file: ::File.new(__FILE__) ) + assert_requested :post, "#{Stripe.uploads_base}/v1/files" assert file.is_a?(Stripe::File) end @@ -32,6 +35,7 @@ class FileTest < Test::Unit::TestCase purpose: "dispute_evidence", file: tempfile ) + assert_requested :post, "#{Stripe.uploads_base}/v1/files" assert file.is_a?(Stripe::File) end @@ -40,6 +44,7 @@ class FileTest < Test::Unit::TestCase purpose: "dispute_evidence", file: Faraday::UploadIO.new(::File.new(__FILE__), nil) ) + assert_requested :post, "#{Stripe.uploads_base}/v1/files" assert file.is_a?(Stripe::File) end diff --git a/test/stripe/file_upload_test.rb b/test/stripe/file_upload_test.rb index 42556b18e..03d9addc3 100644 --- a/test/stripe/file_upload_test.rb +++ b/test/stripe/file_upload_test.rb @@ -6,12 +6,14 @@ module Stripe class FileUploadTest < Test::Unit::TestCase should "be listable" do files = Stripe::FileUpload.list + assert_requested :get, "#{Stripe.api_base}/v1/files" assert files.data.is_a?(Array) assert files.data[0].is_a?(Stripe::FileUpload) end should "be retrievable" do file = Stripe::FileUpload.retrieve("file_123") + assert_requested :get, "#{Stripe.api_base}/v1/files/file_123" assert file.is_a?(Stripe::FileUpload) end @@ -20,6 +22,7 @@ class FileUploadTest < Test::Unit::TestCase purpose: "dispute_evidence", file: ::File.new(__FILE__) ) + assert_requested :post, "#{Stripe.uploads_base}/v1/files" assert file.is_a?(Stripe::FileUpload) end @@ -32,6 +35,7 @@ class FileUploadTest < Test::Unit::TestCase purpose: "dispute_evidence", file: tempfile ) + assert_requested :post, "#{Stripe.uploads_base}/v1/files" assert file.is_a?(Stripe::FileUpload) end @@ -40,6 +44,7 @@ class FileUploadTest < Test::Unit::TestCase purpose: "dispute_evidence", file: Faraday::UploadIO.new(::File.new(__FILE__), nil) ) + assert_requested :post, "#{Stripe.uploads_base}/v1/files" assert file.is_a?(Stripe::FileUpload) end