Sha256: 01c476e3be55b3f30b59b206388f344c09806c46751fd483ef2be09a942799b2

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 KB

Contents

module Stripe
  class Card < APIResource
    include Stripe::APIOperations::Save
    include Stripe::APIOperations::Delete
    extend Stripe::APIOperations::List

    OBJECT_NAME = "card".freeze

    def resource_url
      if respond_to?(:recipient) && !recipient.nil? && !recipient.empty?
        "#{Recipient.resource_url}/#{CGI.escape(recipient)}/cards/#{CGI.escape(id)}"
      elsif respond_to?(:customer) && !customer.nil? && !customer.empty?
        "#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
      elsif respond_to?(:account) && !account.nil? && !account.empty?
        "#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
      end
    end

    def self.update(_id, _params = nil, _opts = nil)
      raise NotImplementedError, "Cards cannot be updated without a customer ID. Update a card using `c = customer.sources.retrieve('card_id'); c.save`"
    end

    def self.retrieve(_id, _opts = nil)
      raise NotImplementedError, "Cards cannot be retrieved without a customer ID. Retrieve a card using customer.sources.retrieve('card_id')"
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
stripe-3.14.0 lib/stripe/card.rb
stripe-3.13.1 lib/stripe/card.rb
stripe-3.13.0 lib/stripe/card.rb
stripe-3.12.1 lib/stripe/card.rb
stripe-3.12.0 lib/stripe/card.rb
stripe-3.11.0 lib/stripe/card.rb
stripe-3.10.0 lib/stripe/card.rb
stripe-3.9.2 lib/stripe/card.rb
stripe-3.9.1 lib/stripe/card.rb
stripe-3.9.0 lib/stripe/card.rb
stripe-3.8.2 lib/stripe/card.rb
stripe-3.8.1 lib/stripe/card.rb
stripe-3.8.0 lib/stripe/card.rb
stripe-3.7.0 lib/stripe/card.rb
stripe-3.6.0 lib/stripe/card.rb
stripe-3.5.3 lib/stripe/card.rb
stripe-3.5.2 lib/stripe/card.rb
stripe-3.5.1 lib/stripe/card.rb
stripe-3.5.0 lib/stripe/card.rb
stripe-3.4.1 lib/stripe/card.rb