stripe 20.0.0 → 20.0.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.
@@ -172,6 +172,7 @@ module Stripe
172
172
  def self.v2_object_names_to_classes
173
173
  {
174
174
  V2::ListObject.object_name => V2::ListObject,
175
+ V2::SearchResultObject.object_name => V2::SearchResultObject,
175
176
 
176
177
  # v2 object classes: The beginning of the section generated from our OpenAPI spec
177
178
  V2::Billing::MeterEvent.object_name => V2::Billing::MeterEvent,
@@ -3,6 +3,12 @@
3
3
  module Stripe
4
4
  class SingletonAPIResource < APIResource
5
5
  def self.resource_url
6
+ if name.include?("Stripe::V2")
7
+ raise NotImplementedError,
8
+ "V2 singleton resources do not have a defined URL. Please use the StripeClient " \
9
+ "to make V2 requests"
10
+ end
11
+
6
12
  if self == SingletonAPIResource
7
13
  raise NotImplementedError,
8
14
  "SingletonAPIResource is an abstract class. You should " \
@@ -1052,7 +1052,7 @@ module Stripe
1052
1052
  def initialize(client, webhook_secret, &fallback_callback)
1053
1053
  super(client, &fallback_callback)
1054
1054
 
1055
- raise ArgumentError, "webhook_secret must be a non-empty string" if webhook_secret.nil? || webhook_secret.empty?
1055
+ raise ArgumentError, "webhook_secret must be a non-empty string" if Util.webhook_secret_blank?(webhook_secret)
1056
1056
 
1057
1057
  @webhook_secret = webhook_secret
1058
1058
  end
@@ -9,6 +9,16 @@ module Stripe
9
9
  end
10
10
 
11
11
  def request(method:, path:, base_address:, params: {}, opts: {})
12
+ params = params.to_h if params.is_a?(RequestParams)
13
+ if method == :post &&
14
+ path.split("?", 2).first.start_with?("/v2/") &&
15
+ path.split("?", 2).first.end_with?("/search") &&
16
+ (params.key?(:limit) || params.key?("limit"))
17
+ params = params.dup
18
+ limit = params.delete(:limit) || params.delete("limit")
19
+ separator = path.include?("?") ? "&" : "?"
20
+ path = "#{path}#{separator}limit=#{URI.encode_www_form_component(limit)}"
21
+ end
12
22
  @requestor.execute_request(
13
23
  method,
14
24
  path,
data/lib/stripe/util.rb CHANGED
@@ -145,7 +145,8 @@ module Stripe
145
145
  when Hash
146
146
  # TODO: This is a terrible hack.
147
147
  # Waiting on https://go/j/API_SERVICES-3167 to add an object in v2 lists
148
- if api_mode == :v2 && data.include?(:data) && data.include?(:next_page_url)
148
+ if api_mode == :v2 && data.include?(:data) && data.include?(:next_page_url) &&
149
+ data[:object] != V2::SearchResultObject::OBJECT_NAME
149
150
  return V2::ListObject.construct_from(data, opts, last_response, api_mode, requestor)
150
151
  end
151
152
 
@@ -173,7 +174,9 @@ module Stripe
173
174
 
174
175
  # set filters so that we can fetch the same limit, expansions, and
175
176
  # predicates when accessing the next and previous pages
176
- obj.filters = params.dup if obj && (obj.is_a?(SearchResultObject) || obj.is_a?(ListObject))
177
+ if obj && (obj.is_a?(SearchResultObject) || obj.is_a?(ListObject) || obj.is_a?(V2::SearchResultObject))
178
+ obj.filters = StripeObject.send(:deep_copy, params, api_mode: api_mode)
179
+ end
177
180
 
178
181
  obj
179
182
  else
@@ -375,6 +378,10 @@ module Stripe
375
378
  res.zero?
376
379
  end
377
380
 
381
+ def self.webhook_secret_blank?(secret)
382
+ secret.nil? || secret.empty? || secret.match?(/\A[ \t\r\n\f\v]*\z/)
383
+ end
384
+
378
385
  # Asserts that a request path is origin-relative: that it begins with a
379
386
  # single "/" and carries no scheme, authority or userinfo.
380
387
  #
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ module V2
5
+ class SearchResultObject < StripeObject
6
+ include Enumerable
7
+ include Stripe::APIOperations::Request
8
+
9
+ OBJECT_NAME = "v2.search_result"
10
+ attr_accessor :filters
11
+
12
+ def self.object_name
13
+ OBJECT_NAME
14
+ end
15
+
16
+ def initialize(*args)
17
+ super
18
+ self.filters = {}
19
+ end
20
+
21
+ def each(&blk)
22
+ data.each(&blk)
23
+ end
24
+
25
+ def empty?
26
+ data.empty?
27
+ end
28
+
29
+ def auto_paging_each(&blk)
30
+ return enum_for(:auto_paging_each) unless block_given?
31
+
32
+ page = self
33
+ loop do
34
+ page.each(&blk)
35
+ break if page.next_page_url.nil?
36
+
37
+ page = page.fetch_next_page
38
+ rescue LocalJumpError => e
39
+ raise unless e.reason == :break
40
+
41
+ break
42
+ end
43
+ end
44
+
45
+ def fetch_next_page(opts = {})
46
+ return self.class.construct_from({ data: [] }, opts, nil, :v2) if next_page_url.nil?
47
+
48
+ params = filters.dup
49
+ params.delete(:limit)
50
+ params.delete("limit")
51
+
52
+ _request(
53
+ method: :post,
54
+ path: next_page_url,
55
+ params: params,
56
+ opts: opts,
57
+ base_address: :api
58
+ ).tap { |page| page.filters = filters }
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "20.0.0"
4
+ VERSION = "20.0.1"
5
5
  end
@@ -135,7 +135,7 @@ module Stripe
135
135
  )
136
136
  end
137
137
 
138
- if secret.nil? || secret.empty?
138
+ if Util.webhook_secret_blank?(secret)
139
139
  raise SignatureVerificationError.new(
140
140
  "No webhook secret value was provided. It should start with " \
141
141
  "`whsec_`",
data/lib/stripe.rb CHANGED
@@ -48,6 +48,7 @@ require "stripe/stripe_object"
48
48
  require "stripe/stripe_response"
49
49
  require "stripe/list_object"
50
50
  require "stripe/v2_list_object"
51
+ require "stripe/v2_search_result_object"
51
52
  require "stripe/search_result_object"
52
53
  require "stripe/error_object"
53
54
  require "stripe/api_resource"
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: 20.0.0
4
+ version: 20.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-01 00:00:00.000000000 Z
11
+ date: 2026-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal
@@ -1338,6 +1338,7 @@ files:
1338
1338
  - lib/stripe/telemetry_id.rb
1339
1339
  - lib/stripe/util.rb
1340
1340
  - lib/stripe/v2_list_object.rb
1341
+ - lib/stripe/v2_search_result_object.rb
1341
1342
  - lib/stripe/v2_type_coercion.rb
1342
1343
  - lib/stripe/version.rb
1343
1344
  - lib/stripe/webhook.rb