mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-10 00:02:25 -04:00
41 lines
1.2 KiB
Ruby
41 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Stripe
|
|
class Source < APIResource
|
|
extend Stripe::APIOperations::Create
|
|
include Stripe::APIOperations::Save
|
|
|
|
OBJECT_NAME = "source".freeze
|
|
|
|
custom_method :verify, http_verb: :post
|
|
|
|
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 = request(:delete, url, params, opts)
|
|
initialize_from(resp.data, opts)
|
|
end
|
|
|
|
def delete(params = {}, opts = {})
|
|
detach(params, opts)
|
|
end
|
|
extend Gem::Deprecate
|
|
deprecate :delete, "#detach", 2017, 10
|
|
|
|
def source_transactions(params = {}, opts = {})
|
|
resp, opts = request(:get, resource_url + "/source_transactions", params, opts)
|
|
Util.convert_to_stripe_object(resp.data, opts)
|
|
end
|
|
|
|
def verify(params = {}, opts = {})
|
|
resp, opts = request(:post, resource_url + "/verify", params, opts)
|
|
initialize_from(resp.data, opts)
|
|
end
|
|
end
|
|
end
|