stripe 3.8.0 → 3.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/stripe/file_upload.rb +3 -1
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/exchange_rate_test.rb +0 -26
- data/test/stripe/file_upload_test.rb +20 -1
- data/test/test_helper.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: e0e126dcbcb1339f0cd72cb6e61ff8bcad95d75d
|
4
|
+
data.tar.gz: 0eeb0eb4383fca37073ff0270e14effb17776c14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e0bf6d764da6d759fb89e0d69edbffd5155f777f54a83406ddc1857ad7f8c0051aa82d1fd26943065ff2e3b5740a3aa867425255dcdf9cc6bfdb2bcbdf9f64a
|
7
|
+
data.tar.gz: dbc7388a004fcb332cc7af98c438dd149fd65b142aa4071ddbc626914526629ca2cdacb0aae439d8810ee05e64c4b390cdf5534df14bcff72c638cdbdf0c2d0c
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.8.1 - 2017-12-06
|
4
|
+
* [#611](https://github.com/stripe/stripe-ruby/pull/611) Support `Tempfile` (as well as `File`) in file uploads
|
5
|
+
|
3
6
|
## 3.8.0 - 2017-10-31
|
4
7
|
* [#606](https://github.com/stripe/stripe-ruby/pull/606) Support for exchange rates APIs
|
5
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.8.
|
1
|
+
3.8.1
|
data/lib/stripe/file_upload.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
|
1
3
|
module Stripe
|
2
4
|
class FileUpload < APIResource
|
3
5
|
extend Stripe::APIOperations::Create
|
@@ -20,7 +22,7 @@ module Stripe
|
|
20
22
|
# rest-client would accept a vanilla `File` for upload, but Faraday does
|
21
23
|
# not. Support the old API by wrapping a `File` with an `UploadIO` object
|
22
24
|
# if we're given one.
|
23
|
-
if params[:file] && params[:file].is_a?(
|
25
|
+
if params[:file] && [File, Tempfile].any? { |klass| params[:file].is_a?(klass) }
|
24
26
|
params[:file] = Faraday::UploadIO.new(params[:file], nil)
|
25
27
|
end
|
26
28
|
|
data/lib/stripe/version.rb
CHANGED
@@ -3,24 +3,6 @@ require File.expand_path("../../test_helper", __FILE__)
|
|
3
3
|
module Stripe
|
4
4
|
class ExchangeRateTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
|
-
# TODO: remove stub once stripe-mock supports /v1/exchange_rates
|
7
|
-
stub_request(:get, "#{Stripe.api_base}/v1/exchange_rates")
|
8
|
-
.to_return(body: JSON.generate(
|
9
|
-
object: "list",
|
10
|
-
data: [
|
11
|
-
{
|
12
|
-
id: "eur",
|
13
|
-
object: "exchange_rate",
|
14
|
-
rates: { "usd" => 1.18221 },
|
15
|
-
},
|
16
|
-
{
|
17
|
-
id: "usd",
|
18
|
-
object: "exchange_rate",
|
19
|
-
rates: { "eur" => 0.845876 },
|
20
|
-
},
|
21
|
-
]
|
22
|
-
))
|
23
|
-
|
24
6
|
list_rates = Stripe::ExchangeRate.list
|
25
7
|
assert_requested :get, "#{Stripe.api_base}/v1/exchange_rates"
|
26
8
|
assert list_rates.data.is_a?(Array)
|
@@ -28,14 +10,6 @@ module Stripe
|
|
28
10
|
end
|
29
11
|
|
30
12
|
should "be retrievable" do
|
31
|
-
# TODO: remove stub once stripe-mock supports /v1/exchange_rates
|
32
|
-
stub_request(:get, "#{Stripe.api_base}/v1/exchange_rates/usd")
|
33
|
-
.to_return(body: JSON.generate(
|
34
|
-
id: "usd",
|
35
|
-
object: "exchange_rate",
|
36
|
-
rates: { "eur" => 0.845876 }
|
37
|
-
))
|
38
|
-
|
39
13
|
rates = Stripe::ExchangeRate.retrieve("usd")
|
40
14
|
assert_requested :get, "#{Stripe.api_base}/v1/exchange_rates/usd"
|
41
15
|
assert rates.is_a?(Stripe::ExchangeRate)
|
@@ -31,7 +31,7 @@ module Stripe
|
|
31
31
|
assert file.is_a?(Stripe::FileUpload)
|
32
32
|
end
|
33
33
|
|
34
|
-
should "be creatable" do
|
34
|
+
should "be creatable with a File" do
|
35
35
|
stub_request(:post, "#{Stripe.uploads_base}/v1/files")
|
36
36
|
.with(headers: {
|
37
37
|
"Content-Type" => /\A#{Faraday::Request::Multipart.mime_type}/,
|
@@ -46,6 +46,25 @@ module Stripe
|
|
46
46
|
assert file.is_a?(Stripe::FileUpload)
|
47
47
|
end
|
48
48
|
|
49
|
+
should "be creatable with a Tempfile" do
|
50
|
+
stub_request(:post, "#{Stripe.uploads_base}/v1/files")
|
51
|
+
.with(headers: {
|
52
|
+
"Content-Type" => /\A#{Faraday::Request::Multipart.mime_type}/,
|
53
|
+
}) do |request|
|
54
|
+
request.body =~ /Hello world/
|
55
|
+
end.to_return(body: JSON.generate(FIXTURE))
|
56
|
+
|
57
|
+
tempfile = Tempfile.new("foo")
|
58
|
+
tempfile.write("Hello world")
|
59
|
+
tempfile.rewind
|
60
|
+
|
61
|
+
file = Stripe::FileUpload.create(
|
62
|
+
purpose: "dispute_evidence",
|
63
|
+
file: tempfile
|
64
|
+
)
|
65
|
+
assert file.is_a?(Stripe::FileUpload)
|
66
|
+
end
|
67
|
+
|
49
68
|
should "be creatable with Faraday::UploadIO" do
|
50
69
|
stub_request(:post, "#{Stripe.uploads_base}/v1/files")
|
51
70
|
.with(headers: {
|
data/test/test_helper.rb
CHANGED
@@ -10,7 +10,7 @@ PROJECT_ROOT = File.expand_path("../../", __FILE__)
|
|
10
10
|
|
11
11
|
require File.expand_path("../test_data", __FILE__)
|
12
12
|
|
13
|
-
MOCK_MINIMUM_VERSION = "0.
|
13
|
+
MOCK_MINIMUM_VERSION = "0.4.0".freeze
|
14
14
|
MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111
|
15
15
|
|
16
16
|
# Disable all real network connections except those that are outgoing to
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.8.
|
4
|
+
version: 3.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|