public CompanyContactsResponse CompanyContacts(CompanyContactsRequest request)
        {
            var payLoad = new PartnerLookupRequestRoot(request);
            var backup  = new BackupLogEntry(payLoad, nameof(CompanyContacts));

            LogRequest(payLoad, nameof(CompanyContacts));
            var result = _erpApi.PartnerLookupPost(payLoad);

            if (result.PARTNERS_OUT == null || result.ADDRESS_OUT == null)
            {
                var companyContactsResponse = new CompanyContactsResponse
                {
                    Error = new Error {
                        Description = "Last name provided not found in this Hiearchy"
                    }
                };
                return(companyContactsResponse);
            }
            var companyContactResponse = result.ToCompanyContactsResponse(request.Name);

            backup.AddResponse(companyContactResponse);
            _repository.InsertOne(backup);
            LogResponse(companyContactResponse);
            return(companyContactResponse);
        }
        public ShippingNotificationResponse SendShippingNotifications(ShippingNotification request)
        {
            var payLoad = new ShippingNotificationOrderDto(request);
            var backup  = new BackupLogEntry(payLoad, nameof(SendShippingNotifications));
            var shippingNotification = new ShippingNotificationResponse();

            LogRequest(payLoad, nameof(SendShippingNotifications));
            try
            {
                var result = _atgOrderApi.SendShippingNotifications(payLoad);
                backup.AddResponse(result);
                _repository.InsertOne(backup);
                LogResponse(result);
                if (string.IsNullOrEmpty(result))
                {
                    shippingNotification.EmailSent    = false;
                    shippingNotification.ErrorMessage = "Server Error communcating with notification service.";
                }
                shippingNotification.EmailSent = Boolean.Parse(result);
            }
            catch (Exception ex)
            {
                shippingNotification.EmailSent    = false;
                shippingNotification.ErrorMessage = ex.Message;
            }

            return(shippingNotification);
        }
Beispiel #3
0
        /// <summary>
        /// Price Request/Response
        /// </summary>
        /// <param name="priceWmRequest"></param>
        /// <returns></returns>
        public PriceResponse GetPrice(PriceRequest priceWmRequest)
        {
            var priceResponse = new PriceResponse();
            var request       = priceWmRequest.ToWmPriceRequest();
            var backup        = new BackupLogEntry(request, "PriceRequest");

            LogRequest(request, "PriceRequest");
            var wmPriceResponse = _soapStoreFrontWebService.PriceWebServiceAsync(request).Result;

            backup.AddResponse(wmPriceResponse);
            _repository.InsertOne(backup);
            LogResponse(wmPriceResponse);

            var failedProducts = new List <FailedProduct>();

            while (wmPriceResponse.ErrorReturn != null)
            {
                var productId = GetProductFromMaterialErrorMessage(wmPriceResponse.ErrorReturn.Error);
                if (productId == Empty)
                {
                    priceResponse.ErrorMessage = wmPriceResponse.ErrorReturn.Error;
                    return(priceResponse);
                }

                Log($"{ErrorMessages.ERRORS_CONTAINED_IN_RESPONSE} for product {productId}");

                var failedProduct = new FailedProduct {
                    ErrorMessage = wmPriceResponse.ErrorReturn.Error, PartNumber = productId
                };
                failedProducts.Add(failedProduct);

                var newProductLists = request.PricingRequest.ProductList.Where(val => val.ProductID != productId).ToArray();
                //I don't see why or how this will be needed (if no edge case is reported by 1/1/2020, remove this line altogether)
                //if (newProductLists.Length == request.PricingRequest.ProductList.Length) break;

                request.PricingRequest.ProductList = newProductLists;
                if (newProductLists.Length == 0)
                {
                    break;
                }

                Log(InfoMessages.SEND_DATA_CORRECTED_INPUT_REQUEST);
                var backup2 = new BackupLogEntry(request, "PriceRequest");
                LogRequest(request, "Additional PriceRequests (to handle failed products)");
                wmPriceResponse = _soapStoreFrontWebService.PriceWebServiceAsync(request).Result;
                backup2.AddResponse(wmPriceResponse);
                _repository.InsertOne(backup2);
                LogResponse(wmPriceResponse);
            }

            priceResponse = wmPriceResponse.ToPriceResponse();

            if (failedProducts.Count == 0)
            {
                return(priceResponse);
            }
            priceResponse.FailedProducts = failedProducts;
            priceResponse.ErrorMessage   = "We were not able to obtain prices for all requested products.  Please see list of failed products.";
            return(priceResponse);
        }
        public SimulateOrderErpResponse SimulateOrder(SimulateOrderErpRequest request)
        {
            var payLoad = new SimulateOrderRequestRoot(request);
            var backup  = new BackupLogEntry(payLoad, nameof(SimulateOrder));

            LogRequest(payLoad, nameof(SimulateOrder));
            var result = _erpApi.SimulateOrderPost(payLoad);

            backup.AddResponse(result);
            _repository.InsertOne(backup);
            LogResponse(result);
            return(result.ToResponse());
        }
        public ContactCreateClientResponse CreateContact(ContactCreateClientRequest request)
        {
            var payLoad = new ContactCreateWebServiceRequest(request);
            var backup  = new BackupLogEntry(payLoad, nameof(CreateContact));

            LogRequest(payLoad, nameof(CreateContact));
            var result = ExecuteCall <ContactCreateWebServiceResponse>(_erpRestSettings.BaseUrl, _erpRestSettings.GetContactCreateRequest, payLoad);

            backup.AddResponse(result);
            _repository.InsertOne(backup);
            LogResponse(result);
            return(result.ToResponse());
        }
Beispiel #6
0
        //Temporarily bringing this back for comparision with the new Boomi version
        public PartnerResponse GetPartnerDetails(SimplePartnerRequest partnerRequest)
        {
            var request = partnerRequest.ToWmPartnerRequest();
            var backup  = new BackupLogEntry(request, nameof(GetPartnerDetails));

            LogRequest(request, nameof(GetPartnerDetails));
            var wmPartnerResponse = _soapStoreFrontWebService.PartnerWebServiceAsync(request).Result;

            backup.AddResponse(wmPartnerResponse);
            _repository.InsertOne(backup);
            LogResponse(wmPartnerResponse);
            return(wmPartnerResponse.ToPartnerResponse());
        }
        public CompanyInfoResponse CompanyInfo(CompanyInfoRequest request)
        {
            var payLoad = new PartnerLookupRequestRoot(request);
            var backup  = new BackupLogEntry(payLoad, nameof(CompanyInfo));

            LogRequest(payLoad, nameof(CompanyInfo));
            var result = _erpApi.PartnerLookupPost(payLoad);
            var companyInfoResponse = result.ToCompanyInfoResponse();

            backup.AddResponse(companyInfoResponse);
            _repository.InsertOne(backup);
            LogResponse(companyInfoResponse);
            return(companyInfoResponse);
        }
        public CompanyAddressesResponse CompanyAddresses(CompanyAddressesRequest request)
        {
            var payLoad = new PartnerLookupRequestRoot(request);
            var backup  = new BackupLogEntry(payLoad, nameof(CompanyAddresses));

            LogRequest(payLoad, "CompanyAddresses");
            var result = _erpApi.PartnerLookupPost(payLoad);
            var companyAddressResponse = result.ToCompanyAddressesResponse(request.ShipTo, request.BillTo);

            backup.AddResponse(companyAddressResponse);
            _repository.InsertOne(backup);
            LogResponse(companyAddressResponse);
            return(companyAddressResponse);
        }
        public PartnerResponse SimplePartnerLookup(SimplePartnerRequest request)
        {
            var payLoad = new PartnerLookupRequestRoot(request);
            var backup  = new BackupLogEntry(payLoad, nameof(SimplePartnerLookup));

            LogRequest(payLoad, nameof(SimplePartnerLookup));
            var result          = _erpApi.PartnerLookupPost(payLoad);
            var partnerResponse = result.ToPartnerResponse();

            backup.AddResponse(partnerResponse);
            _repository.InsertOne(backup);
            LogResponse(partnerResponse);
            return(partnerResponse);
        }
