stripe 3.13.0 → 3.13.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 719456b37833bcc702e2bfc07e527893605d8a1c
4
- data.tar.gz: 5e7be4888ad520802089c4038d3a309db8b38bdc
3
+ metadata.gz: 694536c3749e651a8bfcf6dee6fc625ec982d747
4
+ data.tar.gz: 5c20bddece5f1ac3eae41a876904be08367f5918
5
5
  SHA512:
6
- metadata.gz: 8e8b56ed5c634e90cc5e7ecd7bd351ba1c4a797607256762fda2862ceaf88fdc471919d94618a2643df85683624ff88acb40e417898bff66ec963d341e18c204
7
- data.tar.gz: 6cda7ebdcdae5837a1ba955421546a16999ee33d091bf47ea5d75ee996cf00ba8caacef5df9196954c6ec274436a887d10f508fb9f1f9d73979aa9017c7e67f4
6
+ metadata.gz: 06a5e474c9ab8a042a3a3e98f6d4292db3a4bcd279fca448292adcff957b166847d78d8c22533a5d95ae0524fc504daa5395fab386badc01bc95968bbd0f46a9
7
+ data.tar.gz: 3170f632390bb3fc6940d79b68647fb1d8a0fdeaa63858c2f2ae08ff8b9776d89270ec10c7777af48a87bd3b9e500857ab1694beedd5952891396f5289d4bcb2
@@ -8,17 +8,17 @@
8
8
 
9
9
  # Offense count: 19
10
10
  Metrics/AbcSize:
11
- Max: 45
11
+ Max: 52
12
12
 
13
13
  # Offense count: 27
14
14
  # Configuration parameters: CountComments, ExcludedMethods.
15
15
  Metrics/BlockLength:
16
- Max: 469
16
+ Max: 496
17
17
 
18
18
  # Offense count: 8
19
19
  # Configuration parameters: CountComments.
20
20
  Metrics/ClassLength:
21
- Max: 597
21
+ Max: 624
22
22
 
23
23
  # Offense count: 11
24
24
  Metrics/CyclomaticComplexity:
@@ -33,7 +33,7 @@ Metrics/LineLength:
33
33
  # Offense count: 32
34
34
  # Configuration parameters: CountComments.
35
35
  Metrics/MethodLength:
36
- Max: 46
36
+ Max: 48
37
37
 
38
38
  # Offense count: 1
39
39
  # Configuration parameters: CountComments.
@@ -16,7 +16,8 @@ sudo: false
16
16
 
17
17
  env:
18
18
  global:
19
- - STRIPE_MOCK_VERSION=0.12.0
19
+ # If changing this number, please also change it in `test/test_helper.rb`.
20
+ - STRIPE_MOCK_VERSION=0.15.0
20
21
 
21
22
  cache:
