Class: Wallets

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

Defined Under Namespace

Classes: Wallet

Class Method Summary collapse

Class Method Details

.create(options = {}) ⇒ Object



21
22
23
# File 'lib/Wallets.rb', line 21

def Wallets.create(options={})
  raise "ERROR: Not Implemented"
end

.delete(options = {}) ⇒ Object



71
72
73
# File 'lib/Wallets.rb', line 71

def Wallets.delete(options={})
  raise "ERROR: Not Implemented"
end

.list(options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/Wallets.rb', line 25

def Wallets.list(options={})
  order = get_arg(options, :order_id)
  customer = get_arg(options, :customer_id)

  if customer == NIL and order == NIL
    raise InvalidArguementError.new("ERROR: `customer_id` or `order_id` is required parameter for Wallets.list()")
  end

  if customer
    url = "/customers/#{customer}/wallets"
  else
    url = "/orders/#{order}/wallets"
  end

  method = 'GET'
  response = Array(request(method,url,{}).body['list'])
  wallets = []
  i=0
  while i != response.count
    wallet = Wallet.new(response[i])
    wallets.push(wallet)
    i+=1
  end
  return wallets
end

.refresh_balance(options = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/Wallets.rb', line 51

def Wallets.refresh_balance(options={})
  customer = get_arg(options, :customer_id)

  if customer == NIL
    raise InvalidArguementError.new("ERROR: `customer_id` is required parameter for Wallets.refresh_balance()")
  end

  url = "/customers/#{customer}/wallets/refresh-balances"
  method = 'GET'
  response = Array(request(method,url,{}).body['list'])
  wallets = []
  i=0
  while i != response.count
    wallet = Wallet.new(response[i])
    wallets.push(wallet)
    i+=1
  end
  return wallets
end