public ReturnMessage <string> Format()
        {
            var returnMessage = new ReturnMessage <string>();

            returnMessage.SetSuccess(this.ConvertXMLToJSON(this.Source));

            return(returnMessage);
        }
        /// <summary>
        /// Validates credential for configuraion data
        /// </summary>
        /// <param name="configurationData">Represents Credential model</param>
        /// <returns></returns>
        public ReturnMessage <bool> Validate(string configurationData)
        {
            var returnResult = new ReturnMessage <bool>();

            try
            {
                this._credentialInfo = ObjectUtils.JsonDeserialize <CredentialModel>(configurationData);
                if (!string.IsNullOrWhiteSpace(_credentialInfo.AccessToken) &&
                    !string.IsNullOrWhiteSpace(_credentialInfo.RefreshToken))
                {
                    returnResult.SetSuccess("Validation successful");
                }
                else
                {
                    returnResult.SetError("Validation failed. Access and Refresh token not found");
                }
            }
            catch (Exception e)
            {
                returnResult.SetError(e.ToString());
            }

            return(returnResult);
        }
        /// <summary>
        /// Generates intermediate resultset for partial data
        /// </summary>
        /// <param name="resource">A dictionay object for different level of data generation</param>
        /// <returns></returns>
        public ReturnMessage <IDictionary <string, string> > PartialValidate(IDictionary <string, string> resource)
        {
            var returnMessage = new ReturnMessage <IDictionary <string, string> >();

            //ToDo : Generate intermediate results for processing data / resultset etc.

            try
            {
                if (resource != null)
                {
                    var credentialInfo = resource["ConfigData"];
                    if (!string.IsNullOrEmpty(credentialInfo))
                    {
                        this._credentialInfo = ObjectUtils.JsonDeserialize <CredentialModel>(credentialInfo);
                        var step      = resource["Step"];
                        int stepValue = 0;
                        if (!string.IsNullOrWhiteSpace(step))
                        {
                            int.TryParse(step, out stepValue);
                        }
                        if (stepValue == 0)
                        {
                            string authorizationUrl = string.Format("https://accounts.zoho.com/oauth/v2/auth?scope={0}&client_id={1}&response_type=code&access_type=offline&redirect_uri={2}", this._credentialInfo.Scope, this._credentialInfo.ClientID, this._credentialInfo.CallBack);
                            resource["RequestUrl"]  = authorizationUrl;
                            resource["OpenBrowser"] = "true";
                            resource["Step"]        = (++stepValue).ToString();
                            resource["CallBack"]    = this._credentialInfo.CallBack;
                            resource["ConfigData"]  = ObjectUtils.JsonSerializer <CredentialModel>(this._credentialInfo);
                            returnMessage.SetSuccess("Success", resource);
                        }
                        else if (stepValue == 1)
                        {
                            var responseUrl = resource["ResponseUrl"];
                            if (!string.IsNullOrWhiteSpace(responseUrl))
                            {
                                string[] urlParts = responseUrl.Split('/');

                                foreach (string urlsPart in urlParts)
                                {
                                    if (urlsPart.Contains("code"))
                                    {
                                        this.tempToken = urlsPart.Split('=')[1];
                                    }
                                }
                                var validateResult = GetAccessToken(tempToken);
                                resource["OpenBrowser"] = "false";
                                resource["ConfigData"]  = ObjectUtils.JsonSerializer <CredentialModel>(this._credentialInfo);
                                if (!string.IsNullOrEmpty(validateResult))
                                {
                                    returnMessage.SetSuccess(validateResult, resource);
                                }
                                else
                                {
                                    returnMessage.SetError(validateResult, resource);
                                }
                            }
                        }
                    }
                    else
                    {
                        returnMessage.SetError("Empty config data");
                    }
                }
                else
                {
                    returnMessage.SetError("Resource data dictionary is empty");
                }
            }
            catch (Exception ex)
            {
                returnMessage.SetError("Error in Partial Validate " + ex.Message);
            }
            return(returnMessage);
        }