You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

509 lines
24 KiB

  1. using Newtonsoft.Json;
  2. using Swift.API.Common;
  3. using Swift.API.Common.ExRate;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Configuration;
  7. using System.Linq;
  8. using System.Net.Http;
  9. using System.Text;
  10. namespace Swift.API.ThirdPartyApiServices
  11. {
  12. public class ExchangeRateAPIService
  13. {
  14. public JsonResponse GetExchangeRate(ExRateRequest model)
  15. {
  16. //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
  17. using (var client = RestApiClient.CallJMEThirdParty())
  18. {
  19. JsonResponse jsonResponse = new JsonResponse();
  20. var obj = JsonConvert.SerializeObject(model);
  21. var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json");
  22. try
  23. {
  24. var URL = "api/v1/TP/ExRate";
  25. HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result;
  26. string resultData = resp.Content.ReadAsStringAsync().Result;
  27. if (resp.IsSuccessStatusCode)
  28. {
  29. jsonResponse = JsonConvert.DeserializeObject<JsonResponse>(resultData);
  30. var a = (jsonResponse.Data != null ? JsonConvert.DeserializeObject<ExRateResponse>(jsonResponse.Data.ToString()) : null);
  31. jsonResponse.Data = a;
  32. return jsonResponse;
  33. }
  34. else
  35. {
  36. var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
  37. var jsonResponseData = JsonConvert.DeserializeObject<JsonResponse>(errorJson.Message);
  38. var data = JsonConvert.DeserializeObject<List<Data>>(jsonResponseData.Data.ToString());
  39. jsonResponse.Id = jsonResponseData.Id;
  40. jsonResponse.ResponseCode = jsonResponseData.ResponseCode;
  41. jsonResponse.Msg = jsonResponseData.Msg;
  42. jsonResponse.Data = data;
  43. jsonResponse.Extra = jsonResponseData.Extra;
  44. jsonResponse.Extra1 = jsonResponseData.Extra1;
  45. return jsonResponse;
  46. }
  47. }
  48. catch (Exception ex)
  49. {
  50. return new JsonResponse()
  51. {
  52. ResponseCode = "1",
  53. Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message)
  54. };
  55. }
  56. }
  57. }
  58. public JsonResponse AccountValidationTP(AccountValidateModel model)
  59. {
  60. //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
  61. using (var client = RestApiClient.CallJMEThirdParty())
  62. {
  63. JsonResponse jsonResponse = new JsonResponse();
  64. var obj = JsonConvert.SerializeObject(model);
  65. var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json");
  66. try
  67. {
  68. var URL = "api/v1/TP/Verify";
  69. HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result;
  70. string resultData = resp.Content.ReadAsStringAsync().Result;
  71. if (resp.IsSuccessStatusCode)
  72. {
  73. jsonResponse = JsonConvert.DeserializeObject<JsonResponse>(resultData);
  74. return jsonResponse;
  75. }
  76. else
  77. {
  78. var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
  79. var jsonResponseData = JsonConvert.DeserializeObject<JsonResponse>(errorJson.Message);
  80. var data = JsonConvert.DeserializeObject<List<Data>>(jsonResponseData.Data.ToString());
  81. jsonResponse.Id = jsonResponseData.Id;
  82. jsonResponse.ResponseCode = jsonResponseData.ResponseCode;
  83. jsonResponse.Msg = jsonResponseData.Msg;
  84. jsonResponse.Data = data;
  85. jsonResponse.Extra = jsonResponseData.Extra;
  86. jsonResponse.Extra1 = jsonResponseData.Extra1;
  87. return jsonResponse;
  88. }
  89. }
  90. catch (Exception ex)
  91. {
  92. return new JsonResponse()
  93. {
  94. ResponseCode = "1",
  95. Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message)
  96. };
  97. }
  98. }
  99. }
  100. public JsonResponse PushNotification(SendNotificationRequest model)
  101. {
  102. //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
  103. using (var client = RestApiClient.CallJMEThirdParty())
  104. {
  105. JsonResponse jsonResponse = new JsonResponse();
  106. var obj = JsonConvert.SerializeObject(model);
  107. var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json");
  108. try
  109. {
  110. var URL = "api/v1/TP/NotificationAPI";
  111. HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result;
  112. string resultData = resp.Content.ReadAsStringAsync().Result;
  113. if (resp.IsSuccessStatusCode)
  114. {
  115. jsonResponse = JsonConvert.DeserializeObject<JsonResponse>(resultData);
  116. return jsonResponse;
  117. }
  118. else
  119. {
  120. var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
  121. var jsonResponseData = JsonConvert.DeserializeObject<JsonResponse>(errorJson.Message);
  122. var data = JsonConvert.DeserializeObject<List<Data>>(jsonResponseData.Data.ToString());
  123. jsonResponse.Id = jsonResponseData.Id;
  124. jsonResponse.ResponseCode = jsonResponseData.ResponseCode;
  125. jsonResponse.Msg = jsonResponseData.Msg;
  126. jsonResponse.Data = data;
  127. jsonResponse.Extra = jsonResponseData.Extra;
  128. jsonResponse.Extra1 = jsonResponseData.Extra1;
  129. return jsonResponse;
  130. }
  131. }
  132. catch (Exception ex)
  133. {
  134. return new JsonResponse()
  135. {
  136. ResponseCode = "1",
  137. Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message)
  138. };
  139. }
  140. }
  141. }
  142. public JsonResponse GetTxnStatus(dynamic model)
  143. {
  144. //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
  145. using (var client = RestApiClient.CallJMEThirdParty())
  146. {
  147. JsonResponse jsonResponse = new JsonResponse();
  148. var obj = JsonConvert.SerializeObject(model);
  149. var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json");
  150. try
  151. {
  152. var URL = "api/v1/TP/GetStatus";
  153. HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result;
  154. string resultData = resp.Content.ReadAsStringAsync().Result;
  155. if (resp.IsSuccessStatusCode)
  156. {
  157. jsonResponse = JsonConvert.DeserializeObject<JsonResponse>(resultData);
  158. if (jsonResponse.ResponseCode.Equals("104"))
  159. {
  160. var datas = JsonConvert.DeserializeObject<List<Data>>(jsonResponse.Data.ToString());
  161. string msg = "";
  162. foreach (var item in datas)
  163. {
  164. msg += " " + item.Message;
  165. }
  166. jsonResponse.Msg += msg;
  167. }
  168. return jsonResponse;
  169. }
  170. else
  171. {
  172. var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
  173. var jsonResponseData = JsonConvert.DeserializeObject<JsonResponse>(errorJson.Message);
  174. var data = JsonConvert.DeserializeObject<List<Data>>(jsonResponseData.Data.ToString());
  175. jsonResponse.Id = jsonResponseData.Id;
  176. jsonResponse.ResponseCode = jsonResponseData.ResponseCode;
  177. jsonResponse.Msg = jsonResponseData.Msg;
  178. //jsonResponse.Data = data;
  179. jsonResponse.Extra = jsonResponseData.Extra;
  180. return jsonResponse;
  181. }
  182. }
  183. catch (Exception ex)
  184. {
  185. return new JsonResponse()
  186. {
  187. ResponseCode = "1",
  188. Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message)
  189. };
  190. }
  191. }
  192. }
  193. public List<TransactionResponse> DownloadInficareTransaction(string url)
  194. {
  195. //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
  196. using (var client = RestApiClient.CallJMEThirdParty())
  197. {
  198. List<TransactionResponse> jsonResponse = new List<TransactionResponse>();
  199. try
  200. {
  201. HttpResponseMessage resp = client.GetAsync(url).Result;
  202. string resultData = resp.Content.ReadAsStringAsync().Result;
  203. if (resp.IsSuccessStatusCode)
  204. {
  205. //jsonResponse = JsonConvert.DeserializeObject<List<RetrieveMultipleResponse>>(resultData);
  206. jsonResponse = JsonConvert.DeserializeObject<List<TransactionResponse>>(resultData);
  207. jsonResponse[0].errorCode = "0";
  208. jsonResponse[0].errorMsg = "Success";
  209. return jsonResponse;
  210. }
  211. else
  212. {
  213. jsonResponse[0].errorCode = "1";
  214. jsonResponse[0].errorMsg = "Success";
  215. return jsonResponse;
  216. }
  217. }
  218. catch (Exception ex)
  219. {
  220. jsonResponse[0].errorCode = "1";
  221. jsonResponse[0].errorMsg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message);
  222. return jsonResponse;
  223. }
  224. }
  225. }
  226. public List<CustomerData> DownloadInficareCustomer(string url)
  227. {
  228. //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
  229. using (var client = RestApiClient.CallJMEThirdParty())
  230. {
  231. List<CustomerData> jsonResponse = new List<CustomerData>();
  232. try
  233. {
  234. HttpResponseMessage resp = client.GetAsync(url).Result;
  235. string resultData = resp.Content.ReadAsStringAsync().Result;
  236. if (resp.IsSuccessStatusCode)
  237. {
  238. //jsonResponse = JsonConvert.DeserializeObject<List<RetrieveMultipleResponse>>(resultData);
  239. jsonResponse = JsonConvert.DeserializeObject<List<CustomerData>>(resultData);
  240. jsonResponse[0].errorCode = "0";
  241. jsonResponse[0].errorMsg = "Success";
  242. return jsonResponse;
  243. }
  244. else
  245. {
  246. jsonResponse[0].errorCode = "1";
  247. jsonResponse[0].errorMsg = "Success";
  248. return jsonResponse;
  249. }
  250. }
  251. catch (Exception ex)
  252. {
  253. jsonResponse[0].errorCode = "1";
  254. jsonResponse[0].errorMsg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message);
  255. return jsonResponse;
  256. }
  257. }
  258. }
  259. public List<ReceiverData> DownloadInficareReceiver(string url)
  260. {
  261. //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
  262. using (var client = RestApiClient.CallJMEThirdParty())
  263. {
  264. List<ReceiverData> jsonResponse = new List<ReceiverData>();
  265. try
  266. {
  267. HttpResponseMessage resp = client.GetAsync(url).Result;
  268. string resultData = resp.Content.ReadAsStringAsync().Result;
  269. if (resp.IsSuccessStatusCode)
  270. {
  271. //jsonResponse = JsonConvert.DeserializeObject<List<RetrieveMultipleResponse>>(resultData);
  272. jsonResponse = JsonConvert.DeserializeObject<List<ReceiverData>>(resultData);
  273. jsonResponse[0].errorCode = "0";
  274. jsonResponse[0].errorMsg = "Success";
  275. return jsonResponse;
  276. }
  277. else
  278. {
  279. jsonResponse[0].errorCode = "1";
  280. jsonResponse[0].errorMsg = "Success";
  281. return jsonResponse;
  282. }
  283. }
  284. catch (Exception ex)
  285. {
  286. jsonResponse[0].errorCode = "1";
  287. jsonResponse[0].errorMsg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message);
  288. return jsonResponse;
  289. }
  290. }
  291. }
  292. public List<TransactionSync> DownloadInficareTransactionForSync(string url)
  293. {
  294. //Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
  295. using (var client = RestApiClient.CallJMEThirdParty())
  296. {
  297. List<TransactionSync> jsonResponse = new List<TransactionSync>();
  298. try
  299. {
  300. HttpResponseMessage resp = client.GetAsync(url).Result;
  301. string resultData = resp.Content.ReadAsStringAsync().Result;
  302. if (resp.IsSuccessStatusCode)
  303. {
  304. //jsonResponse = JsonConvert.DeserializeObject<List<RetrieveMultipleResponse>>(resultData);
  305. jsonResponse = JsonConvert.DeserializeObject<List<TransactionSync>>(resultData);
  306. jsonResponse[0].errorCode = "0";
  307. jsonResponse[0].errorMsg = "Success";
  308. return jsonResponse;
  309. }
  310. else
  311. {
  312. jsonResponse[0].errorCode = "1";
  313. jsonResponse[0].errorMsg = "Success";
  314. return jsonResponse;
  315. }
  316. }
  317. catch (Exception ex)
  318. {
  319. jsonResponse[0].errorCode = "1";
  320. jsonResponse[0].errorMsg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message);
  321. return jsonResponse;
  322. }
  323. }
  324. }
  325. public class TransactionSync
  326. {
  327. public string errorCode { get; set; }
  328. public string errorMsg { get; set; }
  329. public string transtatus { get; set; }
  330. public string status { get; set; }
  331. public string paiddate { get; set; }
  332. public string cancel_date { get; set; }
  333. public string tranno { get; set; }
  334. }
  335. public class ReceiverData
  336. {
  337. public string errorCode { get; set; }
  338. public string errorMsg { get; set; }
  339. public string Col1 { get; set; }
  340. public string Sender_SNo { get; set; }
  341. public string ReceiverName { get; set; }
  342. public string ReceiverMiddleName { get; set; }
  343. public string ReceiverLastName { get; set; }
  344. public string ReceiverCountry { get; set; }
  345. public string ReceiverAddress { get; set; }
  346. public string Col2 { get; set; }
  347. public string Col3 { get; set; }
  348. public string ReceiverCity { get; set; }
  349. public string ReceiverEmail { get; set; }
  350. public string Col4 { get; set; }
  351. public string ReceiverFax { get; set; }
  352. public string ReceiverMobile { get; set; }
  353. public string Relation { get; set; }
  354. public string CustomerbenificiarType { get; set; }
  355. public string ReceiverIdDescription { get; set; }
  356. public string ReceiverId { get; set; }
  357. public string PaymentType { get; set; }
  358. public string Commercial_bank_Id { get; set; }
  359. public string PayOutPartner { get; set; }
  360. public string Api_partnet_bank_name { get; set; }
  361. public string AccountNo { get; set; }
  362. public string CustomerRemarks { get; set; }
  363. public string Reason_for_remittance { get; set; }
  364. public string CreateBy { get; set; }
  365. public string Create_TS { get; set; }
  366. public string Col5 { get; set; }
  367. public string Col6 { get; set; }
  368. public string Col7 { get; set; }
  369. public string SNo { get; set; }
  370. }
  371. public class CustomerData
  372. {
  373. public string errorCode { get; set; }
  374. public string errorMsg { get; set; }
  375. public string SenderName { get; set; }
  376. public string SenderMiddleName { get; set; }
  377. public string SenderLastName { get; set; }
  378. public string Country { get; set; }
  379. public string SenderZipCode { get; set; }
  380. public string SenderCity { get; set; }
  381. public string SenderState { get; set; }
  382. public string SenderEmail { get; set; }
  383. public string SenderMobile2 { get; set; }
  384. public string SenderMobile { get; set; }
  385. public string SenderNativeCountry { get; set; }
  386. public string Date_of_birth { get; set; }
  387. public string Sender_Occupation { get; set; }
  388. public string Gender { get; set; }
  389. public string FullName { get; set; }
  390. public string Create_by { get; set; }
  391. public string create_ts { get; set; }
  392. public string id_issue_DATE { get; set; }
  393. public string SENDERVISA { get; set; }
  394. public string SenderFax { get; set; }
  395. public string SenderPassport { get; set; }
  396. public string Is_ACT { get; set; }
  397. public string approve_by { get; set; }
  398. public string approve_ts { get; set; }
  399. public string cust_type { get; set; }
  400. public string is_enable { get; set; }
  401. public string Force_Change_Pwd { get; set; }
  402. public string Source_Of_income { get; set; }
  403. public string SenderAddress { get; set; }
  404. public string CustomerType { get; set; }
  405. public string EmploymentType { get; set; }
  406. public string NameOfEmp { get; set; }
  407. public string SSN_cardId { get; set; }
  408. public string Is_Active { get; set; }
  409. public string Customer_remarks { get; set; }
  410. public string sendercompany { get; set; }
  411. public string RegdNo { get; set; }
  412. public string Org_Type { get; set; }
  413. public string Date_OfInc { get; set; }
  414. public string Nature_OD_Company { get; set; }
  415. public string Position { get; set; }
  416. public string NameOfAuthorizedPerson { get; set; }
  417. public string Income { get; set; }
  418. public string SNo { get; set; }
  419. public string CustomerId { get; set; }
  420. }
  421. public class TransactionResponse
  422. {
  423. public string errorCode { get; set; }
  424. public string errorMsg { get; set; }
  425. public string RefNo { get; set; }
  426. public string pCurrCostRate { get; set; }
  427. public string PCurrMargin { get; set; }
  428. public string custRate { get; set; }
  429. public string SCharge { get; set; }
  430. public string senderCommission { get; set; }
  431. public string pAgentComm { get; set; }
  432. public string pAgentCommCurr { get; set; }
  433. public string AgentCode { get; set; }
  434. public string Branch1 { get; set; }
  435. public string Branch_Code { get; set; }
  436. public string Branch { get; set; }
  437. public string ReceiverCountry { get; set; }
  438. public string paymentType { get; set; }
  439. public string ben_bank_id_BANK { get; set; }
  440. public string ben_bank_name_BANK { get; set; }
  441. public string ben_bank_id { get; set; }
  442. public string ben_bank_name { get; set; }
  443. public string rBankAcNo { get; set; }
  444. public string collMode { get; set; }
  445. public string paidAmt { get; set; }
  446. public string receiveAmt { get; set; }
  447. public string TotalRountAmt { get; set; }
  448. public string receiveCType { get; set; }
  449. public string ReceiverRelation { get; set; }
  450. public string reason_for_remittance { get; set; }
  451. public string source_of_income { get; set; }
  452. public string TranStatus { get; set; }
  453. public string PayStatus { get; set; }
  454. public string sTime { get; set; }
  455. public string sempid { get; set; }
  456. public string confirmdate { get; set; }
  457. public string sendername { get; set; }
  458. public string receivername { get; set; }
  459. public string TranNo { get; set; }
  460. public string firstName { get; set; }
  461. public string fullName { get; set; }
  462. public string senderstate { get; set; }
  463. public string sendercity { get; set; }
  464. public string senderAddress { get; set; }
  465. public string senderemail { get; set; }
  466. public string sender_mobile { get; set; }
  467. public string senderPhoneNo { get; set; }
  468. public string senderNativeCountry { get; set; }
  469. public string senderFax { get; set; }
  470. public string senderPassport { get; set; }
  471. public string ID_issue_Date { get; set; }
  472. public string senderVisa { get; set; }
  473. public string ip_address { get; set; }
  474. public string dateofbirth { get; set; }
  475. public string senderzipcode { get; set; }
  476. public string customer_sno { get; set; }
  477. public string rfirstName { get; set; }
  478. public string rFullName { get; set; }
  479. public string rCountry { get; set; }
  480. public string receiverAddress { get; set; }
  481. public string receiver_mobile { get; set; }
  482. public string ReceiverIdDescription { get; set; }
  483. public string ReceiverId { get; set; }
  484. public string rRel { get; set; }
  485. public string receiver_sno { get; set; }
  486. public string paidBy { get; set; }
  487. public string paidDate { get; set; }
  488. public string cancel_date { get; set; }
  489. }
  490. }
  491. }