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.

420 lines
20 KiB

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