Android SDK Samples - Currencies Operations

Get Currencies
          
          
//$companyinfo object is of ZCRMCompanyInfo

//call getCurrencies() using $companyinfo object

$companyinfo.getCurrencies(object: DataCallback<BulkAPIResponse, List<ZCRMCurrency>>
    {
        override fun completed(response: BulkAPIResponse,currencies: List<ZCRMCurrency>)
       {
           println("${response.responseJSON}")
       }
    
        override fun failed(exception: ZCRMException) 
       {
           println("Throws Exception : $exception")
       }
    
    })
 
Get Currencies from the Server
          
          
//$companyinfo object is of ZCRMCompanyInfo

//call getCurrenciesFromServer() using $companyinfo object

$companyinfo.getCurrenciesFromServer(object: DataCallback<BulkAPIResponse, List<ZCRMCurrency>>
    {
        override fun completed(response: BulkAPIResponse,currencies: List<ZCRMCurrency>)
       {
           println("${response.responseJSON}")
       }
    
        override fun failed(exception: ZCRMException) 
       {
           println("Throws Exception : $exception")
       }
    
    })
 
Get a Currency by its ID
          
          
//$companyinfo object is of ZCRMCompanyInfo

//call getCurrency() using $companyinfo object by passing the id of the currency as a parameter

$companyinfo.getCurrency(415xxx003, object : DataCallback<APIResponse, ZCRMCurrency>
    {
       override fun completed(response: APIResponse, zcrmentity: ZCRMCurrency) {
           println("${response.responseJSON}")
       }
    
       override fun failed(exception: ZCRMException) {
           println("Throws Exception : $exception")
       }
    
    })
    
 
Get a Currency by its ID from the Server
          
          
//$companyinfo object is of ZCRMCompanyInfo

//call getCurrencyFromServer() using $companyinfo object by passing the id of the currency as a parameter

$companyinfo.getCurrencyFromServer(415xxx003, object : DataCallback<APIResponse, ZCRMCurrency>
    {
       override fun completed(response: APIResponse, zcrmentity: ZCRMCurrency) {
           println("${response.responseJSON}")
       }
    
       override fun failed(exception: ZCRMException) {
           println("Throws Exception : $exception")
       }
    
    })
 
Enable Multi-currency
          
          
//$companyinfo object is of ZCRMCompanyInfo

//call newCurrency() using $companyinfo object by passing the symbol, name and isoCode.

//symbol - Symbol of the currency.

//name - Name of the currency.

//isoCode - ISO code of the currency.

val currency = $companyinfo.newCurrency("Af", "Algerian Dinar - DZD", "DZD",1.0000000, ZCRMCurrency.Format("Period","Comma", 2))

//call enableMultiCurrency() using $companyinfo object by passing the defined base currency as a parameter to it.

$companyinfo.enableMultiCurrency(currency, object : ResponseCallback<APIResponse>
{
   override fun completed(response: APIResponse)
   {
       println("${response.responseJSON}")
   }

   override fun failed(exception: ZCRMException)
   {
       println("Throws Exception : $exception")
   }

})
 
Add a List of Currencies
          
          
//$companyinfo object is of ZCRMCompanyInfo

//define the currencies 

//call newCurrency() using $companyinfo object by passing the symbol, name and isoCode.

//symbol - Symbol of the currency.

//name - Name of the currency.

//isoCode - ISO code of the currency.

val currency1 = $companyinfo.newCurrency("$", "US Dollar - USD", "USD",3.000000000, ZCRMCurrency.Format("Period","Comma", 2))

val currency2 = $companyinfo.newCurrency("SR","Saudi Riyal - SAR","SAR", 1.0000000,ZCRMCurrency.Format("Period","Comma",2))

//add the currencies to currenciesList
val currenciesList = listOf<ZCRMCurrency>(currency1,currency2)

//call createCurrencies() using $companyinfo object by passing the currenciesList as a parameter to it

$companyinfo.createCurrencies(currenciesList,object:DataCallback<BulkAPIResponse,List<ZCRMCurrency>>
{
    override fun completed(response: BulkAPIResponse,zcrmentity: List<ZCRMCurrency>) {
       println("${response.responseJSON}")
   }

    override fun failed(exception: ZCRMException) {
      println("Throws Exception : $exception")
   }

})
 
Update Currencies
          
          
val currenciesList = listOf<ZCRMCurrency>()

//$currency1 and $currency2 objects are of ZCRMCurrency

$currency1.exchangeRate = 3.000000000 //updating the currency's exchange rate
currenciesList.add($currency1) //add currency1 to currenciesList

$currency2.exchangeRate = 1.000000000 //updating the currency's exchange rate
currenciesList.add($currency2) //add currency2 to currenciesList

//$companyinfo object is of ZCRMCompanyInfo

//call updateCurrencies() using $companyinfo object by passing the currenciesList as a parameter to it

$companyinfo.updateCurrencies(currenciesList,object:ResponseCallback<BulkAPIResponse>
{
   override fun completed(response: BulkAPIResponse) {
       println("${response.responseJSON}")
   }

   override fun failed(exception: ZCRMException) {
       println("Throws Exception: $exception")
   }

})