using Business.TPApi; using Common; using Common.Model; using Common.Model.Config; using Common.Model.Notification; using log4net; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; using System.Web; using Data = Common.Data; using Notify = Common.Model.Notification; namespace Business { public static class NotifierV2 { private static readonly ILog Log = LogManager.GetLogger(typeof(NotifierV2)); public static JsonRxResponse SendNotification(SendNotificationRequest request, NOTIFICATION_TYPE nOTIFICATION_TYPE = NOTIFICATION_TYPE.PUSH_NOTIFICATION) { ThirdPartyAPI _tpApi = new ThirdPartyAPI(); APIJsonResponse jsonResponse = new APIJsonResponse(); if (string.IsNullOrEmpty(request.ProcessId)) request.ProcessId = Guid.NewGuid().ToString(); //request.ProviderId = Guid.NewGuid().ToString(); request.NotificationTypeId = nOTIFICATION_TYPE.ToString(); Log.Debug("NotifierV2.SendNotification | REQUEST : " + JsonConvert.SerializeObject(request)); APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly(request, "TP/NotificationAPI", out jsonResponse); Log.Debug("NotifierV2.SendNotification | RESPONSE : " + JsonConvert.SerializeObject(result)); return new JsonRxResponse() { ErrorCode = result.ResponseCode, Id = result.Id, Msg = result.Msg, Data = result.Data, Extra = result.Extra, Extra2 = result.Extra1 }; } } public class SendSMSApiService { public APIJsonResponse SMSTPApi(SMSRequestModel model) { //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model)); using (var client = RestApiClient.GetThirdPartyClient()) { APIJsonResponse jsonResponse = new APIJsonResponse(); var obj = JsonConvert.SerializeObject(model); var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json"); try { var URL = "TP/SMSApi"; HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result; string resultData = resp.Content.ReadAsStringAsync().Result; if (resp.IsSuccessStatusCode) { jsonResponse = JsonConvert.DeserializeObject(resultData); var a = (jsonResponse.Data != null ? JsonConvert.DeserializeObject(jsonResponse.Data.ToString()) : null); jsonResponse.Data = a; return jsonResponse; } else { var errorJson = JsonConvert.DeserializeObject(resultData); var jsonResponseData = JsonConvert.DeserializeObject(errorJson.Message); var data = JsonConvert.DeserializeObject>(jsonResponseData.Data.ToString()); jsonResponse.Id = jsonResponseData.Id; jsonResponse.ResponseCode = jsonResponseData.ResponseCode; jsonResponse.Msg = jsonResponseData.Msg; jsonResponse.Data = data; jsonResponse.Extra = jsonResponseData.Extra; jsonResponse.Extra1 = jsonResponseData.Extra1; return jsonResponse; } } catch (Exception ex) { return new APIJsonResponse() { ResponseCode = "1", Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message) }; } } } } }