stripe 10.2.0 → 10.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1175af77634044ef0ef6efda0626ace1431bdb4ad52eb78c643af4eba8982faf
4
- data.tar.gz: 19863ceeab18b449560dc647213d5873eadb190db544015e88749b5e79414528
3
+ metadata.gz: 78c3e10c5e7afde049a2affb5bbb230e4e4525193353bcf4921ff2bdb7219ce9
4
+ data.tar.gz: 6e194c85cf1fe5b37289e5912be22a9ae885ad8aa4c66752a5181d7767cbdc1c
5
5
  SHA512:
6
- metadata.gz: 24f1e67f729c964e150bf991140467c85d2b85430da3a7d736cd6b6ae5a9ce8afac2664e27fb3df51d472eb23b1ae67f5933e019e8c6fd9c7639d32e4713a334
7
- data.tar.gz: 28dee05f7251e400ba32ace17cb0e8e78f63bfa156ba36c9d6f3baa7cc6d361d0e86826a962a117e70cd774628183eddf70d0379c9c485a74192b9844c3855c5
6
+ metadata.gz: 28c94abdfad1445b7c4f059bbda77e05638fd5b0fe3347a2cac7529ea632ede0a17db8e43dff34ed3e22488853cfa0494f05776dcdd042ace5362de5d920e106
7
+ data.tar.gz: b06f47d94deb9782211c81046795942a4b8787b13238e0e85c2dbee4f1aa946de9242d488031a0d87abe78ab0e3a61ca0a9689c19562fc9e41c5ec0d13720e39
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Changelog
2
+ ## 10.3.0 - 2023-12-14
3
+ * [#1294](https://github.com/stripe/stripe-ruby/pull/1294) Support sending parameters inside singleton retrieve
4
+
2
5
  ## 10.2.0 - 2023-11-30
3
6
  * [#1292](https://github.com/stripe/stripe-ruby/pull/1292) Update generated code
4
7
  * Add support for new resources `Climate.Order`, `Climate.Product`, and `Climate.Supplier`
data/Makefile CHANGED
@@ -5,7 +5,7 @@ update-version:
5
5
 
6
6
  codegen-format:
7
7
  bundle install --quiet
8
- bundle exec rubocop -o /dev/null --auto-correct
8
+ bundle exec rubocop -o /dev/null --autocorrect
9
9
 
10
10
  ci-test:
11
11
  bundle install && bundle exec rake test
data/README.md CHANGED
@@ -291,10 +291,11 @@ Stripe.set_app_info('MyAwesomePlugin', version: '1.2.34', url: 'https://myawesom
291
291
  This information is passed along when the library makes calls to the Stripe
292
292
  API.
293
293
 
294
- ### Request latency telemetry
294
+ ### Telemetry
295
295
 
296
- By default, the library sends request latency telemetry to Stripe. These
297
- numbers help Stripe improve the overall latency of its API for all users.
296
+ By default, the library sends telemetry to Stripe regarding request latency and feature usage. These
297
+ numbers help Stripe improve the overall latency of its API for all users, and
298
+ improve popular features.
298
299
 
299
300
  You can disable this behavior if you prefer:
300
301
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 10.2.0
1
+ 10.3.0
@@ -5,14 +5,14 @@ module Stripe
5
5
  module Request
6
6
  module ClassMethods
7
7
  def execute_resource_request(method, url,
8
- params = {}, opts = {})
8
+ params = {}, opts = {}, usage = [])
9
9
  execute_resource_request_internal(
10
- :execute_request, method, url, params, opts
10
+ :execute_request, method, url, params, opts, usage
11
11
  )
12
12
  end
13
13
 
14
14
  def execute_resource_request_stream(method, url,
15
- params = {}, opts = {},
15
+ params = {}, opts = {}, usage = [],
16
16
  &read_body_chunk_block)
17
17
  execute_resource_request_internal(
18
18
  :execute_request_stream,
@@ -20,18 +20,19 @@ module Stripe
20
20
  url,
21
21
  params,
22
22
  opts,
23
+ usage,
23
24
  &read_body_chunk_block
24
25
  )
25
26
  end
26
27
 
27
- private def request_stripe_object(method:, path:, params:, opts: {})
28
- resp, opts = execute_resource_request(method, path, params, opts)
28
+ private def request_stripe_object(method:, path:, params:, opts: {}, usage: [])
29
+ resp, opts = execute_resource_request(method, path, params, opts, usage)
29
30
  Util.convert_to_stripe_object_with_params(resp.data, params, opts)
30
31
  end
31
32
 
32
33
  private def execute_resource_request_internal(client_request_method_sym,
33
34
  method, url,
34
- params, opts,
35
+ params, opts, usage,
35
36
  &read_body_chunk_block)
36
37
  params ||= {}
37
38
 
@@ -53,7 +54,7 @@ module Stripe
53
54
  client_request_method_sym,
54
55
  method, url,
55
56
  api_base: api_base, api_key: api_key,
56
- headers: headers, params: params,
57
+ headers: headers, params: params, usage: usage,
57
58
  &read_body_chunk_block
58
59
  )
59
60
 
@@ -66,6 +67,7 @@ module Stripe
66
67
  [resp, opts_to_persist]
67
68
  end
68
69
 
70
+ # TODO: (major)
69
71
  # This method used to be called `request`, but it's such a short name
70
72
  # that it eventually conflicted with the name of a field on an API
71
73
  # resource (specifically, `Event#request`), so it was renamed to
@@ -111,9 +113,9 @@ module Stripe
111
113
  end
112
114
 
113
115
  protected def execute_resource_request(method, url,
114
- params = {}, opts = {})
116
+ params = {}, opts = {}, usage = [])
115
117
  opts = @opts.merge(Util.normalize_opts(opts))
