/bookkeeping/getAccount.php

This method is used obtain a list of the accounts available in your ledgers.

Parameters

int companyId
The company id of the Uhasibu account required
string login
The login for the API user, logins are typically emails
string password
The password for the API user

Return values

int RESULT_AMOUNT
Contains the amount of result rows in the result set
array RESULT
Array containing the individual result rows
int RESULT : NO
The number of the particular account, this is the item required in many other api's referring to a particular NO.
string RESULT : NAME
This is the full name of the account.
string RESULT : TYPE
This is a textual description of the account type.
int RESULT : BALANCE
This is the current balance of the account, reprecented in the smallest unit of the particular currency.
string RESULT : CURRENCY
This is the currency of the account, represented as an ISO-4217 formated string.
int STATUS_CODE
The status code of the function call, any code different from 0 is an error code
string STATUS_MESSAGE
A textual description of the status code in a few words

Potential error messages

1001: Invalid credentials
Occurs when no user is found within the given companyId using the login and password provided
1002: Missing access rights
Occurs when the user credentials provided does not have access-rights to use the required part of the system.
1003: Account expired
Occurs when the company is expired i.e. due to missing subscription payment.
1006: Requests method not supported
Occurs when the request is neither a POST nor GET HTTP request type

Examples

PHP example
$APIVersion = "20120401";

function uhasibu($method, $package) {
	global $APIVersion;
	$url = "www.uhasibu.co.ke/api/" . $APIVersion . $method;
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($curl, CURLOPT_POST, true);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $package); 
	$response = curl_exec($curl);
	curl_close($curl);
	return json_decode($response, TRUE);
}

$package = 
	"companyId=**COMPANYID**" .
	"&login=" . urlencode("**USERNAME**") .
	"&password=" . urlencode("**PASSWORD**");

$response = uhasibu("/bookkeeping/getAccount.php", $package);
if ($response["STATUS_CODE"] != 0) {
	die($response["STATUS_MESSAGE"]);
}

foreach ($response["RESULT"] AS $account) {
	print "Account NO: " . $account["NO"];
	print "Account Name: " . $account["NAME"];
	print "Account Type: " . $account["TYPE"];
	print "Account Balance: " . $account["BALANCE"]/100 . $account["CURRENCY"];
}