コード例 #1
0
        /// <summary>
        /// Based upon the `PriceSheetRequest` dto supplied, this will
        /// call the appropriate E-Fulfillment service and return a list of tuples.
        /// </summary>
        /// <param name="priceSheetRequest">Dto containing all pertinent information for the request.</param>
        /// <param name="endpoint">Optional field to supply a specific endpoint to be appended to the base url.</param>
        /// <returns>Collection of tuples that contain an ImportSeedItem Dto and a ImportSeedItemZone Dto</returns>
        public IEnumerable <(ImportSeedItem ImportSeedItem, ImportSeedItemZone ZonePricingDetail)> GetSeedItemZonePricePairs(PriceSheetRequest priceSheetRequest, string endpoint = null)
        {
            PriceSheetType priceSheet;

            var request = _mapper.Map <PriceSheetRequestType>(priceSheetRequest);

            var endpointAddress = ClientUtility.BuildEndpointAddress(_baseUrl, endpoint);
            var binding         = ClientUtility.GetBinding(endpointAddress);

            using (var client = new CESOrderManagementPortTypeClient(binding, endpointAddress))
            {
                priceSheet = _agGatewaySecurityProvider.ExecuteRequest(client, request, client.PriceSheetRequest);
            }

            var seedItems = _mapper.Map <IEnumerable <(ImportSeedItem importSeedItem, ImportSeedItemZone zonePricingDetail)> >(priceSheet);

            return(seedItems);
        }
コード例 #2
0
        public ShipNoticeResponse GetShipNotices(ShipNoticeRequest shipNoticeRequest, string endpoint = null)
        {
            ShipNoticeListType shipNoticeListType;
            var request = _mapper.Map <ShipNoticeListRequestType>(shipNoticeRequest);

            var endpointAddress = ClientUtility.BuildEndpointAddress(_baseUrl, endpoint);
            var binding         = ClientUtility.GetBinding(endpointAddress);

            using (var client = new CESTransportationPortTypeClient(binding, endpointAddress))
            {
                shipNoticeListType = _agGatewaySecurityProvider.ExecuteRequest(client, request, client.ShipNoticeListRequest);
            }

            var shipments = _mapper.Map <IEnumerable <Shipment> >(shipNoticeListType);

            foreach (var shipment in shipments)
            {
                shipment.VendorId = shipNoticeRequest.Vendor.Id;
            }

            return(null);
        }
コード例 #3
0
        // NOTE: ALL TYPES USED ARE STRICTLY HYPOTHETICAL
        // NOTE: THIS IS JUST AN ILLUSTRATION THAT WON'T BREAK THE BUILD
        /// <summary>
        /// This method takes an example request DTO, maps it to the appropriate AgGateway request object,
        ///     calls the HandleGenericAgGatewayRequest method to make the request and maps the response
        ///     to the appropriate DTO
        /// </summary>
        /// <param name="exampleRequest">The Request DTO</param>
        /// <param name="endpoint">The (optional) endpoint to be appended to the base url</param>
        /// <returns>The mapped DTO</returns>
        //public ExampleResponseDto ExampleGenericAgGatewayMethod(ExampleRequestDto exampleRequest, string endpoint = null)
        //{
        //    var request = _mapper.Map<Generic.ExampleAgGatewayRequestType>(exampleRequest);

        //    var response = HandleGenericAgGatewayRequest<Generic.ExampleAgGatewayRequestType, Generic.ExampleAgGatewayResponseType>(request, endpoint);

        //    return _mapper.Map<ExampleResponseDto>(response);
        //}

        #endregion

        /// <summary>
        /// This handles a request to the generic AgGateway Doc Exchange web service
        /// </summary>
        /// <typeparam name="TRequest">The request type from the `EFC.AgGateway.Integration.Specifications.AgGatewayGenericServiceContract` namespace</typeparam>
        /// <typeparam name="TResponse">The response type from the `EFC.AgGateway.Integration.Specifications.AgGatewayGenericServiceContract` namespace</typeparam>
        /// <param name="requestBody">The request object</param>
        /// <param name="endpoint">The (optional) endpoint to append to the base url</param>
        /// <returns></returns>
        private TResponse HandleGenericAgGatewayRequest <TRequest, TResponse>(TRequest requestBody, string endpoint = null)
            where TRequest : class
            where TResponse : class
        {
            var request = new Generic.inboundData
            {
                messageId  = Guid.NewGuid().ToString(),
                xmlPayload = XmlUtility.Serialize(requestBody)
            };

            Generic.outboundData response;

            var endpointAddress = ClientUtility.BuildEndpointAddress(_baseUrl, endpoint);
            var binding         = ClientUtility.GetBinding(endpointAddress);

            using (var client = new Generic.DocExchangePortTypeClient(binding, endpointAddress))
            {
                response = _agGatewaySecurityProvider.ExecuteRequest(client, request, client.execute);
            }

            return(XmlUtility.Deserialize <TResponse>(response.xmlPayload[0]));
        }