Sha256: 485c13b883f96499cc5261792eec2e00f2c548707c12aa75d93eaa134da4f564

Contents?: true

Size: 1.09 KB

Versions: 15

Compression:

Stored size: 1.09 KB

Contents

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

    OBJECT_NAME = 'card'

    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.new("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.new("Cards cannot be retrieved without a customer ID. Retrieve a card using customer.sources.retrieve('card_id')")
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
stripe-3.3.2 lib/stripe/card.rb
stripe-3.3.1 lib/stripe/card.rb
stripe-3.3.0 lib/stripe/card.rb
stripe-3.2.0 lib/stripe/card.rb
stripe-3.1.0 lib/stripe/card.rb
stripe-3.0.3 lib/stripe/card.rb
stripe-3.0.1 lib/stripe/card.rb
stripe-3.0.0 lib/stripe/card.rb
stripe-2.12.0 lib/stripe/card.rb
stripe-2.11.0 lib/stripe/card.rb
stripe-2.10.0 lib/stripe/card.rb
stripe-2.9.0 lib/stripe/card.rb
stripe-2.8.0 lib/stripe/card.rb
stripe-2.7.0 lib/stripe/card.rb
stripe-2.6.0 lib/stripe/card.rb