stripe 3.26.1 → 3.27.0
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/.travis.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +2 -2
- data/lib/stripe/{file_upload.rb → file.rb} +11 -9
- data/lib/stripe/stripe_object.rb +4 -3
- data/lib/stripe/util.rb +2 -1
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/file_test.rb +73 -0
- data/test/stripe/file_upload_test.rb +50 -20
- data/test/stripe/issuing/dispute_test.rb +1 -1
- data/test/stripe/stripe_object_test.rb +1 -1
- data/test/test_helper.rb +1 -5
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1bbd688d73104dce2fc75c1363172aed7f44f6f6e3d40e634588adc1efd9cb3
|
4
|
+
data.tar.gz: b05dd5cec9bdaabdd57f305fd1cd08058158d71cea7f2377e98949f12d856c57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccb476039053498ddd0b3e67971acdf6b35d81fc7c86b5871523d742eb8534d72f0d1094d93d5ae778125528c33fbfba6552ce3edde0e5b88114aba1b5f3c6c1
|
7
|
+
data.tar.gz: a347c29e5cf52a0df6d12232cb3cb82a371b536858ce254e296dd1292e3d1422606eb87577307480a6abd5baa706cafb8d444c56c45eb6c7f156d9f048ed9af3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.27.0
|
data/lib/stripe.rb
CHANGED
@@ -55,8 +55,8 @@ require "stripe/dispute"
|
|
55
55
|
require "stripe/ephemeral_key"
|
56
56
|
require "stripe/event"
|
57
57
|
require "stripe/exchange_rate"
|
58
|
+
require "stripe/file"
|
58
59
|
require "stripe/file_link"
|
59
|
-
require "stripe/file_upload"
|
60
60
|
require "stripe/invoice"
|
61
61
|
require "stripe/invoice_item"
|
62
62
|
require "stripe/invoice_line_item"
|
@@ -103,7 +103,7 @@ module Stripe
|
|
103
103
|
|
104
104
|
@api_base = "https://api.stripe.com"
|
105
105
|
@connect_base = "https://connect.stripe.com"
|
106
|
-
@uploads_base = "https://
|
106
|
+
@uploads_base = "https://files.stripe.com"
|
107
107
|
|
108
108
|
@log_level = nil
|
109
109
|
@logger = nil
|
@@ -1,23 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Stripe
|
4
|
-
class
|
4
|
+
class File < APIResource
|
5
5
|
extend Stripe::APIOperations::Create
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
|
8
|
-
|
8
|
+
# This resource can have two different object names. In latter API
|
9
|
+
# versions, only `file` is used, but since stripe-ruby may be used with
|
10
|
+
# any API version, we need to support deserializing the older
|
11
|
+
# `file_upload` object into the same class.
|
12
|
+
OBJECT_NAME = "file".freeze
|
13
|
+
OBJECT_NAME_ALT = "file_upload".freeze
|
9
14
|
|
10
15
|
def self.resource_url
|
11
16
|
"/v1/files"
|
12
17
|
end
|
13
18
|
|
14
|
-
def self.request(method, url, params = {}, opts = {})
|
15
|
-
opts = {
|
16
|
-
api_base: Stripe.uploads_base,
|
17
|
-
}.merge(Util.normalize_opts(opts))
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
19
|
def self.create(params = {}, opts = {})
|
22
20
|
# rest-client would accept a vanilla `File` for upload, but Faraday does
|
23
21
|
# not. Support the old API by wrapping a `File`-like object with an
|
@@ -27,9 +25,13 @@ module Stripe
|
|
27
25
|
end
|
28
26
|
|
29
27
|
opts = {
|
28
|
+
api_base: Stripe.uploads_base,
|
30
29
|
content_type: "multipart/form-data",
|
31
30
|
}.merge(Util.normalize_opts(opts))
|
32
31
|
super
|
33
32
|
end
|
34
33
|
end
|
34
|
+
|
35
|
+
# For backwards compatibility, the `File` class is aliased to `FileUpload`.
|
36
|
+
FileUpload = File
|
35
37
|
end
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -96,13 +96,14 @@ module Stripe
|
|
96
96
|
other.is_a?(StripeObject) && @values == other.instance_variable_get(:@values)
|
97
97
|
end
|
98
98
|
|
99
|
-
# Hash equality. As with
|
99
|
+
# Hash equality. As with `#==`, we consider two equivalent Stripe objects equal.
|
100
100
|
def eql?(other)
|
101
|
+
# Defer to the implementation on `#==`.
|
101
102
|
self == other
|
102
103
|
end
|
103
104
|
|
104
|
-
# As
|
105
|
-
# equivalent objects.
|
105
|
+
# As with equality in `#==` and `#eql?`, we hash two Stripe objects to the
|
106
|
+
# same value if they're equivalent objects.
|
106
107
|
def hash
|
107
108
|
@values.hash
|
108
109
|
end
|
data/lib/stripe/util.rb
CHANGED
@@ -64,8 +64,9 @@ module Stripe
|
|
64
64
|
EphemeralKey::OBJECT_NAME => EphemeralKey,
|
65
65
|
Event::OBJECT_NAME => Event,
|
66
66
|
ExchangeRate::OBJECT_NAME => ExchangeRate,
|
67
|
+
File::OBJECT_NAME => File,
|
68
|
+
File::OBJECT_NAME_ALT => File,
|
67
69
|
FileLink::OBJECT_NAME => FileLink,
|
68
|
-
FileUpload::OBJECT_NAME => FileUpload,
|
69
70
|
Invoice::OBJECT_NAME => Invoice,
|
70
71
|
InvoiceItem::OBJECT_NAME => InvoiceItem,
|
71
72
|
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
|
data/lib/stripe/version.rb
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../../test_helper", __FILE__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
class FileTest < Test::Unit::TestCase
|
7
|
+
should "be listable" do
|
8
|
+
files = Stripe::File.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/files"
|
10
|
+
assert files.data.is_a?(Array)
|
11
|
+
assert files.data[0].is_a?(Stripe::File)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
file = Stripe::File.retrieve("file_123")
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/files/file_123"
|
17
|
+
assert file.is_a?(Stripe::File)
|
18
|
+
end
|
19
|
+
|
20
|
+
context ".create" do
|
21
|
+
setup do
|
22
|
+
# We don't point to the same host for the API and uploads in
|
23
|
+
# production, but `stripe-mock` supports both APIs.
|
24
|
+
Stripe.uploads_base = Stripe.api_base
|
25
|
+
|
26
|
+
# Set `api_base` to `nil` to ensure that these requests are _not_ sent
|
27
|
+
# to the default API hostname.
|
28
|
+
Stripe.api_base = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
should "be creatable with a File" do
|
32
|
+
file = Stripe::File.create(
|
33
|
+
purpose: "dispute_evidence",
|
34
|
+
file: ::File.new(__FILE__)
|
35
|
+
)
|
36
|
+
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
37
|
+
assert file.is_a?(Stripe::File)
|
38
|
+
end
|
39
|
+
|
40
|
+
should "be creatable with a Tempfile" do
|
41
|
+
tempfile = Tempfile.new("foo")
|
42
|
+
tempfile.write("Hello world")
|
43
|
+
tempfile.rewind
|
44
|
+
|
45
|
+
file = Stripe::File.create(
|
46
|
+
purpose: "dispute_evidence",
|
47
|
+
file: tempfile
|
48
|
+
)
|
49
|
+
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
50
|
+
assert file.is_a?(Stripe::File)
|
51
|
+
end
|
52
|
+
|
53
|
+
should "be creatable with Faraday::UploadIO" do
|
54
|
+
file = Stripe::File.create(
|
55
|
+
purpose: "dispute_evidence",
|
56
|
+
file: Faraday::UploadIO.new(::File.new(__FILE__), nil)
|
57
|
+
)
|
58
|
+
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
59
|
+
assert file.is_a?(Stripe::File)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
should "be deserializable when `object=file`" do
|
64
|
+
file = Stripe::Util.convert_to_stripe_object({ object: "file" }, {})
|
65
|
+
assert file.is_a?(Stripe::File)
|
66
|
+
end
|
67
|
+
|
68
|
+
should "be deserializable when `object=file_upload`" do
|
69
|
+
file = Stripe::Util.convert_to_stripe_object({ object: "file_upload" }, {})
|
70
|
+
assert file.is_a?(Stripe::File)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -3,43 +3,73 @@
|
|
3
3
|
require ::File.expand_path("../../test_helper", __FILE__)
|
4
4
|
|
5
5
|
module Stripe
|
6
|
+
# This is a strict copy of `FileTest`, except that it uses
|
7
|
+
# `Stripe::FileUpload` instead of `Stripe::File`.
|
6
8
|
class FileUploadTest < Test::Unit::TestCase
|
7
9
|
should "be listable" do
|
8
10
|
files = Stripe::FileUpload.list
|
11
|
+
assert_requested :get, "#{Stripe.api_base}/v1/files"
|
9
12
|
assert files.data.is_a?(Array)
|
10
13
|
assert files.data[0].is_a?(Stripe::FileUpload)
|
11
14
|
end
|
12
15
|
|
13
16
|
should "be retrievable" do
|
14
17
|
file = Stripe::FileUpload.retrieve("file_123")
|
18
|
+
assert_requested :get, "#{Stripe.api_base}/v1/files/file_123"
|
15
19
|
assert file.is_a?(Stripe::FileUpload)
|
16
20
|
end
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
context ".create" do
|
23
|
+
setup do
|
24
|
+
# We don't point to the same host for the API and uploads in
|
25
|
+
# production, but `stripe-mock` supports both APIs.
|
26
|
+
Stripe.uploads_base = Stripe.api_base
|
27
|
+
|
28
|
+
# Set `api_base` to `nil` to ensure that these requests are _not_ sent
|
29
|
+
# to the default API hostname. `api_base` is reset when each test
|
30
|
+
# starts so this won't affect the global state.
|
31
|
+
Stripe.api_base = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
should "be creatable with a File" do
|
35
|
+
file = Stripe::FileUpload.create(
|
36
|
+
purpose: "dispute_evidence",
|
37
|
+
file: ::File.new(__FILE__)
|
38
|
+
)
|
39
|
+
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
40
|
+
assert file.is_a?(Stripe::FileUpload)
|
41
|
+
end
|
25
42
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
43
|
+
should "be creatable with a Tempfile" do
|
44
|
+
tempfile = Tempfile.new("foo")
|
45
|
+
tempfile.write("Hello world")
|
46
|
+
tempfile.rewind
|
47
|
+
|
48
|
+
file = Stripe::FileUpload.create(
|
49
|
+
purpose: "dispute_evidence",
|
50
|
+
file: tempfile
|
51
|
+
)
|
52
|
+
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
53
|
+
assert file.is_a?(Stripe::FileUpload)
|
54
|
+
end
|
55
|
+
|
56
|
+
should "be creatable with Faraday::UploadIO" do
|
57
|
+
file = Stripe::FileUpload.create(
|
58
|
+
purpose: "dispute_evidence",
|
59
|
+
file: Faraday::UploadIO.new(::File.new(__FILE__), nil)
|
60
|
+
)
|
61
|
+
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
62
|
+
assert file.is_a?(Stripe::FileUpload)
|
63
|
+
end
|
64
|
+
end
|
30
65
|
|
31
|
-
|
32
|
-
|
33
|
-
file: tempfile
|
34
|
-
)
|
66
|
+
should "be deserializable when `object=file`" do
|
67
|
+
file = Stripe::Util.convert_to_stripe_object({ object: "file" }, {})
|
35
68
|
assert file.is_a?(Stripe::FileUpload)
|
36
69
|
end
|
37
70
|
|
38
|
-
should "be
|
39
|
-
file = Stripe::
|
40
|
-
purpose: "dispute_evidence",
|
41
|
-
file: Faraday::UploadIO.new(::File.new(__FILE__), nil)
|
42
|
-
)
|
71
|
+
should "be deserializable when `object=file_upload`" do
|
72
|
+
file = Stripe::Util.convert_to_stripe_object({ object: "file_upload" }, {})
|
43
73
|
assert file.is_a?(Stripe::FileUpload)
|
44
74
|
end
|
45
75
|
end
|
@@ -8,7 +8,7 @@ module Stripe
|
|
8
8
|
should "be creatable" do
|
9
9
|
dispute = Stripe::Issuing::Dispute.create(
|
10
10
|
reason: "fraudulent",
|
11
|
-
|
11
|
+
disputed_transaction: "ipi_123"
|
12
12
|
)
|
13
13
|
assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes"
|
14
14
|
assert dispute.is_a?(Stripe::Issuing::Dispute)
|
@@ -118,7 +118,7 @@ module Stripe
|
|
118
118
|
end
|
119
119
|
|
120
120
|
context "#eql?" do
|
121
|
-
should "produce
|
121
|
+
should "produce true for two equivalent Stripe objects" do
|
122
122
|
obj1 = Stripe::StripeObject.construct_from(id: 1, name: "Stripe")
|
123
123
|
obj2 = Stripe::StripeObject.construct_from(id: 1, name: "Stripe")
|
124
124
|
assert obj1.eql?(obj2)
|
data/test/test_helper.rb
CHANGED
@@ -16,7 +16,7 @@ PROJECT_ROOT = ::File.expand_path("../../", __FILE__)
|
|
16
16
|
require ::File.expand_path("../test_data", __FILE__)
|
17
17
|
|
18
18
|
# If changing this number, please also change it in `.travis.yml`.
|
19
|
-
MOCK_MINIMUM_VERSION = "0.
|
19
|
+
MOCK_MINIMUM_VERSION = "0.32.0".freeze
|
20
20
|
MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111
|
21
21
|
|
22
22
|
# Disable all real network connections except those that are outgoing to
|
@@ -50,10 +50,6 @@ module Test
|
|
50
50
|
Stripe.api_key = "sk_test_123"
|
51
51
|
Stripe.api_base = "http://localhost:#{MOCK_PORT}"
|
52
52
|
|
53
|
-
# We don't point to the same host for the API and uploads in
|
54
|
-
# production, but `stripe-mock` supports both APIs.
|
55
|
-
Stripe.uploads_base = Stripe.api_base
|
56
|
-
|
57
53
|
stub_connect
|
58
54
|
end
|
59
55
|
|
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.
|
4
|
+
version: 3.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -76,8 +76,8 @@ files:
|
|
76
76
|
- lib/stripe/errors.rb
|
77
77
|
- lib/stripe/event.rb
|
78
78
|
- lib/stripe/exchange_rate.rb
|
79
|
+
- lib/stripe/file.rb
|
79
80
|
- lib/stripe/file_link.rb
|
80
|
-
- lib/stripe/file_upload.rb
|
81
81
|
- lib/stripe/invoice.rb
|
82
82
|
- lib/stripe/invoice_item.rb
|
83
83
|
- lib/stripe/invoice_line_item.rb
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- test/stripe/errors_test.rb
|
148
148
|
- test/stripe/exchange_rate_test.rb
|
149
149
|
- test/stripe/file_link_test.rb
|
150
|
+
- test/stripe/file_test.rb
|
150
151
|
- test/stripe/file_upload_test.rb
|
151
152
|
- test/stripe/invoice_item_test.rb
|
152
153
|
- test/stripe/invoice_line_item_test.rb
|
@@ -240,6 +241,7 @@ test_files:
|
|
240
241
|
- test/stripe/errors_test.rb
|
241
242
|
- test/stripe/exchange_rate_test.rb
|
242
243
|
- test/stripe/file_link_test.rb
|
244
|
+
- test/stripe/file_test.rb
|
243
245
|
- test/stripe/file_upload_test.rb
|
244
246
|
- test/stripe/invoice_item_test.rb
|
245
247
|
- test/stripe/invoice_line_item_test.rb
|