/bookkeeping/getCurrency.php

This method is used obtain a list of currencies currently available in the system.

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 : ID
The id of the particular invoice, this is the item required in many other api's referring to a particular ID.
string RESULT : SYMBOL
This is the ISO-4217 formated representation of the currency
string RESULT : NAME
This is the full name of the currency.
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/getCurrency.php", $package);
if ($response["STATUS_CODE"] != 0) {
	die($response["STATUS_MESSAGE"]);
}

foreach ($response["RESULT"] AS $currency) {
	print "Currency ID: " . $currency["ID"];
	print "Currency Symbol: " . $currency["SYMBOL"];
	print "Currency Name: " . $currency["NAME"];
}
C# example
using System;
using System.Collections.Generic;
using System.Net.Http;

using Newtonsoft.Json; // Download Newtonsoft via NuGet
using Newtonsoft.Json.Linq;

var apiVersion = "20120401";
var apiFunction = "/bookkeeping/getCurrency.php";
var serviceUri = new Uri(string.Format("https://www.uhasibu.co.ke/api/", apiVersion, apiFunction));

HttpClient client = new HttpClient();
HttpContent content = new FormUrlEncodedContent(new[] {
  new KeyValuePair("companyId", "**COMPANYID**"),
  new KeyValuePair("login", "**USERNAME**"),
  new KeyValuePair("password", "**PASSWORD**")
});

var response = client.PostAsync(serviceUri, content).Result;
																										
if (response != null && response.IsSuccessStatusCode && response.Content != null)
{
  var responseData = response.Content.ReadAsStringAsync().Result;
  if (responseData != null)
  {
    var responseDataObject = JsonConvert.DeserializeObject(responseData);
    JToken statusCode;
    JToken result;

    if (responseDataObject != null &&
        responseDataObject.TryGetValue("STATUS_CODE", out statusCode) &&
        JToken.DeepEquals(statusCode, "0") &&
        responseDataObject.TryGetValue("RESULT", out result) &&
        result != null)
    {
      foreach (var currency in result.Children())
      {
        JToken currencyID;
        JToken currencyName;
        JToken currencySymbol;
								
        if (currency.TryGetValue("ID", out currencyID) &&
            currency.TryGetValue("SYMBOL", out currencySymbol) &&
            currency.TryGetValue("NAME", out currencyName))
        {
          Console.WriteLine("ID: , SYMBOL: , NAME: ", currencyID, currencySymbol, currencyName);
        }
      }
    }
  }
}