Sha256: 4753ae23de011ca58ee699c27150cae8d82d7b382c6a1245cf0765687c783233

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 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, Util.normalize_opts(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, Util.normalize_opts(opts))
      Util.convert_to_stripe_object(resp.data, opts)
    end

    def verify(params = {}, opts = {})
      resp, opts = request(:post, resource_url + "/verify", params, Util.normalize_opts(opts))
      initialize_from(resp.data, opts)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stripe-4.16.0 lib/stripe/source.rb
stripe-4.15.0 lib/stripe/source.rb
stripe-4.14.0 lib/stripe/source.rb
stripe-4.13.0 lib/stripe/source.rb
stripe-4.12.0 lib/stripe/source.rb