Example #1
0
        public MallInstallmentsResponse Installments(
            string token,
            string commerceCode,
            string buyOrder,
            int installmentsNumber)
        {
            ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
            ValidationUtil.hasTextWithMaxLength(commerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "commerceCode");
            ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");

            return(ExceptionHandler.Perform <MallInstallmentsResponse, MallTransactionInstallmentsExceptions>(() =>
            {
                var mallInstallmentsResponse = new MallInstallmentsRequest(
                    token,
                    commerceCode,
                    buyOrder,
                    installmentsNumber);
                return _requestService.Perform <MallInstallmentsResponse, MallTransactionInstallmentsExceptions>(mallInstallmentsResponse, Options);
            }));
        }
Example #2
0
        public MallInstallmentsDetailsResponse Installments(
            string token,
            List <MallInstallmentsDetails> details)
        {
            ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");

            return(ExceptionHandler.Perform <MallInstallmentsDetailsResponse, MallTransactionInstallmentsExceptions>(() =>
            {
                List <MallInstallmentsResponse> det = new List <MallInstallmentsResponse>();

                foreach (MallInstallmentsDetails req in details)
                {
                    var request = new MallInstallmentsRequest(
                        token,
                        req.CommerceCode,
                        req.BuyOrder,
                        req.InstallmentsNumber);

                    var resp = _requestService.Perform <MallInstallmentsResponse, MallTransactionInstallmentsExceptions>(request, Options);
                    det.Add(new MallInstallmentsResponse(resp.InstallmentsAmount, resp.IdQueryInstallments, resp.DeferredPeriods));
                }
                return JsonConvert.DeserializeObject <MallInstallmentsDetailsResponse>(det.ToString());
            }));
        }