116
- self.class.execute_resource_request(method, url, params, opts)
118
+ self.class.execute_resource_request(method, url, params, opts, usage)
117
119
  end
118
120
 
119
121
  protected def execute_resource_request_stream(method, url,
@@ -125,8 +127,8 @@ module Stripe
125
127
  )
126
128
  end
127
129
 
128
- private def request_stripe_object(method:, path:, params:, opts: {})
129
- resp, opts = execute_resource_request(method, path, params, opts)
130
+ private def request_stripe_object(method:, path:, params:, opts: {}, usage: [])
131
+ resp, opts = execute_resource_request(method, path, params, opts, usage)
130
132
  Util.convert_to_stripe_object_with_params(resp.data, params, opts)
131
133
  end
132
134
 
@@ -66,7 +66,7 @@ module Stripe
66
66
  # generated a uri for this object with an identifier baked in
67
67
  values.delete(:id)
68
68
 
69
- resp, opts = execute_resource_request(:post, save_url, values, opts)
69
+ resp, opts = execute_resource_request(:post, save_url, values, opts, ["save"])
70
70
  initialize_from(resp.data, opts)
71
71
  end
72
72
  extend Gem::Deprecate
@@ -17,8 +17,25 @@ module Stripe
17
17
  self.class.resource_url
18
18
  end
19
19
 
20
- def self.retrieve(opts = {})
21
- instance = new(nil, Util.normalize_opts(opts))
20
+ def self.retrieve(params_or_opts = {}, definitely_opts = nil)
21
+ opts = nil
22
+ params = nil
23
+ if definitely_opts.nil?
24
+ unrecognized_key = params_or_opts.keys.find { |k| !Util::OPTS_USER_SPECIFIED.include?(k) }
25
+ if unrecognized_key
26
+ raise ArgumentError,
27
+ "Unrecognized request option: #{unrecognized_key}. Did you mean to specify this as retrieve params? " \
28
+ "If so, you must explicitly pass an opts hash as a second argument. " \
29
+ "For example: .retrieve({#{unrecognized_key}: 'foo'}, {})"
30
+ end
31
+
32
+ opts = params_or_opts
33
+ else
34
+ opts = definitely_opts
35
+ params = params_or_opts
36
+ end
37
+
38
+ instance = new(params, Util.normalize_opts(opts))
22
39
  instance.refresh
23
40
  instance
24
41
  end
@@ -209,9 +209,9 @@ module Stripe
209
209
  end
