stripe-ruby/lib/stripe/resources/bank_account.rb
Brandur 3433130c5d
Rename API resource's request method (#936)
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.
2020-08-05 16:00:37 -07:00

44 lines
1.5 KiB
Ruby

# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
class BankAccount < APIResource
include Stripe::APIOperations::Delete
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save
OBJECT_NAME = "bank_account"
def verify(params = {}, opts = {})
resp, opts = execute_resource_request(:post, resource_url + "/verify", params, opts)
initialize_from(resp.data, opts)
end
def resource_url
if respond_to?(:customer)
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
elsif respond_to?(:account)
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
end
end
def self.update(_id, _params = nil, _opts = nil)
raise NotImplementedError,
"Bank accounts cannot be updated without a customer ID or an " \
" account ID. Update a bank account using " \
"`Customer.update_source('customer_id', 'bank_account_id', " \
"update_params)` or `Account.update_external_account(" \
"'account_id', 'bank_account_id', update_params)`"
end
def self.retrieve(_id, _opts = nil)
raise NotImplementedError,
"Bank accounts cannot be retrieve without a customer ID or an " \
"account ID. Retrieve a bank account using " \
"`Customer.retrieve_source('customer_id', 'bank_account_id')` " \
"or `Account.retrieve_external_account('account_id', " \
"'bank_account_id')`"
end
end
end