NAME
  bank_api - provide method to communicate with a bank server

SYNOPSIS
  local bank = require("bank_api")

DESCRIPTION
  This API allow easy communication with the bank server

  Data structure
    cbData : see man libCB

  Method list
    Publicly available methods :
      getCredit(cbData) -> status:int,balance:int
        Return the balance of the account
      makeTransaction(targetAccount,cbData,amount) -> status:int
        cbData's account will pay targetAccount amount

    Trusted client methods :
      This methods required a secret delivered by the server to be provided in the config
      createAccount() -> status:int, accountUUID:sting
        Return the newly create account's uuid
      requestNewCBdata(accountUUID [,cbUUID])-> status:int,string:rawCBdata
        Without cbUUID, the srv will assume it is a magcard from open security and need less data.
      editAccount(cbData,amount):int
        Add amount to the account. If amount is < 0 It will be removed form the account
        A account cant have a negative balance.

    setModemTimeout(t)

  Status codes
    0 = OK
    1 = NO_ACCOUNT
    2 = ERROR_ACCOUNT
    3 = ERROR_CB
    4 = ERROR_AMOUNT
    5 = ERROR_RECEIVING_ACCOUNT
    -1 = timeout
    -2 = wrong message

CONFIGURATION
  The configuration is parsed with serialization.unserialize. Only the secret field may be empty (not nil).
    secret:string -> secret delivered by the server to authenticated trusted clients
    timeout:int -> how long to wait for the server to answer before giving up with a timeout (-1) status
    bank_addr:string -> the server network card address
  This file can be generated with the program `generateClientAPIconfig.lua` on the server. To use it you will need to switch the server network card with the clients one during the configuration file creation. The program will prompt you to do it.


FILES
  /usr/lib/bank_api.lua
    the library
  /etc/bank/api/conf.conf
    the config file location

SEE ALSO
  libCB

AUTHOR
  AR2000
