mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-12-07 00:00:35 -05:00
58 lines
1.7 KiB
Ruby
58 lines
1.7 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"
|
|
|
|
nested_resource_class_methods :source_transaction,
|
|
operations: %i[retrieve list]
|
|
|
|
def verify(params = {}, opts = {})
|
|
request_stripe_object(
|
|
method: :post,
|
|
path: format("/v1/sources/%<source>s/verify", { source: CGI.escape(self["id"]) }),
|
|
params: params,
|
|
opts: opts
|
|
)
|
|
end
|
|
|
|
def self.verify(source, params = {}, opts = {})
|
|
request_stripe_object(
|
|
method: :post,
|
|
path: format("/v1/sources/%<source>s/verify", { source: CGI.escape(source) }),
|
|
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 = {})
|
|
request_stripe_object(
|
|
method: :get,
|
|
path: resource_url + "/source_transactions",
|
|
params: params,
|
|
opts: opts
|
|
)
|
|
end
|
|
extend Gem::Deprecate
|
|
deprecate :source_transactions, :"Source.list_source_transactions", 2020, 1
|
|
end
|
|
end
|