public ResultDTO Process() { try { // Build request HttpWebRequest request = (HttpWebRequest)WebRequest.Create( string.Format( "https://api.procampaignapi.com/Consumer/Documents/{0}/{1}?apiKey={2}", TermsAndConditionsName, TermsAndConditionsName, ProCampaignKeyRepository.GetApiKey(Locale, Environment) )); request.Method = "Get"; request.KeepAlive = true; // Get response HttpWebResponse response = (HttpWebResponse)request.GetResponse(); request.ContentType = "application/json"; Result.HttpStatusCode = HttpStatusCode.OK; using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) { string responseValue = streamReader.ReadToEnd(); ResponseRootObject responseResult = JsonConvert.DeserializeObject <ResponseRootObject>(responseValue); if (responseResult.IsSuccessful) { Result.HttpStatusCode = HttpStatusCode.OK; Result.Meta = new { PolicyText = String.Empty, PolicyVersion = String.Empty, TnCText = responseResult.Data.Html, TnCVersion = responseResult.Data.Versions[0].Version }; } else { Result.HttpStatusCode = HttpStatusCode.InternalServerError; Result.Code = CodeKeys.SYSTEM_ERROR_01; } } } catch (Exception ex) { Result.HttpStatusCode = HttpStatusCode.InternalServerError; Result.Code = CodeKeys.SYSTEM_ERROR_01; } return(Result); }
internal ProCampaignService(string locale, string environement = null) { var key = ProCampaignKeyRepository.GetApiKey(locale, environement); if (key == null) { throw new Exception("Configuration failed Key not found"); } var secret = ProCampaignKeyRepository.GetApiSecret(locale, environement); this._apiSecret = !string.IsNullOrEmpty(secret) ? secret : string.Empty; this._apiKey = key; this._consumerClient = new ConsumerClient(APIKey, APISecret); }