Copiedcurl "https://www.zohoapis.com/crm/v2.1/org/currencies/actions/enable"
-X POST
-d "input.json"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied
CurrenciesOperations currenciesOperations = new CurrenciesOperations();
BaseCurrencyWrapper bodyWrapper = new BaseCurrencyWrapper();
com.zoho.crm.api.currencies.Currency currency = new com.zoho.crm.api.currencies.Currency();
currency.setPrefixSymbol(true);
currency.setName("Algerian Dinar-ADN");
currency.setIsoCode("DZD");
currency.setSymbol("DA");
currency.setExchangeRate("1.0000000");
currency.setIsActive(true);
Format format = new Format();
format.setDecimalSeparator(new Choice < String > ("Period"));
format.setThousandSeparator(new Choice < String > ("Comma"));
format.setDecimalPlaces(new Choice < String > ("2"));
currency.setFormat(format);
bodyWrapper.setBaseCurrency(currency);
APIResponse < BaseCurrencyActionHandler > response = currenciesOperations.enableMultipleCurrencies(bodyWrapper);
Copiedpackage com.zoho.crm.api.sample.restapi.currencies;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
public class MultipleCurrenciesinOrganization
{
@SuppressWarnings("deprecation")
public static void main(String[] args)
{
try
{
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
SSLContext sslContext = SSLContext.getDefault();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();
URIBuilder uriBuilder = new URIBuilder("https://www.zohoapis.com/crm/v2.1/org/currencies/actions/enable");
HttpUriRequest requestObj = new HttpPost(uriBuilder.build());
HttpEntityEnclosingRequestBase requestBase = (HttpEntityEnclosingRequestBase) requestObj;
JSONObject requestBody = new JSONObject();
JSONObject recordObject = new JSONObject();
JSONObject formatObject = new JSONObject();
formatObject.put("decimal_separator", "Period");
formatObject.put("thousand_separator", "Comma");
formatObject.put("decimal_places", "2");
recordObject.put("format", formatObject);
recordObject.put("prefix_symbol", true);
recordObject.put("name", "Algerian Dinar-ADN");
recordObject.put("iso_code", "DZD");
recordObject.put("symbol", "DA");
recordObject.put("exchange_rate", "1.00");
requestBody.put("base_currency", recordObject);
requestBase.setEntity(new StringEntity(requestBody.toString(), HTTP.UTF_8));
requestObj.addHeader("Authorization", "Zoho-oauthtoken 1000.xxxxxxx.xxxxxxx");
HttpResponse response = httpclient.execute(requestObj);
HttpEntity responseEntity = response.getEntity();
System.out.println("HTTP Status Code : " + response.getStatusLine().getStatusCode());
if(responseEntity != null)
{
Object responseObject = EntityUtils.toString(responseEntity);
String responseString = responseObject.toString();
System.out.println(responseString);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
Copied
$currenciesOperations = new CurrenciesOperations();
$bodyWrapper = new BaseCurrencyWrapper();
$currencyClass = "com\zoho\crm\api\currencies\Currency";
$currency = new $currencyClass();
$currency->setPrefixSymbol(true);
$currency->setName("Angolan Kwanza - AOA");
$currency->setIsoCode("AOA");
$currency->setSymbol("Kz");
$currency->setExchangeRate("1.00");
$currency->setIsActive(true);
$format = new Format();
$format->setDecimalSeparator(new Choice("Period"));
$format->setThousandSeparator(new Choice("Comma"));
$format->setDecimalPlaces(new Choice("2"));
$currency->setFormat($format);
$bodyWrapper->setBaseCurrency($currency);
$response = $currenciesOperations->enableMultipleCurrencies($bodyWrapper);
Copied<?php
class MultipleCurrenciesinOrganization{
public function execute(){
$curl_pointer = curl_init();
$curl_options = array();
$url = "https://www.zohoapis.com/crm/v2.1/org/currencies/actions/enable";
$curl_options[CURLOPT_URL] =$url;
$curl_options[CURLOPT_RETURNTRANSFER] = true;
$curl_options[CURLOPT_HEADER] = 1;
$curl_options[CURLOPT_CUSTOMREQUEST] = "POST";
$requestBody = array();
$recordObject = array();
$formatObject = array();
$formatObject["decimal_separator"]="Period";
$formatObject["thousand_separator"]="Comma";
$formatObject["decimal_places"]="2";
$recordObject["format"]=$formatObject;
$recordObject["prefix_symbol"]=true;
$recordObject["name"]="Algerian Dinar-ADN";
$recordObject["iso_code"]="DZD";
$recordObject["symbol"]="DA";
$recordObject["exchange_rate"]="1.00000";
$requestBody["base_currency"] =$recordObject;
$curl_options[CURLOPT_POSTFIELDS]= json_encode($requestBody);
$headersArray = array();
$headersArray[] = "Authorization". ":" . "Zoho-oauthtoken " . "1000.30f3a589XXXXXXXXXXXXXXXXXXX4077.dc5XXXXXXXXXXXXXXXXXXXee9e7c171c";
$curl_options[CURLOPT_HTTPHEADER]=$headersArray;
curl_setopt_array($curl_pointer, $curl_options);
$result = curl_exec($curl_pointer);
$responseInfo = curl_getinfo($curl_pointer);
curl_close($curl_pointer);
list ($headers, $content) = explode("\r\n\r\n", $result, 2);
if(strpos($headers," 100 Continue")!==false){
list( $headers, $content) = explode( "\r\n\r\n", $content , 2);
}
$headerArray = (explode("\r\n", $headers, 50));
$headerMap = array();
foreach ($headerArray as $key) {
if (strpos($key, ":") != false) {
$firstHalf = substr($key, 0, strpos($key, ":"));
$secondHalf = substr($key, strpos($key, ":") + 1);
$headerMap[$firstHalf] = trim($secondHalf);
}
}
$jsonResponse = json_decode($content, true);
if ($jsonResponse == null && $responseInfo['http_code'] != 204) {
list ($headers, $content) = explode("\r\n\r\n", $content, 2);
$jsonResponse = json_decode($content, true);
}
var_dump($headerMap);
var_dump($jsonResponse);
var_dump($responseInfo['http_code']);
}
}
(new MultipleCurrenciesinOrganization())->execute();
Copied
CurrenciesOperations currenciesOperations = new CurrenciesOperations();
BaseCurrencyWrapper bodyWrapper = new BaseCurrencyWrapper();
Com.Zoho.Crm.API.Currencies.Currency currency = new Com.Zoho.Crm.API.Currencies.Currency();
currency.Name = "Algerian Dinar-ADN";
currency.IsoCode = "DZD";
currency.Symbol = "DA";
currency.ExchangeRate = "1.0000000";
currency.IsActive = true;
Format format = new Format();
format.DecimalSeparator = new Choice<string>("Period");
format.ThousandSeparator = new Choice<string>("Comma");
format.DecimalPlaces = new Choice<string>("2");
bodyWrapper.BaseCurrency = currency;
APIResponse<BaseCurrencyActionHandler> response = currenciesOperations.EnableMultipleCurrencies(bodyWrapper);
Copiedusing System;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
namespace Com.Zoho.Crm.API.Sample.RestAPI.Currencies
{
public class EnableMultiCurrency
{
public static void MultipleCurrenciesinOrganization()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.zohoapis.com/crm/v2.1/org/currencies/actions/enable");
request.Method = "POST";
request.Headers["Authorization"] = "Zoho-oauthtoken 1000.abfeXXXXXXXXXXX2asw.XXXXXXXXXXXXXXXXXXsdc2";
JObject requestBody = new JObject();
JObject recordObject = new JObject();
JObject formatObject = new JObject();
formatObject.Add("decimal_separator", "Period");
formatObject.Add("thousand_separator", "Comma");
formatObject.Add("decimal_places", "2");
recordObject.Add("format", formatObject);
recordObject.Add("prefix_symbol", true);
recordObject.Add("name", "Algerian Dinar-ADN");
recordObject.Add("iso_code", "DZD");
recordObject.Add("symbol", "DA");
recordObject.Add("exchange_rate", "1.0000000");
requestBody.Add("base_currency", recordObject);
string dataString = requestBody.ToString();
var data = Encoding.UTF8.GetBytes(dataString);
int dataLength = data.Length;
request.ContentLength = dataLength;
using (var writer = request.GetRequestStream())
{
writer.Write(data, 0, dataLength);
}
request.KeepAlive = true;
HttpWebResponse response;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
if (e.Response == null) { throw; }
response = (HttpWebResponse)e.Response;
}
HttpWebResponse responseEntity = response;
Console.WriteLine("HTTP Status Code : " + (int)response.StatusCode);
string responsestring = new StreamReader(responseEntity.GetResponseStream()).ReadToEnd();
responseEntity.Close();
Console.WriteLine(responsestring);
}
}
}
Copied
currencies_operations = CurrenciesOperations()
request = BaseCurrencyWrapper()
currency = ZCRMCurrency()
currency.set_prefix_symbol(True)
currency.set_name("Algerian Dinar-ADN")
currency.set_iso_code("DZD")
currency.set_symbol("DA")
currency.set_exchange_rate("1.000000000")
currency.set_is_active(True)
format = Format()
format.set_decimal_separator(Choice('Period'))
format.set_thousand_separator(Choice('Comma'))
format.set_decimal_places(Choice('2'))
currency.set_format(format)
request.set_base_currency(currency)
response = currencies_operations.enable_multiple_currencies(request)
Copieddef enable_multi_currency():
import requests
import json
url = 'https://www.zohoapis.com/crm/v2.1/org/currencies/actions/enable'
headers = {
'Authorization': 'Zoho-oauthtoken 1000.1fc2da2144ba0f8931261a0a78e51a4e.7d2b34de8647be16a27b68c71cfa04dd'
}
request_body = dict()
record_object = dict()
format_object = dict()
format_object['decimal_separator'] = 'Period'
format_object['thousand_separator'] = 'Comma'
format_object['decimal_places'] = '2'
record_object['format'] = format_object
record_object['prefix_symbol'] = True
record_object['name'] = 'Indian Rupee-INR'
record_object['iso_code'] = 'INR'
record_object['symbol'] = 'Rs'
record_object['exchange_rate'] = '1.0000000'
record_object['is_active'] = True
request_body['base_currency'] = record_object
response = requests.post(url=url, headers=headers, data=json.dumps(request_body).encode('utf-8'))
if response is not None:
print("HTTP Status Code : " + str(response.status_code))
print(response.json())
enable_multi_currency()
Copied//Get instance of CurrenciesOperations Class
let currenciesOperations = new CurrenciesOperations();
//Get instance of BaseCurrencyWrapper Class that will contain the request body
let request = new BaseCurrencyWrapper();
//Get instance of Currency Class
let currency = new Currency();
//To set the position of the ISO code in the base currency.
//true: Display ISO code before the currency value.
//false: Display ISO code after the currency value.
currency.setPrefixSymbol(true);
//To set the name of the base currency.
currency.setName("Algerian Dinar-ADN");
//To set the ISO code of the base currency.
currency.setIsoCode("DZD");
//To set the symbol of the base currency.
currency.setSymbol("DA");
//To set the rate at which the currency has to be exchanged for home base currency.
currency.setExchangeRate("1.0000000");
//To set the status of the base currency.
//true: The currency is active.
//false: The currency is inactive.
currency.setIsActive(true);
let format = new Format();
//It can be a Period or Comma, depending on the base currency.
format.setDecimalSeparator(new Choice("Period"));
//It can be a Period, Comma, or Space, depending on the base currency.
format.setThousandSeparator(new Choice("Comma"));
//To set the number of decimal places allowed for the base currency. It can be 0, 2, or 3.
format.setDecimalPlaces(new Choice("2"));
//To set the format of the base currency
currency.setFormat(format);
//Set the Currency in BodyWrapper instance
request.setBaseCurrency(currency);
//Call enableMultipleCurrencies method that takes BodyWrapper instance as parameter
let response = await currenciesOperations.enableMultipleCurrencies(request);
Copiedasync function enableMultiCurrency() {
const got = require("got");
let url = 'https://www.zohoapis.com/crm/v2.1/org/currencies/actions/enable'
let headers = {
Authorization : "Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
}
let requestBody = {}
let recordObject = {}
let formatObject = {}
formatObject['decimal_separator'] = 'Period'
formatObject['thousand_separator'] = 'Comma'
formatObject['decimal_places'] = '2'
recordObject['format'] = formatObject
recordObject['prefix_symbol'] = true
recordObject['name'] = 'Indian Rupee-INR'
recordObject['iso_code'] = 'INR'
recordObject['symbol'] = 'Rs'
recordObject['exchange_rate'] = '1.0000000'
recordObject['is_active'] = true
requestBody['base_currency'] = recordObject
let requestDetails = {
method : "POST",
headers : headers,
body : JSON.stringify(requestBody),
encoding: "utf8",
throwHttpErrors : false
};
let response = await got(url, requestDetails)
if(response != null) {
console.log(response.statusCode);
console.log(response.body);
}
}
enableMultiCurrency()
Copied
co = Currencies::CurrenciesOperations.new
bcw = Currencies::BaseCurrencyWrapper.new
currency = Currencies::Currency.new
currency.prefix_symbol = true
currency.name = 'Angolan Kwanza - AOA'
currency.iso_code = 'DZD'
currency.symbol = 'Kz'
currency.exchange_rate = '20.000000000'
currency.is_active = true
format = Currencies::Format.new
format.decimal_separator = Util::Choice.new('Period')
format.thousand_separator = Util::Choice.new('Comma')
format.decimal_places = Util::Choice.new('2')
currency.format = format
bcw.base_currency = currency
response = co.enable_multiple_currencies(bcw)
Copiedrequire 'net/http'
require 'json'
class MultipleCurrenciesinOrganization
def execute
url ="https://www.zohoapis.com/crm/v2.1/org/currencies/actions/enable"
url = URI(url)
req = Net::HTTP::Post.new(url.request_uri)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
headers={}
headers["Authorization"]="Zoho-oauthtoken 1000.dfa7XXXXXXXXXXXXXXXXXX84f9665840.c176aeXXXXXXXXXXXX13f3d37a84d"
headers&.each { |key, value| req.add_field(key, value) }
request_body = {};
record_object = {};
format_object ={};
format_object["decimal_separator"]="Period";
format_object["thousand_separator"]="Comma";
format_object["decimal_places"]="2";
record_object["format"]=format_object;
record_object["prefix_symbol"]=true;
record_object["name"]="Algerian Dinar-ADN";
record_object["iso_code"]="DZD";
record_object["symbol"]="DA";
record_object["exchange_rate"]="1.0000000";
request_body["base_currency"] =record_object;
request_json = request_body.to_json
req.body = request_json.to_s
response=http.request(req)
status_code = response.code.to_i
headers = response.each_header.to_h
print status_code
print headers
unless response.body.nil?
print response.body
end
end
end
MultipleCurrenciesinOrganization.new.execute
CopiedformatMap = Map();
formatMap.put("decimal_separator", "Period");
formatMap.put("thousand_separator", "Comma");
formatMap.put("decimal_places", "2");
currencyMap = Map();
currencyMap.put("format", formatMap);
currencyMap.put("prefix_symbol", true);
currencyMap.put("name", "Algerian Dinar-ADN");
currencyMap.put("iso_code", "DZD");
currencyMap.put("symbol", "DA");
currencyMap.put("exchange_rate", "1.0000000");
params = Map();
params.put("base_currency", currencyMap);
response = invokeurl
[
url :"https://www.zohoapis.com/crm/v2.1/org/currencies/actions/enable"
type :POST
parameters: params.toString()
connection:"crm_oauth_connection"
];
info response;
In the request, "@input.json" contains the sample input data.