22
23
  directories:
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.13.1 - 2018-05-07
4
+ * [#647](https://github.com/stripe/stripe-ruby/pull/647) Merge query parameters coming from path with `params` argument
5
+
3
6
  ## 3.13.0 - 2018-04-11
4
7
  * [#498](https://github.com/stripe/stripe-ruby/pull/498) Add support for flexible billing primitives
5
8
 
data/README.md CHANGED
@@ -80,14 +80,20 @@ require "stripe"
80
80
 
81
81
  Stripe::Charge.list(
82
82
  {},
83
- :api_key => "sk_test_...",
84
- :stripe_account => "acct_..."
83
+ {
84
+ :api_key => "sk_test_...",
85
+ :stripe_account => "acct_...",
86
+ :stripe_version => "2018-02-28"
87
+ }
85
88
  )
86
89
 
87
90
  Stripe::Charge.retrieve(
88
91
  "ch_18atAXCdGbJFKhCuBAa4532Z",
89
- :api_key => "sk_test_...",
90
- :stripe_account => "acct_..."
92
+ {
93
+ :api_key => "sk_test_...",
94
+ :stripe_account => "acct_...",
95
+ :stripe_version => "2018-02-28"
96
+ }
91
97
  )
92
98
  ```
93
99
 
@@ -108,6 +114,15 @@ end
108
114
  puts resp.request_id
109
115
  ```
110
116
 
117
+ ### Configuration an API Version
118
+
119
+ By default, the library will use the API version pinned to the account making
120
+ a request. This can be overridden with this global option:
121
+
122
+ Stripe.api_version = "2018-02-28"
123
+
124
+ See [versioning in the API reference][versioning] for more information.
125
+
111
126
  ### Configuring CA Bundles
112
127
 
113
128
  By default, the library will use its own internal bundle of known CA
@@ -204,6 +219,7 @@ Update the bundled [stripe-mock] by editing the version number found in
204
219
  [faraday]: https://github.com/lostisland/faraday
205
220
  [idempotency-keys]: https://stripe.com/docs/api/ruby#idempotent_requests
206
221
  [stripe-mock]: https://github.com/stripe/stripe-mock
222
+ [versioning]: https://stripe.com/docs/api/ruby#versioning
207
223
 
208
224
  <!--
209
225
  # vim: set tw=79:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.13.0
1
+ 3.13.1
@@ -134,6 +134,23 @@ module Stripe
134
134
  end
135
135
  end
136
136
 
137
+ # This works around an edge case where we end up with both query
138
+ # parameters in `query_params` and query parameters that are appended
139
+ # onto the end of the given path. In this case, Faraday will silently
140
+ # discard the URL's parameters which may break a request.
141
+ #
142
+ # Here we decode any parameters that were added onto the end of a path
143
+ # and add them to `query_params` so that all parameters end up in one
144
+ # place and all of them are correctly included in the final request.
145
+ u = URI.parse(path)
146
+ unless u.query.nil?
147
+ query_params ||= {}
148
+ query_params = Hash[URI.decode_www_form(u.query)].merge(query_params)
149
+
150
+ # Reset the path minus any query parameters that were specified.
151
+ path = u.path
152
+ end
153
+
137
154
  headers = request_headers(api_key, method)
138
155
  .update(Util.normalize_headers(headers))
139
156
 
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = "3.13.0".freeze
2
+ VERSION = "3.13.1".freeze
3
3
  end
@@ -2,43 +2,18 @@ require File.expand_path("../../test_helper", __FILE__)
2
2
 
3
3
  module Stripe
4
4
  class FileUploadTest < Test::Unit::TestCase
5
- # Note that these tests are written different from others because we
6
- # don't have anything on the uploads service in our OpenAPI spec. This is
7
- # something that should be looked into at some point. We may need to ship
8
- # a separate spec for it though, so it's high effort with low reward for
9
- # the time being.
10
- FIXTURE = {
11
- id: "file_123",
12
- object: "file_upload",
13
- }.freeze
14
-
15
5
  should "be listable" do
16
- stub_request(:get, "#{Stripe.uploads_base}/v1/files")
17
- .to_return(body: JSON.generate(data: [FIXTURE],
18
- object: "list",
19
- resource_url: "/v1/files"))
20
-
21
6
  files = Stripe::FileUpload.list
22
7
  assert files.data.is_a?(Array)
23
8
  assert files.data[0].is_a?(Stripe::FileUpload)
24
9
  end
25
10
 
26
11
  should "be retrievable" do
27
- stub_request(:get, "#{Stripe.uploads_base}/v1/files/file_123")
28
- .to_return(body: JSON.generate(FIXTURE))
29
-
30
12
  file = Stripe::FileUpload.retrieve("file_123")
31
13
  assert file.is_a?(Stripe::FileUpload)
32
14
  end
33
15
 
34
16
  should "be creatable with a File" do
35
- stub_request(:post, "#{Stripe.uploads_base}/v1/files")
36
- .with(headers: {
37
- "Content-Type" => /\A#{Faraday::Request::Multipart.mime_type}/,
38
- }) do |request|
39
- request.body =~ /FileUploadTest/
40
- end.to_return(body: JSON.generate(FIXTURE))
41
-
42
17
  file = Stripe::FileUpload.create(
43
18
  purpose: "dispute_evidence",
44
19
  file: File.new(__FILE__)
@@ -47,13 +22,6 @@ module Stripe
47
22
  end
48
23
 
49
24
  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
25
  tempfile = Tempfile.new("foo")
58
26
  tempfile.write("Hello world")
59
27
  tempfile.rewind
@@ -66,13 +34,6 @@ module Stripe
66
34
  end
67
35
 
68
36
  should "be creatable with Faraday::UploadIO" do
69
- stub_request(:post, "#{Stripe.uploads_base}/v1/files")
70
- .with(headers: {
71
- "Content-Type" => /\A#{Faraday::Request::Multipart.mime_type}/,
72
- }) do |request|
73
- request.body =~ /FileUploadTest/
74
- end.to_return(body: JSON.generate(FIXTURE))
75
-
76
37
  file = Stripe::FileUpload.create(
77
38
  purpose: "dispute_evidence",
78
39
  file: Faraday::UploadIO.new(File.new(__FILE__), nil)
@@ -681,6 +681,35 @@ module Stripe
681
681
  }
682
682
  )
683
683
  end
684
+
685
+ should "merge query parameters in URL and params" do
686
+ client = StripeClient.new
687
+ client.execute_request(:get, "/v1/invoices/upcoming?coupon=25OFF", params: {
688
+ customer: "cus_123",
689
+ })
690
+ assert_requested(
691
+ :get,
692
+ "#{Stripe.api_base}/v1/invoices/upcoming?",
693
+ query: {
694
+ coupon: "25OFF",
695
+ customer: "cus_123",
696
+ }
697
+ )
698
+ end
699
+
700
+ should "prefer query parameters in params when specified in URL as well" do
701
+ client = StripeClient.new
702
+ client.execute_request(:get, "/v1/invoices/upcoming?customer=cus_query", params: {
703
+ customer: "cus_param",
704
+ })
705
+ assert_requested(
706
+ :get,
707
+ "#{Stripe.api_base}/v1/invoices/upcoming?",
708
+ query: {
709
+ customer: "cus_param",
710
+ }
711
+ )
712
+ end
684
713
  end
685
714
  end
686
715
 
@@ -13,7 +13,8 @@ PROJECT_ROOT = File.expand_path("../../", __FILE__)
13
13
 
14
14
  require File.expand_path("../test_data", __FILE__)
15
15
 
16
- MOCK_MINIMUM_VERSION = "0.12.0".freeze
16
+ # If changing this number, please also change it in `.travis.yml`.
17
+ MOCK_MINIMUM_VERSION = "0.15.0".freeze
17
18
  MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111
18
19
 
19
20
  # Disable all real network connections except those that are outgoing to
@@ -46,6 +47,11 @@ module Test
46
47
  setup do
47
48
  Stripe.api_key = "sk_test_123"
48
49
  Stripe.api_base = "http://localhost:#{MOCK_PORT}"
50
+
51
+ # We don't point to the same host for the API and uploads in
52
+ # production, but `stripe-mock` supports both APIs.
53
+ Stripe.uploads_base = Stripe.api_base
54
+
49
55
  stub_connect
50
56
  end
51
57
 
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.13.0
4
+ version: 3.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-11 00:00:00.000000000 Z
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday