Leeza Baidar
1 year ago
9 changed files with 440 additions and 75 deletions
-
92SendMail/API/ThirdPartyAPI.cs
-
106SendMail/Business/TxnPush.cs
-
26SendMail/Common/APIJsonResponse.cs
-
12SendMail/Common/Enums.cs
-
29SendMail/Common/Notification.cs
-
96SendMail/Common/SendNotificationRequest.cs
-
26SendMail/Common/TxnDetails.cs
-
13SendMail/DAO/TxnPushDAO.cs
-
9SendMail/JMETxnPushScheduler.csproj
@ -0,0 +1,92 @@ |
|||
using Common; |
|||
using JMETxnPushScheduler.Business; |
|||
using JMETxnPushScheduler.Common; |
|||
using log4net; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Linq; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net.Http; |
|||
using System.Net.Http.Headers; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace JMETxnPushScheduler.API |
|||
{ |
|||
public class ThirdPartyAPI |
|||
{ |
|||
private static int timeOut = 100; |
|||
private string tp_base_url = GetStatic.ReadWebConfig("ThirdParty_Base_Url", ""); |
|||
private string apiAccessKey = GetStatic.ReadWebConfig("apiAccessKey", ""); |
|||
//private readonly ILog _log = LogManager.GetLogger(typeof(ThirdPartyApi));
|
|||
|
|||
public ResponseModel ThirdPartyApiGetDataOnly<RequestModel, ResponseModel>(RequestModel model, string api_url, out APIJsonResponse jsonResponse, string MethodType = "post") |
|||
{ |
|||
ResponseModel _responseModel = default(ResponseModel); |
|||
using (HttpClient httpClient = new HttpClient()) |
|||
{ |
|||
try |
|||
{ |
|||
httpClient.BaseAddress = new Uri(tp_base_url); |
|||
httpClient.DefaultRequestHeaders.Add("apiAccessKey", apiAccessKey); |
|||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); |
|||
httpClient.Timeout = new TimeSpan(0, 0, timeOut); |
|||
HttpResponseMessage resp = new HttpResponseMessage(); |
|||
if (MethodType.ToLower().Equals("get")) |
|||
resp = httpClient.GetAsync(api_url).Result; |
|||
if (MethodType.ToLower().Equals("put")) |
|||
{ |
|||
StringContent jbdContent = new StringContent(JsonConvert.SerializeObject(model).ToString(), Encoding.UTF8, "application/json"); |
|||
resp = httpClient.PutAsync(api_url, jbdContent).Result; |
|||
} |
|||
if (MethodType.ToLower().Equals("post")) |
|||
{ |
|||
var jsonData = JsonConvert.SerializeObject(model).ToString(); |
|||
StringContent jbdContent = new StringContent(jsonData, Encoding.UTF8, "application/json"); |
|||
resp = httpClient.PostAsync(api_url, jbdContent).Result; |
|||
} |
|||
string resultData = resp.Content.ReadAsStringAsync().Result; |
|||
if (resp.IsSuccessStatusCode) |
|||
{ |
|||
var result = resp.Content.ReadAsStringAsync().Result; |
|||
JObject a = JObject.Parse(result); |
|||
_responseModel = a.ToObject<ResponseModel>(); |
|||
} |
|||
else |
|||
{ |
|||
//_log.Debug("ThirdPartyApiGetDataOnly | RESPONSE: " + resp.ToString());
|
|||
ErrorJosn errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData); |
|||
APIJsonResponse jsonResponseData = JsonConvert.DeserializeObject<APIJsonResponse>(errorJson.Message); |
|||
List<Data> data = JsonConvert.DeserializeObject<List<Data>>(jsonResponseData.Data.ToString()); |
|||
jsonResponse = new APIJsonResponse() |
|||
{ |
|||
Id = jsonResponseData.Id, |
|||
Msg = jsonResponseData.Msg, |
|||
Data = data, |
|||
Extra = jsonResponseData.Extra, |
|||
Extra1 = jsonResponseData.Extra1 |
|||
}; |
|||
} |
|||
} |
|||
catch (HttpRequestException ex) |
|||
{ |
|||
jsonResponse = new APIJsonResponse() |
|||
{ |
|||
ResponseCode = "999", |
|||
Msg = ex.Message, |
|||
Data = ex.Data, |
|||
}; |
|||
_responseModel = default(ResponseModel); |
|||
} |
|||
}; |
|||
|
|||
jsonResponse = new APIJsonResponse() |
|||
{ |
|||
ResponseCode = "0", |
|||
Msg = "Api Calling process successfully!" |
|||
}; |
|||
return _responseModel; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
|
|||
namespace Common |
|||
{ |
|||
public class APIJsonResponse |
|||
{ |
|||
public string ResponseCode { get; set; } |
|||
public string Msg { get; set; } |
|||
public string Id { get; set; } |
|||
public object Data { get; set; } |
|||
public string Extra { get; set; } |
|||
public string Extra1 { get; set; } |
|||
public string Extra3 { get; set; } |
|||
public string FootNoteMessage { get; set; } |
|||
|
|||
public void SetResponse(string responseCode, string msg, string id = null, string extra = null, string extra1 = null, string extra3 = null, string footNoteMessage = "") |
|||
{ |
|||
ResponseCode = responseCode; |
|||
Msg = msg; |
|||
Id = id; |
|||
Extra = extra; |
|||
Extra1 = extra1; |
|||
Extra3 = extra3; |
|||
FootNoteMessage = footNoteMessage; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
using System; |
|||
|
|||
namespace Swift.API.Common.Enum |
|||
{ |
|||
[Flags] |
|||
public enum NOTIFICATION_TYPE |
|||
{ |
|||
SMS, |
|||
EMAIL, |
|||
PUSH_NOTIFICATION |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace JMETxnPushScheduler.Common |
|||
{ |
|||
[DefaultValue(NONE)] |
|||
public enum NotifyTemplate |
|||
{ |
|||
NONE, |
|||
|
|||
|
|||
[Description("Email to customer txn is created for bank transfer")] |
|||
BANK_TRANSFER_TXN_PENDING = 1, |
|||
|
|||
[Description("Email to customer after txn payment is cleared by IME London")] |
|||
BANK_TRANSFER_TXN_CLEARED = 2, |
|||
|
|||
[Description("Email to customer after txn is accepted by Pay-out partner")] |
|||
BANK_TXN_POST = 3, |
|||
|
|||
[Description("Email to customer after txn has been accepted by Pay-out partner (Cash Collection)")] |
|||
CASH_TXN_POST = 4, |
|||
|
|||
} |
|||
} |
@ -0,0 +1,96 @@ |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace JMETxnPushScheduler.Common |
|||
{ |
|||
public class SendNotificationRequest : CommonRequest |
|||
{ |
|||
public string NotificationTypeId { get; set; } |
|||
public bool IsBulkNotification { get; set; } |
|||
public string ControlNo { get; set; } |
|||
public List<RecipientViewModel> Recipients { get; set; } |
|||
} |
|||
|
|||
public class DisplayMailAddress |
|||
{ |
|||
public string FromEmail { get; set; } |
|||
public string AliasName { get; set; } |
|||
|
|||
} |
|||
|
|||
public class AttachmentModel |
|||
{ |
|||
public string FileName { get; set; } |
|||
public string FilePath { get; set; } |
|||
public string FileType { get; set; } |
|||
public string Byte64String { get; set; } |
|||
} |
|||
|
|||
public class RecipientViewModel |
|||
{ |
|||
public string Address { get; set; } |
|||
public string CcAddress { get; set; } |
|||
|
|||
public string BccAddress { get; set; } |
|||
public string DeviceType { get; set; } |
|||
|
|||
|
|||
public DisplayMailAddress MailAddress { get; set; } |
|||
|
|||
public NotificationDTO NotificationContent { get; set; } |
|||
} |
|||
|
|||
public class NotificationDTO |
|||
{ |
|||
[JsonProperty("body")] |
|||
public string Body { get; set; } |
|||
|
|||
[JsonProperty("title")] |
|||
public string Title { get; set; } |
|||
|
|||
[JsonProperty("image")] |
|||
public string Image { get; set; } |
|||
|
|||
public string ClickActivity { get; set; } |
|||
public string MessageType { get; set; } |
|||
public string NavigateURL { get; set; } |
|||
|
|||
public List<AttachmentModel> Attachments { get; set; } |
|||
|
|||
public List<AttachmentModel> EmbeddedResources { get; set; } |
|||
|
|||
} |
|||
public class Mapping |
|||
{ |
|||
public string SValue { get; set; } |
|||
public string SText { get; set; } |
|||
public string DValue { get; set; } |
|||
public string DText { get; set; } |
|||
|
|||
} |
|||
public class SendNotificationRequestMobile : CommonRequest |
|||
{ |
|||
public string NotificationTypeId { get; set; } |
|||
|
|||
public bool IsBulkNotification { get; set; } |
|||
|
|||
public string ControlNo { get; set; } |
|||
|
|||
public List<RecipientViewModel> Recipients { get; set; } |
|||
|
|||
public NotifyTemplate Template { get; set; } |
|||
|
|||
public string Language { get; set; } |
|||
} |
|||
public class CommonRequest |
|||
{ |
|||
public string ProcessId { get; set; } |
|||
public string UserName { get; set; } |
|||
public string ProviderId { get; set; } |
|||
public string SessionId { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace JMETxnPushScheduler.Common |
|||
{ |
|||
public class TxnDetails |
|||
{ |
|||
public string senderName { get; set; } |
|||
public string controlNo { get; set; } |
|||
public string TranDate { get; set; } |
|||
public string PayoutCountry { get; set; } |
|||
public string BankName { get; set; } |
|||
public string BankBranch { get; set; } |
|||
public string AccountNo { get; set; } |
|||
public string BeneficiaryName { get; set; } |
|||
public string PayoutAmount { get; set; } |
|||
public string TransferAmount { get; set; } |
|||
public string serviceCharge { get; set; } |
|||
public string TotalAmount { get; set; } |
|||
public string paymentMethod { get; set; } |
|||
public string email { get; set; } |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue