示例#1
0
        public async Task <BestOfferResponse> GetOfferAsync(BestOfferRequest request)
        {
            var baseUrl = _configuration.GetValue <string>("PremierAPIConfig:BaseURL");
            var apiKey  = _configuration.GetValue <string>("PremierAPIConfig:ApiKey");

            var offerResponse = new BestOfferResponse();

            offerResponse.CompanyName = _configuration.GetValue <string>("PremierAPIConfig:CompanyName");

            var postData = new PremierAPIRequest
            {
                Source      = request.Source,
                Destination = request.Destination,
                Packages    = string.Join(",", request.Carton)
            };

            var response = await _restClient.PostRequestAsync <PremierAPIRequest, PremierAPIResponse>(baseUrl, postData, apiKey, MediaTypeNames.Application.Xml);

            if (response == default(PremierAPIResponse))
            {
                offerResponse.BestPrice = decimal.Zero;
            }
            else
            {
                offerResponse.BestPrice = response.Quote;
            }

            return(offerResponse);
        }
        public PremierAPIResponse GetPremierServiceCharge(PremierAPIRequest request)
        {
            var serviceChargeList = CompanyConfiguration.LoadServiceChargeData(CompanyName.Premier);

            var chargeRequest = _mapper.Map <ServiceChargeRequest>(request);

            var charge = GetServiceCharge(chargeRequest, serviceChargeList);

            return(new PremierAPIResponse {
                Quote = charge
            });
        }
示例#3
0
        public async Task <IActionResult> GetServiceCharge(PremierAPIRequest request)
        {
            try
            {
                _logger.LogInformation("Premier Contoller : GetServiceCharge Call");

                var response = _companyServiceCharge.GetPremierServiceCharge(request);

                _logger.LogInformation("Premier Contoller : GetServiceCharge Success");

                return(Ok(response));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Premier Contoller : GetServiceCharge - Error Occured ( {ex.Message} )");
                throw ex;
            }
        }