Beispiel #10
0
        public InventoryResponse GetInventory(InventoryRequest inventoryWmRequest)
        {
            var inventoryResponse = new InventoryResponse();
            var request           = inventoryWmRequest.ToWmInventoryRequest();
            var backup            = new BackupLogEntry(request, nameof(GetInventory));

            LogRequest(request, nameof(GetInventory));
            var wmInventoryResponse = _soapStoreFrontWebService.InventoryWebServiceAsync(request).Result;

            backup.AddResponse(wmInventoryResponse);
            _repository.InsertOne(backup);
            LogResponse(wmInventoryResponse);

            var failedInventoryItems = new List <FailedItem>();

            while (wmInventoryResponse.ErrorResponse != null)
            {
                var errorMessage = wmInventoryResponse.ErrorResponse.ErrorResponse1.Body[0].Error;
                var productId    = LogFailedItem(failedInventoryItems, errorMessage);

                if (productId == Empty)
                {
                    inventoryResponse.FailedItems  = failedInventoryItems;
                    inventoryResponse.ErrorMessage = "We were not able to obtain response items for all requested products.  Please see list of failed inventory items.";
                    return(inventoryResponse);
                }

                var newItemsList = request.InventoryRequest.InventoryRequestDetail.Where(val => val.ProductID != productId).ToArray();
                request.InventoryRequest.InventoryRequestDetail = newItemsList;
                if (newItemsList.Length == 0)
                {
                    break;
                }
                var backup2 = new BackupLogEntry(request, "Additional GetInventory (to handle failed products");
                LogRequest(request, "Additional GetInventory (to handle failed products");
                wmInventoryResponse = _soapStoreFrontWebService.InventoryWebServiceAsync(request).Result;
                backup2.AddResponse(wmInventoryResponse);
                _repository.InsertOne(backup2);
                LogResponse(wmInventoryResponse);
            }

            inventoryResponse = wmInventoryResponse.ToInventoryResponse();
            if (failedInventoryItems.Count == 0)
            {
                return(inventoryResponse);
            }
            inventoryResponse.FailedItems  = failedInventoryItems;
            inventoryResponse.ErrorMessage = "We were not able to obtain response items for all requested products.  Please see list of failed inventory items.";
            return(inventoryResponse);
        }
Beispiel #11
0
        public SimulateOrderResponse SimulateOrder(SimulateOrderRequest simulateOrderRequest)
        {
            var endPoint = _soapStoreFrontWebService.ToString();
            var request  = simulateOrderRequest.ToWmSimulateOrderRequest();
            var backup   = new BackupLogEntry(request, nameof(SimulateOrder));

            LogRequest(request, nameof(SimulateOrder));
            var wmSimulateOrderResponse = _soapStoreFrontWebService.SimulateOrderWebServiceAsync(request).Result;
            var orderResponseError      = "We were not able to obtain response items for all requested products.  Please see list of failed inventory items.";

            backup.AddResponse(wmSimulateOrderResponse);
            _repository.InsertOne(backup);
            LogResponse(wmSimulateOrderResponse);
            var failedItems = new List <FailedItem>();

            while (ContainsSAPError(wmSimulateOrderResponse))
            {
                var    errorMessage = wmSimulateOrderResponse.ErrorResponse.ErrorResponse1.Body[0].Error;
                string productId    = LogFailedItem(failedItems, errorMessage);

                //if we have an error condition but no failed products, we have an order order level issue, we can return
                if (productId == Empty)
                {
                    failedItems.Clear();
                    var failedItem = new FailedItem {
                        ErrorMessage = errorMessage, ProductId = "Order Level Exception, not applicable"
                    };
                    failedItems.Add(failedItem);
                    var orderLevelFailureResponse = new SimulateOrderResponse
                    {
                        FailedItems  = failedItems,
                        ErrorMessage = "We were not able to obtain response items for all requested products.Please see list of failed inventory items."
                    };
                    return(orderLevelFailureResponse);
                }

                var newItemsList = request.OrderRequest.OrderRequest.Body[0].OrderRequestDetail.Where(val => val.ProductID != productId).ToArray();
                request.OrderRequest.OrderRequest.Body[0].OrderRequestDetail = newItemsList;

                //We had an error condition for a single product .. we need to collect that error and return
                if (newItemsList.Length == 0)
                {
                    var orderLevelFailureResponse = new SimulateOrderResponse
                    {
                        FailedItems  = failedItems,
                        ErrorMessage = orderResponseError
                    };
                    return(orderLevelFailureResponse);
                }
                var backup2 = new BackupLogEntry(request, "Addtional SimulateOrder (to handle failed products");
                LogRequest(request, "Additional SimulateOrder (to handle failed products");
                wmSimulateOrderResponse = _soapStoreFrontWebService.SimulateOrderWebServiceAsync(request).Result;
                backup2.AddResponse(wmSimulateOrderResponse);
                _repository.InsertOne(backup2);
                LogResponse(wmSimulateOrderResponse);
            }

            var simulateOrderResponse = wmSimulateOrderResponse.ToSimulateOrderResponse();

            if (failedItems.Count == 0)
            {
                return(simulateOrderResponse);
            }
            simulateOrderResponse.FailedItems  = failedItems;
            simulateOrderResponse.ErrorMessage = orderResponseError;
            return(simulateOrderResponse);
        }