Configuration
Before you get started with creating your Javascript application, you need to register your client and authenticate the app with Zoho.
Follow the below steps to configure the SDK.
Create an instance of the Logger Class to log exception and API information.
/* * Create an instance of Logger Class that takes parameter * 1 -> Level of the log messages to be logged. Can be configured by typing Levels "." and choose any level from the list displayed. */ let logger = Logger.getInstance(Levels.ALL);
Configure the API environment which decides the domain and the URL to make API calls.
/* * Configure the environment * which is of the pattern Domain.Environment * Available Domains: US, EU, IN, CN, AU * Available Environments: PRODUCTION(), DEVELOPER(), SANDBOX() */ let environment = DataCenter.US.PRODUCTION();
Create an instance of OAuthToken with the information that you get after registering your Zoho client.
/* * Create a Token instance * clientId -> OAuth client id. * scope -> OAuth client scope. * redirectURL -> OAuth Redirect URL. */ let token = new OAuthBuilder() .clientId("clientId") .scope("scope") .redirectURL("redirectURL") .build();
Create an instance of SDKConfig containing the SDK configuration.
/* * autoRefreshFields * if true - all the modules' fields will be auto-refreshed in the background, every hour. * if false - the fields will not be auto-refreshed in the background. The user can manually delete the cache or refresh the fields using methods from ModuleFieldsHandler * * cacheStore * A boolean field that allows or disallows the storage of module field information in cache. * True - the SDK stores all the modules' field information in cache, and refreshes every hour, if autoRefreshFields is true. * False - the SDK temporarily stores the modules' field information in a Map. * * pickListValidation * A boolean field that validates user input for a pick list field and allows or disallows the addition of a new value to the list. * True - the SDK validates the input. If the value does not exist in the pick list, the SDK throws an error. * False - the SDK does not validate the input and makes the API request with the user’s input to the pick list * * timeout * representing the number of milliseconds a request can take before automatically being terminated. */ let sdkConfig = new SDKConfigBuilder().autoRefreshFields(true).pickListValidation(false).cacheStore(true).timeout(1000).build();