Sha256: 90ca5c9c716b7dd5aa1d36781e0bafc9c95f4543aedf85dbb400c4f2b320eeb9

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stripe-4.18.1 lib/stripe/source.rb