class Wallets

Public Class Methods

authenticate(options={}) click to toggle source
# File lib/Wallets.rb, line 126
def Wallets.authenticate(options={})
  wallet_id = get_arg(options, :wallet_id)

  if wallet_id == NIL or wallet_id == ''
    raise InvalidArguementError.new("ERROR: `wallet_id` is required parameter for Wallets.authenticate()")
  end

  url = "/wallets/#{wallet_id}"

  method = 'POST'
  parameters = {
      :command => 'authenticate'
  }
  response = request(method,url,parameters)
  wallet = Wallet.new(response.body)
  return wallet
end
create(options={}) click to toggle source
# File lib/Wallets.rb, line 22
def Wallets.create(options={})
  customer_id = get_arg(options, :customer_id)
  gateway = get_arg(options, :gateway)

  if customer_id == NIL or customer_id == '' or gateway == NIL or gateway == ''
    raise InvalidArguementError.new("ERROR: `customer_id` and `gateway` are required parameters for Wallets.create()")
  end

  url = "/customers/#{customer_id}/wallets"

  method = 'POST'
  parameters = {
      :gateway => gateway
  }
  response = request(method,url,parameters)
  wallet = Wallet.new(response.body)
  return wallet
end
create_and_authenticate(options={}) click to toggle source
# File lib/Wallets.rb, line 41
def Wallets.create_and_authenticate(options={})
  customer_id = get_arg(options, :customer_id)
  gateway = get_arg(options, :gateway)

  if customer_id == NIL or customer_id == '' or gateway == NIL or gateway == ''
    raise InvalidArguementError.new("ERROR: `customer_id` and `gateway` are required parameters for Wallets.create_and_authenticate()")
  end

  url = "/customers/#{customer_id}/wallets"

  method = 'POST'
  parameters = {
      :command => 'authenticate',
      :gateway => gateway
  }
  response = request(method,url,parameters)
  wallet = Wallet.new(response.body)
  return wallet
end
list(options={}) click to toggle source
# File lib/Wallets.rb, line 61
def Wallets.list(options={})
  order_id = get_arg(options, :order_id)
  customer_id = get_arg(options, :customer_id)

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

  if customer_id
    url = "/customers/#{customer_id}/wallets"
  else
    url = "/orders/#{order_id}/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={}) click to toggle source
# File lib/Wallets.rb, line 87
def Wallets.refresh_balance(options={})
  customer_id = get_arg(options, :customer_id)

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

  url = "/customers/#{customer_id}/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
refresh_by_wallet_id(options={}) click to toggle source
# File lib/Wallets.rb, line 107
def Wallets.refresh_by_wallet_id(options={})
  wallet_id = get_arg(options, :wallet_id)

  if wallet_id == NIL or wallet_id == ''
    raise InvalidArguementError.new("ERROR: `wallet_id` is required parameter for Wallets.refresh_by_wallet_id()")
  end

  url = "/wallets/#{wallet_id}"

  method = 'GET'
  parameters = {
      :command => 'refresh'
  }
  response = request(method,url,parameters)
  wallet = Wallet.new(response.body)
  return wallet
end