Configuration
Before you get started with creating your Ruby application, you need to register your client and authenticate the app with Zoho.
Mandatory Keys | Optional Keys |
---|---|
user | logger |
environment | store |
token | sdk_config |
proxy | |
resource_path |
Follow the below steps to configure the SDK.
Create an instance of SDKLog::Log Class to log exception and API information.
# # Create an instance of SDKLog::Log Class that takes two parameters # 1 -> Level of the log messages to be logged. Can be configured by typing Levels "::" and choose any level from the list displayed. # 2 ->Absolute file path, where messages need to be logged. # log = ZOHOCRMSDK::SDKLog::Log.initialize(level: ZOHOCRMSDK::Levels::INFO, path:"/Users/user_name/Documents/rubysdk_log.log")
Create an instance of UserSignature that identifies the current user.
#Create an UserSignature instance that takes user Email as parameter user_signature = ZOHOCRMSDK::UserSignature.new('abc@zohocorp.com')
Configure the API environment which decides the domain and the URL to make API calls.
#Configure the environment #which is of the pattern DC::Domain::Environment #Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter #Available Environments: PRODUCTION, DEVELOPER, SANDBOX environment = ZOHOCRMSDK::DC::USDataCenter::PRODUCTION
Create an instance of Authenticator::OAuthToken with the information that you get after registering your Zoho client.
#Create a Token instance #1 -> OAuth client id. #2 -> OAuth client secret. #3 -> grant token #4 -> refresh token #5 -> OAuth redirect URL. #6 -> id #7 -> Access token token = ZOHOCRMSDK::Authenticator::OAuthToken.new(client_id: "clientId", client_secret:"clientSecret", grant_token:"grant_token", refresh_token:"refresh_token", redirect_url:"redirectURL", id:"id", access_token:"access_token")
Create an instance of TokenStore to persist tokens that are used for authenticating all the requests. By default, the SDK creates the sdk_tokens.txt created in the current working directory) to persist the tokens.
# Create an instance of TokenStore. # DBStore takes the following parameters #1 -> DataBase host name. Default "localhost" #2 -> DataBase name. Default "zohooauth" #3 -> DataBase user name. Default "root" #4 -> DataBase password. Default "" #5 -> DataBase port number. Default "3306" #6 -> DataBase table name. Default value "oauthtoken" tokenstore = ZOHOCRMSDK::Store::DBStore.new(host: "host_name", database_name: "database_name", table_name: "table_name", user_name: "user_name",password: "password", port_number:"port_number") tokenstore = ZOHOCRMSDK::Store::FileStore.new("/Users/user_name/Documents/ruby_sdk_token.txt") tokenStore = CustomStore.new
Create an instance of SDKConfig containing the SDK configuration.
# By default, the SDK creates the SDKConfig instance # auto_refresh_fields # 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 file(s) or refresh the fields using methods from ModuleFieldsHandler (Util::ModuleFieldsHandler) # # pickListValidation # if true - value for any picklist field will be validated with the available values. # if false - value for any picklist field will not be validated, resulting in creation of a new value. # # open_timeout # Number of seconds to wait for the connection to open (default 60 seconds) # # read_timeout # Number of seconds to wait for one block to be read (via one read(2) call) (default 60 seconds) # # write_timeout # Number of seconds to wait for one block to be written (via one write(2) call) (default 60 seconds) # # keep_alive_timeout # Seconds to reuse the connection of the previous request(default 2 seconds) # sdk_config = ZOHOCRMSDK::SDKConfig.new(auto_refresh_fields: false, pick_list_validation: true, open_timeout: 60, read_timeout: 60, write_timeout: 60,keep_alive_timeout: 2)
The path containing the absolute directory path to store user specific files containing module fields information. By default, the SDK stores the user-specific files within a folder in the current working directory.
resource_path = "/Users/user_name/Documents/rubysdk-application"
Create an instance of RequestProxy containing the proxy properties of the user.
request_proxy = ZOHOCRMSDK::RequestProxy.new(host:"proxyHost", post:"proxyPort", user_name:"proxyUser", password:"password")
Initialize the SDK and make API calls.