mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-11-29 00:01:18 -05:00
As seen in #928, the `refresh` method doesn't work for an event class. This is because event has a field called `request`, and it ends up replacing the `request` method that it inherited from being an API resource, so when `refresh` tries to make a request, it fails because it tries to invoke it on the accessor added for the event's property. Here we give `request` a much more unique name so that it will never conflict with a property field again, and update all internal references to use the new name. We use `alias` to make the old name available for backwards compatibility reasons because its been around for so long that people are probably calling it. Fixes #928.
40 lines
1.3 KiB
Ruby
40 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Stripe
|
|
module APIOperations
|
|
module Delete
|
|
module ClassMethods
|
|
# Deletes an API resource
|
|
#
|
|
# Deletes the identified resource with the passed in parameters.
|
|
#
|
|
# ==== Attributes
|
|
#
|
|
# * +id+ - ID of the resource to delete.
|
|
# * +params+ - A hash of parameters to pass to the API
|
|
# * +opts+ - A Hash of additional options (separate from the params /
|
|
# object values) to be added to the request. E.g. to allow for an
|
|
# idempotency_key to be passed in the request headers, or for the
|
|
# api_key to be overwritten. See
|
|
# {APIOperations::Request.execute_resource_request}.
|
|
def delete(id, params = {}, opts = {})
|
|
resp, opts = execute_resource_request(:delete,
|
|
"#{resource_url}/#{id}",
|
|
params, opts)
|
|
Util.convert_to_stripe_object(resp.data, opts)
|
|
end
|
|
end
|
|
|
|
def delete(params = {}, opts = {})
|
|
resp, opts = execute_resource_request(:delete, resource_url,
|
|
params, opts)
|
|
initialize_from(resp.data, opts)
|
|
end
|
|
|
|
def self.included(base)
|
|
base.extend(ClassMethods)
|
|
end
|
|
end
|
|
end
|
|
end
|