STRING, //html, '@status' => ENUM, // -1 means no account, 0 means blocked, 1 means trading //following arguments are passed if the account exists '@balance' => INTEGER, //in the base unit i.e. minutes '@min' => INTEGER, //in the base unit i.e. minutes '@max' => INTEGER, //in the base unit i.e. minutes '@count' => INTEGER, //number of transactions '@keymatch' => BOOLEAN //whether the stored key is the same as the given one. ); /* * CLIENT REQUEST: http://myserver.com/server/handshake * Method: POST * Data: */ array ( //address of the site admin. Error messages, news, and notification may be sent here. 'api' => 1.0,//not used at present.. 'mail' => STRING, 63, //relative value of the currency against 1 tick. One tick might be 1 minute, and an hour currency would be 60 ticks 'ticks' => FLOAT, //the date of the first trade in the system, in case age of the system is needed for membership criteria 'first_trade', //Number of traders 'traders' => INTEGER, //number of transactions in the last 30 days 'transactions' => INTEGER, //OPTIONAL FIELDS 'divisions' => mixed, //01 means cents OR list of acceptable centilesseparated by pipe| //The root path e.g. domain.org/mytown?q= 'uri' => STRING, 63, //Toggle whether all this data should be visible to the public 'visibility' => BOOLEAN, //The absolute url of the logo of the site (optional) 'logo' => URL, //The latitude of the site 'lat' => FLOAT, //The latitude of the site 'lon' => FLOAT, //random string 'new_key' => VARCHAR, ); /* * RESPONSE * Returns http error code specified below * Or 'OK' */ /* * CLIENT REQUEST: http://myserver.com/transaction/form * typically called before a transaction is attempted, to verify client validity and prep client about its balance limits on the server * ideal for jQuery * Method: GET * Data: */ array( //Last 365 days volume 'volume' => FLOAT, //the largest negative balance - an indicator of deficit spending, a common problem 'deficit' => FLOAT, //Boolean whether the balances add up to zero. Must be TRUE! 'integrity' => 1, //balance of the account designated for intertrading 'balance' => FLOAT, ); /* * RESPONSE * Returns http error code specified below * or on success this array * Data: */ array( //according the limits of the sites account on the intertrading server //suitable for client-side validation //both values are > 0 since they indicate the max value of a transaction in a given direction 'spend_limit' => FLOAT,//in base 'earn_limit' => FLOAT, ); /* * CLIENT REQUEST: http://myserver.com/server/clients * retrieve a list of other member systems, typically for populating a dropdown widget * ideal for jQuery * Method: GET */ /* * RESPONSE * Returns http error code specified below * Data: */ array( 'servername.com' => 'Site Title', 'servername2.com' => 'Site2 Title' ); /* * CLIENT REQUEST: http://myserver.com/transaction/try * (RELAYED to http://client2.com/intertrade) * The request should be repeated every few seconds to prevent a timeout * Method: PUT * Data: */ array( 'payer' => varchar, 'payer_url' => varchar, 'payee' => varchar, 'payee_url' => varchar, 'dest_url' => STRING, //'servername.com', 'src_url' => STRING, //'servername.com', 'quantity' => FLOAT, 'description' => TEXT, //255 'really' => boolean //whether or not to write 'hash' => varchar //hash of the above so the server knows not to try twice ); /* * SERVER RESPONSE && 2nd CLIENT RESPONSE * Returns http error code specified below * return OK or * Not sure about this yet - it could send a separate request later with the response * Data: */ array( 'code' => INTEGER, 'args' => array() ); /* * http error codes * this is an ad hoc extenstion of the http status codes * http://en.wikipedia.org/wiki/List_of_HTTP_status_codes * $args is an array, keyed by the preceding @words * The actual strings below are not definitive 4: "Transaction would exceed limits on server" 5: 'Problem saving transaction on server' 6: 'Unknown account & failed to create a new account on intertrading server' 7: 'Diagnostics from server: @message', $args 8: 'Invalid transaction field: @field: @value', $args //failure to authenticate or validate handshake with server 11: 'Missing config field: @fieldname', $args 12: 'Field @fieldname should be @rel 0: $val', $args 13: 'Field @fieldname contains invalid characters', $args 14: 'Your Intertrading ratio (balance/volume) exceeds @num%: @balance / @volume', $args 15: 'Type error in field @fieldname. Should be a @type.', $args 16: 'Your exchange is not permitted on the intertrading network. 17: 'Wrong key' 18: 'not enough data to authenticate' //failure of remote client 20: "server failed to authenticate with remote client" 24: "Transaction would exceed remote client's account limits" 25: "Misc validation error on remote client: @message", $args); 26: "Server not found: @server", $args); 27: "@message", $args default: return t('Unknown error code: @code', array('@code' => $code)); */