mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-07 00:05:33 -04: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.
48 lines
1.5 KiB
Ruby
48 lines
1.5 KiB
Ruby
# File generated from our OpenAPI spec
|
|
# frozen_string_literal: true
|
|
|
|
module Stripe
|
|
class Source < APIResource
|
|
extend Stripe::APIOperations::Create
|
|
include Stripe::APIOperations::Save
|
|
extend Stripe::APIOperations::NestedResource
|
|
|
|
OBJECT_NAME = "source"
|
|
|
|
custom_method :verify, http_verb: :post
|
|
|
|
nested_resource_class_methods :source_transaction,
|
|
operations: %i[retrieve list]
|
|
|
|
def verify(params = {}, opts = {})
|
|
request_stripe_object(
|
|
method: :post,
|
|
path: resource_url + "/verify",
|
|
params: params,
|
|
opts: opts
|
|
)
|
|
end
|
|
|
|
def detach(params = {}, opts = {})
|
|
if !respond_to?(:customer) || customer.nil? || customer.empty?
|
|
raise NotImplementedError,
|
|
"This source object does not appear to be currently attached " \
|
|
"to a customer object."
|
|
end
|
|
|
|
url = "#{Customer.resource_url}/#{CGI.escape(customer)}/sources" \
|
|
"/#{CGI.escape(id)}"
|
|
resp, opts = execute_resource_request(:delete, url, params, opts)
|
|
initialize_from(resp.data, opts)
|
|
end
|
|
|
|
def source_transactions(params = {}, opts = {})
|
|
resp, opts = execute_resource_request(:get, resource_url + "/source_transactions", params,
|
|
opts)
|
|
Util.convert_to_stripe_object(resp.data, opts)
|
|
end
|
|
extend Gem::Deprecate
|
|
deprecate :source_transactions, :"Source.list_source_transactions", 2020, 1
|
|
end
|
|
end
|