Class: Cards

Inherits:
Object
  • Object
show all
Defined in:
lib/Cards.rb

Defined Under Namespace

Classes: Card

Class Method Summary collapse

Class Method Details

.create(options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/Cards.rb', line 29

def Cards.create(options={})
  if (options.length == 0)
    raise InvalidArguementError.new()
  end

  method = 'POST'
  url = '/card/add'
  response = request(method,url,options)
  card = Card.new(response.body)
  return card
end

.delete(options = {}) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/Cards.rb', line 60

def Cards.delete(options={})
  card_token = get_arg(options,:card_token)
  if card_token == NIL
    raise InvalidArguementError.new("ERROR: `card_token` is a required parameter for Card.delete().")
  end

  method = 'POST'
  url = '/card/delete'
  response = request(method,url,options)
  card = Card.new(response.body)
  return card
end

.list(options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/Cards.rb', line 41

def Cards.list(options={})
  customer_id = get_arg(options,:customer_id)
  if customer_id == NIL
    raise InvalidArguementError.new("ERROR: `customer_id` is a required parameter for Cards.list().")
  end

  method = 'GET'
  url = '/card/list'
  response = Array(request(method,url,options).body['cards'])
  cards = []
  i=0
  while i != response.count
    card = Card.new(response[i])
    cards.push(card)
    i+=1
  end
  return cards
end