public override MovementsResponse GetMovements(MovementsRequest request)
        {
            MovementsResponse result = new MovementsResponse();

            try {
                LoginBindResponse loginData = doLogin();
                //banks/:bank_id/accounts/:account_id/:view_id/transactions
                string urlData = String.Format("banks/{0}/accounts/{1}/{2}/transactions", request.bank_id, request.AccountId, request.view_id);

                DateTime dt = DateTime.ParseExact(request.finalDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                request.finalDate = dt.ToString("yyyy-MM-dd");

                dt = DateTime.ParseExact(request.initialDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                request.initialDate = dt.ToString("yyyy-MM-dd");

                string JsonResult = new FluentClient(config.Url)
                                    .GetAsync(urlData)
                                    .WithHeader("Authorization", "JWT " + loginData.token)
                                    .WithHeader("obp_from_date", request.initialDate)
                                    .WithHeader("obp_to_date", request.finalDate)
                                    .WithOptions(true)
                                    .AsString().Result;

                try {
                    result.transactions = JsonConvert.DeserializeObject <List <Transactions> >(JsonResult);
                } catch {
                }

                result.executeStatus = getExecuteStatus(JsonResult, urlData);
            } catch (CustomException cEx) {
                result.executeStatus = cEx.convertToCustomStatus();
            } catch (Exception ex) {
                result.executeStatus = new CustomException(ExceptionsCodes.UnexpectedException, "", ex.Message).convertToCustomStatus();
            }

            return(result);
        }
Exemplo n.º 2
0
        public override MovementsResponse GetMovements(MovementsRequest request)
        {
            MovementsResponse result = new MovementsResponse();

            try {
                ValoresLoginResponse loginData = doLogin();

                string urlData = "accounts/getMovementsDetail";

                var requestM = (HttpWebRequest)WebRequest.Create(config.Url + urlData);
                requestM.ContentType = "application/json";
                requestM.Method      = "POST";

                if (cookieContainer != null)
                {
                    requestM.CookieContainer = cookieContainer;
                }
                else
                {
                    requestM.CookieContainer = new CookieContainer();
                }

                //CONVERT DATE
                DateTime dt = DateTime.ParseExact(request.finalDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                request.finalDate = dt.ToString("MM/dd/yyyy");

                dt = DateTime.ParseExact(request.initialDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                request.initialDate = dt.ToString("MM/dd/yyyy");

                ValoresMovementsRequest valoresMovementsRequest = new ValoresMovementsRequest();
                valoresMovementsRequest.productNumber = request.AccountId;
                valoresMovementsRequest.initialDate   = request.initialDate;
                valoresMovementsRequest.finalDate     = request.finalDate;

                //Valores
                valoresMovementsRequest.productId  = request.productId;
                valoresMovementsRequest.currencyId = request.currencyId;

                valoresMovementsRequest.numberOfMovements = 100;
                valoresMovementsRequest.sequential        = "0";
                valoresMovementsRequest.uniqueSequential  = "0";
                valoresMovementsRequest.mode      = "0";
                valoresMovementsRequest.serviceId = "1";

                using (var streamWriter = new StreamWriter(requestM.GetRequestStream())) {
                    string json = JsonConvert.SerializeObject(valoresMovementsRequest);
                    streamWriter.Write(json);
                }

                var httpResponse = (HttpWebResponse)requestM.GetResponse();

                ValoresMovementsReponse response = new ValoresMovementsReponse();

                string JsonResult = "";
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) {
                    JsonResult = streamReader.ReadToEnd();
                    response   = JsonConvert.DeserializeObject <ValoresMovementsReponse>(JsonResult);
                }

                if (response.message != null)
                {
                    result.executeStatus = new CustomStatus(ExceptionsCodes.ApiException, response.message.message, response.message.code, "accounts/getMovementsDetail");
                    return(result);
                }

                result = response.convertToStandar(request.currencyId);
                result.executeStatus = new CustomStatus();

                return(result);
            } catch (FormatException cEx) {
                result.executeStatus = new CustomException(ExceptionsCodes.UnexpectedException, "", cEx.Message).convertToCustomStatus();
            } catch (CustomException cEx) {
                result.executeStatus = cEx.convertToCustomStatus();
            } catch (Exception ex) {
                result.executeStatus = new CustomException(ExceptionsCodes.UnexpectedException, "", ex.Message).convertToCustomStatus();
            }

            return(result);
        }
Exemplo n.º 3
0
 public override MovementsResponse GetMovements(MovementsRequest request)
 {
     return(_connector.GetMovements(request));
 }
 public abstract MovementsResponse GetMovements(MovementsRequest request);