Sha256: d09e4b103fc89382bfbb248ae1f6989231a54e173a7ecfacc906397352dd9b05

Contents?: true

Size: 1.45 KB

Versions: 28

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

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

    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,
            "Card cannot be updated without a customer ID or an account ID. " \
            "Update a card using `Customer.update_source('customer_id', " \
            "'card_id', update_params)` or `Account.update_external_account(" \
            "'account_id', 'card_id', update_params)`"
    end

    def self.retrieve(_id, _opts = nil)
      raise NotImplementedError,
            "Card cannot be retrieved without a customer ID or an account " \
            "ID. Retrieve a card using `Customer.retrieve_source(" \
            "'customer_id', 'card_id')` or " \
            "`Account.retrieve_external_account('account_id', 'card_id')`"
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
stripe-5.22.0 lib/stripe/resources/card.rb
stripe-5.21.0 lib/stripe/resources/card.rb
stripe-5.20.0 lib/stripe/resources/card.rb
stripe-5.19.0 lib/stripe/resources/card.rb
stripe-5.18.0 lib/stripe/resources/card.rb
stripe-5.17.0 lib/stripe/resources/card.rb
stripe-5.16.0 lib/stripe/resources/card.rb
stripe-5.15.0 lib/stripe/resources/card.rb
stripe-5.14.0 lib/stripe/resources/card.rb
stripe-5.13.0 lib/stripe/resources/card.rb
stripe-5.12.1 lib/stripe/resources/card.rb
stripe-5.12.0 lib/stripe/resources/card.rb
stripe-5.11.0 lib/stripe/resources/card.rb
stripe-5.10.0 lib/stripe/resources/card.rb
stripe-5.9.0 lib/stripe/resources/card.rb
stripe-5.8.0 lib/stripe/resources/card.rb
stripe-5.7.1 lib/stripe/resources/card.rb
stripe-5.7.0 lib/stripe/resources/card.rb
stripe-5.6.0 lib/stripe/resources/card.rb
stripe-5.5.0 lib/stripe/resources/card.rb