Skip to content

Commit

Permalink
Use files.stripe.com only for the file create endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe committed Sep 20, 2018
1 parent f3dd3ab commit 6f697a5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions lib/stripe/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/stripe/file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
5 changes: 5 additions & 0 deletions test/stripe/file_upload_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 6f697a5

Please sign in to comment.