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.
 
 
 
 
 

109 lines
5.1 KiB

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Swift.API.Common;
using Swift.API.Common.SyncModel.Bank;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
namespace Swift.API.ThirdPartyApiServices
{
public class SyncBankAndBranchService
{
public JsonResponse GetBankList(BankRequest model)
{
//Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
using (var client = RestApiClient.CallJMEThirdParty())
{
JsonResponse jsonResponse = new JsonResponse();
var obj = JsonConvert.SerializeObject(model);
var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json");
try
{
var URL = "api/v1/TP/bankList";
HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result;
string resultData = resp.Content.ReadAsStringAsync().Result;
if (resp.IsSuccessStatusCode)
{
jsonResponse = JsonConvert.DeserializeObject<JsonResponse>(resultData);
var b = JsonConvert.DeserializeObject(jsonResponse.Data.ToString());
var a = (jsonResponse.Data != null ? JsonConvert.DeserializeObject<List<BankResponse>>(jsonResponse.Data.ToString()) : null);
jsonResponse.Data = a;
return jsonResponse;
}
else
{
var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
var jsonResponseData = JsonConvert.DeserializeObject<JsonResponse>(errorJson.Message);
var data = JsonConvert.DeserializeObject<List<Data>>(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 JsonResponse()
{
ResponseCode = "1",
Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message)
};
}
}
}
public JsonResponse GetBankBranchList<T>(BankRequest model) where T : class
{
//Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
using (var client = RestApiClient.CallJMEThirdParty())
{
JsonResponse jsonResponse = new JsonResponse();
var obj = JsonConvert.SerializeObject(model);
var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json");
try
{
var URL = "api/v1/TP/bankList";
HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result;
string resultData = resp.Content.ReadAsStringAsync().Result;
if (resp.IsSuccessStatusCode)
{
jsonResponse = JsonConvert.DeserializeObject<JsonResponse>(resultData);
var a = (jsonResponse.Data != null ? JsonConvert.DeserializeObject<List<BracBranchDatum>>(jsonResponse.Data.ToString()) : null);
jsonResponse.Data = a;
return jsonResponse;
}
else
{
var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
var jsonResponseData = JsonConvert.DeserializeObject<JsonResponse>(errorJson.Message);
var data = JsonConvert.DeserializeObject<List<Data>>(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 JsonResponse()
{
ResponseCode = "1",
Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message)
};
}
}
}
}
}