Skip to content

Commit

Permalink
Merge pull request #1311 from stripe/helenye-use-deprecation-gem-search
Browse files Browse the repository at this point in the history
Use the deprecation gem in search and clean up usage of the gem
  • Loading branch information
helenye-stripe authored Jan 19, 2024
2 parents a685a13 + 08b0063 commit 37293f6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/stripe/api_operations/search.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

# TODO: (major) Deprecated, Remove along with extends
module Stripe
module APIOperations
# The _search method via API Operations is deprecated.
# Please use the search method from within the resource instead.
module Search
def _search(search_url, filters = {}, opts = {})
request_stripe_object(
Expand All @@ -12,6 +13,9 @@ def _search(search_url, filters = {}, opts = {})
opts: opts
)
end

extend Gem::Deprecate
deprecate :_search, "request_stripe_object", 2024, 1
end
end
end
1 change: 0 additions & 1 deletion lib/stripe/resources/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module Stripe
# for a Standard or Express account, some parameters are no longer returned. These are marked as **Custom Only** or **Custom and Express**
# below. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts).
class Account < APIResource
extend Gem::Deprecate
extend Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
extend Stripe::APIOperations::List
Expand Down
20 changes: 20 additions & 0 deletions test/stripe/api_operations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ def self.protected_fields
end
end

context ".search" do
should "warn that ._search is deprecated" do
old_stderr = $stderr
$stderr = StringIO.new
begin
stub_request(:post, "#{Stripe.api_base}/v1/customers/search?query=foo:bar")
.to_return(body: JSON.generate(object: "customer"))

client = StripeClient.new
client.request { Customer._search("/v1/customers/search", query: "foo:bar") }

message = "NOTE: Stripe::Customer._search is deprecated; use request_stripe_object " \
"instead. It will be removed on or after 2024-01."
assert_match Regexp.new(message), $stderr.string
ensure
$stderr = old_stderr
end
end
end

context ".nested_resource_class_methods" do
class MainResource < APIResource # rubocop:todo Lint/ConstantDefinitionInBlock
extend Stripe::APIOperations::NestedResource
Expand Down

0 comments on commit 37293f6

Please sign in to comment.