210
210
 
211
211
  def execute_request(method, path,
212
- api_base: nil, api_key: nil, headers: {}, params: {})
212
+ api_base: nil, api_key: nil, headers: {}, params: {}, usage: [])
213
213
  http_resp, api_key = execute_request_internal(
214
- method, path, api_base, api_key, headers, params
214
+ method, path, api_base, api_key, headers, params, usage
215
215
  )
216
216
 
217
217
  begin
@@ -240,7 +240,7 @@ module Stripe
240
240
  # passed, then a StripeStreamResponse is returned containing an IO stream
241
241
  # with the response body.
242
242
  def execute_request_stream(method, path,
243
- api_base: nil, api_key: nil,
243
+ api_base: nil, api_key: nil, usage: [],
244
244
  headers: {}, params: {},
245
245
  &read_body_chunk_block)
246
246
  unless block_given?
@@ -249,7 +249,7 @@ module Stripe
249
249
  end
250
250
 
251
251
  http_resp, api_key = execute_request_internal(
252
- method, path, api_base, api_key, headers, params, &read_body_chunk_block
252
+ method, path, api_base, api_key, headers, params, usage, &read_body_chunk_block
253
253
  )
254
254
 
255
255
  # When the read_body_chunk_block is given, we no longer have access to the
@@ -428,7 +428,7 @@ module Stripe
428
428
  end
429
429
 
430
430
  private def execute_request_internal(method, path,
431
- api_base, api_key, headers, params,
431
+ api_base, api_key, headers, params, usage,
432
432
  &read_body_chunk_block)
433
433
  raise ArgumentError, "method should be a symbol" \
434
434
  unless method.is_a?(Symbol)
@@ -490,7 +490,7 @@ module Stripe
490
490
  end
491
491
 
492
492
  http_resp =
493
- execute_request_with_rescues(method, api_base, headers, context) do
493
+ execute_request_with_rescues(method, api_base, headers, usage, context) do
494
494
  self.class
495
495
  .default_connection_manager(config)
496
496
  .execute_request(method, url,
@@ -560,7 +560,7 @@ module Stripe
560
560
  http_status >= 400
561
561
  end
562
562
 
563
- private def execute_request_with_rescues(method, api_base, headers, context)
563
+ private def execute_request_with_rescues(method, api_base, headers, usage, context)
564
564
  num_retries = 0
565
565
 
566
566
  begin
@@ -586,7 +586,7 @@ module Stripe
586
586
  if config.enable_telemetry? && context.request_id
587
587
  request_duration_ms = (request_duration * 1000).to_i
588
588
  @last_request_metrics =
589
- StripeRequestMetrics.new(context.request_id, request_duration_ms)
589
+ StripeRequestMetrics.new(context.request_id, request_duration_ms, usage: usage)
590
590
  end
591
591
 
592
592
  # We rescue all exceptions from a request so that we have an easy spot to
@@ -1038,13 +1038,19 @@ module Stripe
1038
1038
  # Request duration in milliseconds
1039
1039
  attr_accessor :request_duration_ms
1040
1040
 
1041
- def initialize(request_id, request_duration_ms)
1041
+ # list of names of tracked behaviors associated with this request
1042
+ attr_accessor :usage
1043
+
1044
+ def initialize(request_id, request_duration_ms, usage: [])
1042
1045
  self.request_id = request_id
1043
1046
  self.request_duration_ms = request_duration_ms
1047
+ self.usage = usage
1044
1048
  end
1045
1049
 
1046
1050
  def payload
1047
- { request_id: request_id, request_duration_ms: request_duration_ms }
1051
+ ret = { request_id: request_id, request_duration_ms: request_duration_ms }
1052
+ ret[:usage] = usage if !usage.nil? && !usage.empty?
1053
+ ret
1048
1054
  end
1049
1055
  end
1050
1056
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "10.2.0"
4
+ VERSION = "10.3.0"
5
5
  end
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: 10.2.0
4
+ version: 10.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-30 00:00:00.000000000 Z
11
+ date: 2023-12-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Stripe is the easiest way to accept payments online. See https://stripe.com
14
14
  for details.