Sha256: 97cba67c9b616abcc77baca2782a44ebf183fb9202a3cef9362f864f3726d641

Contents?: true

Size: 1.2 KB

Versions: 39

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Stripe
  class Source < APIResource
    extend Stripe::APIOperations::Create
    include Stripe::APIOperations::Save

    OBJECT_NAME = "source".freeze

    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

39 entries across 39 versions & 1 rubygems

Version Path
stripe-4.11.0 lib/stripe/source.rb
stripe-4.10.0 lib/stripe/source.rb
stripe-4.9.1 lib/stripe/source.rb
stripe-4.9.0 lib/stripe/source.rb
stripe-4.8.1 lib/stripe/source.rb
stripe-4.8.0 lib/stripe/source.rb
stripe-4.7.1 lib/stripe/source.rb
stripe-4.7.0 lib/stripe/source.rb
stripe-4.6.0 lib/stripe/source.rb
stripe-4.5.0 lib/stripe/source.rb
stripe-4.4.1 lib/stripe/source.rb
stripe-4.4.0 lib/stripe/source.rb
stripe-4.3.0 lib/stripe/source.rb
stripe-4.2.0 lib/stripe/source.rb
stripe-4.1.0 lib/stripe/source.rb
stripe-4.0.3 lib/stripe/source.rb
stripe-4.0.2 lib/stripe/source.rb
stripe-4.0.1 lib/stripe/source.rb
stripe-4.0.0 lib/stripe/source.rb
stripe-3.31.1 lib/stripe/source.rb