示例#1
0
        public async Task <GetQuotesResponse> GetQuotes(GetQuotesRequest request)
        {
            var command = new GetQuotesCommand(request.Symbols, Gateway.AccesToken);

            //Send command to API
            await MakeApiCall(command);

            //Some handling of the response
            var response = new GetQuotesResponse(command.RawResponse, command.MessageFormat);

            return(response);
        }
        public async Task <GetQuotesResponse> GetQuotes(GetQuotesRequest request)
        {
            try
            {
                using var client = _clientFactory.CreateClient("ParcelMonkey");

                var agentResponse = new GetQuotesResponse
                {
                    Quotes = await client.PostAsync <IList <GetQuoteResponse> >("GetQuote", request)
                };

                return(agentResponse);
            }
            catch (HttpRequestException ex)
            {
                throw new ParcelMonkeyException(ex.Message);
            }
        }
示例#3
0
        public GetQuotesResponse GetQuotes(GetQuotesRequest request)
        {
            var productCodes = request.ProductCodes.Count() > 0 ? request.ProductCodes : Product.Defaults.Select(x => x.ProductCode);
            var quotes       = new List <Quote>();

            foreach (var code in productCodes)
            {
                var quote = new Quote();
                quote.VehicleId  = request.VehicleId;
                quote.PostalCode = request.PostalCode;
                quote.Product    = GetProduct(code);
                quote.Options    = GetOptions(code);
                quote.Cost       = CalculateCost(quote.Product.BasePrice, request.VehicleId, request.PostalCode);
                quotes.Add(quote);
            }
            var response = new GetQuotesResponse();

            response.Quotes = quotes;
            return(response);
        }
示例#4
0
        protected virtual GetQuotesResponse GetQuotesInternal(GetQuotesRequest request)
        {
            Log.Debug("QuoteService.GetQuotesInternal called for vehicle ID: {0}, postal code: {1}", request.VehicleId, request.PostalCode);
            var productCodes = request.ProductCodes.Count() > 0 ? request.ProductCodes : Product.Defaults.Select(x => x.ProductCode);
            var quotes       = new List <Quote>();

            foreach (var code in productCodes)
            {
                var quote = new Quote();
                quote.VehicleId  = request.VehicleId;
                quote.PostalCode = request.PostalCode;
                quote.Product    = GetProduct(code);
                quote.Options    = GetOptions(code);
                quote.Cost       = CalculateCost(quote.Product.BasePrice, request.VehicleId, request.PostalCode);
                quotes.Add(quote);
            }
            var response = new GetQuotesResponse();

            response.Quotes = quotes;
            Log.Debug("QuoteService.GetQuotesInternal returning for vehicle ID: {0}, postal code: {1}", request.VehicleId, request.PostalCode);
            return(response);
        }