Sha256: 4ca616492cb202f54900a162c6c2b1d6e533ac986341f052af078951ad5dde33

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'open_pay_resource'

class Cards < OpenPayResource


  def list(creation,before,after,offset=0,limit=10)

  end


  def get(card='',customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.get_card(customer_id,card)
    else
      super card
    end
  end


  def create(card,customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.create_card(customer_id,card)
    else
      super card
    end
  end


  def delete(card_id,customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.delete_card(customer_id,card_id)
    else
      super card_id
    end
  end


  def delete_all(customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.delete_all_cards(customer_id)
    else
      each do |card|
        delete(card['id'])
      end
    end
  end


  def each(customer_id=nil)
    if customer_id
      all(customer_id).each do |card|
        yield card
      end
    else
        all.each do |card|
          yield card
        end
    end
  end


  def all(customer_id=nil)
    if customer_id
      customers=@api_hook.create(:customers)
      customers.all_cards(customer_id)
    else
      super   ''
    end
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openpay-1.0.1 lib/OpenPay/Cards.rb
openpay-0.9.8 lib/OpenPay/Cards.rb