Example #1
0
        /// <summary>
        /// Processes response data into a response object.
        /// </summary>
        /// <param name="response">A string containing the response data to process.</param>
        /// <returns>An ApiResponse<T> containing the processed data.</returns>
        internal static ApiResponse <T> ProcessResponse(string response)
        {
            ApiResponse <T> ReturnValue = null;

            try
            {
                //TODO: Fix this dirty hack!
                if (typeof(T).FullName.Contains("GetOffersResponse"))
                {
                    if (response.Contains("},false,{"))
                    {
                        response = response.Replace("},false,{", "},{");
                    }
                    if (response.Contains("[false,{"))
                    {
                        response = response.Replace("[false,{", "[{");
                    }
                    if (response.Contains("},false]"))
                    {
                        response = response.Replace("}.false]", "}]");
                    }
                }
                ReturnValue = Serialiser <ApiResponse <T> > .Deserialise(response);
            }
            catch (Exception ex)
            {
                LogWriter.LogException(ex);
                LogWriter.LogMessage("T is: {0}", typeof(T).FullName);
                LogWriter.LogMessage("Raw Data: {0}", response);
                throw new ArgumentException("Unable to deserialise the response data", "response", ex);
            }

            return(ReturnValue);
        }