示例#1
0
        /// <summary>
        /// Get the Shipping methods available for a shipment.
        /// The Cost and Expected Delivery Date are calculated in overture.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>The ShippingMethodsViewModel</returns>
        /// <remarks>This cannot be cached because Overture may include custom logic depending on the current cart state.</remarks>
        public virtual Task <List <FulfillmentMethod> > GetCalculatedFulfillmentMethods(GetShippingMethodsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CartName"), "param");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Scope"), "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CustomerId"), "param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CultureInfo"), "param");
            }

            var request = new FindCalculatedFulfillmentMethodsRequest
            {
                CartName   = param.CartName,
                CustomerId = param.CustomerId,
                ScopeId    = param.Scope,
                ShipmentId = param.ShipmentId
            };

            return(OvertureClient.SendAsync(request));
        }
示例#2
0
        public virtual Task <PaymentMethod> SetDefaultCustomerPaymentMethod(SetDefaultCustomerPaymentMethodParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param), "param is required");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("param.CustomerId is required", nameof(param.CustomerId));
            }
            if (param.PaymentMethodId == Guid.Empty)
            {
                throw new ArgumentException("param.PaymentMethodId is required", nameof(param.PaymentMethodId));
            }
            if (string.IsNullOrWhiteSpace(param.PaymentProviderName))
            {
                throw new ArgumentException("param.PaymentProviderName", nameof(param.PaymentProviderName));
            }
            if (string.IsNullOrWhiteSpace(param.ScopeId))
            {
                throw new ArgumentException("param.ScopeId is required", nameof(param.ScopeId));
            }

            var request = new SetDefaultCustomerPaymentMethodRequest
            {
                CustomerId          = param.CustomerId,
                Default             = true,
                PaymentMethodId     = param.PaymentMethodId,
                PaymentProviderName = param.PaymentProviderName,
                ScopeId             = param.ScopeId
            };

            return(OvertureClient.SendAsync(request));
        }
示例#3
0
        public virtual Task <Overture.ServiceModel.Orders.Order> CompleteCheckoutAsync(CompleteCheckoutParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param", "param");
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("param.CartName"), "param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CultureInfo"), "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CustomerId"), "param");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Scope"), "param");
            }

            var request = new CompleteCheckoutRequest
            {
                CartName    = param.CartName,
                CultureName = param.CultureInfo.Name,
                CustomerId  = param.CustomerId,
                ScopeId     = param.Scope
            };

            return(OvertureClient.SendAsync(request));
        }
示例#4
0
        public virtual async Task <Overture.ServiceModel.Customers.Stores.Store> GetStoreByNumberAsync(GetStoreParam param)
        {
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("scope");
            }
            if (string.IsNullOrWhiteSpace(param.StoreNumber))
            {
                throw new ArgumentException("storeNumber");
            }

            var cacheKey = new CacheKey(CacheConfigurationCategoryNames.Store)
            {
                Scope = param.Scope
            };

            cacheKey.AppendKeyParts(GETSTOREBYNUMBER_CACHE_KEYPART, param.StoreNumber);

            var request = new GetStoreByNumberRequest()
            {
                ScopeId          = param.Scope,
                Number           = param.StoreNumber,
                IncludeAddresses = param.IncludeAddresses,
                IncludeSchedules = param.IncludeSchedules
            };

            return(await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false));
        }
示例#5
0
        /// <summary>
        /// Sends instructions to the given email address on how to reset it's Customer's password
        /// </summary>
        /// <param name="param"></param>
        public virtual async Task SendResetPasswordInstructionsAsync(SendResetPasswordInstructionsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Email))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Email)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }

            var request = new ResetPasswordRequest
            {
                Email   = param.Email,
                ScopeId = param.Scope
            };

            var response = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            if (response.Success)
            {
                return;
            }

            throw new ComposerException(errorCode: "SendResetPasswordInstructionsFailed");
        }
示例#6
0
        /// <summary>
        /// Retrieve the detail about the status of Inventory Items represented by the specified InventoryLocationId and a list of skus for the specified date
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <List <InventoryItemAvailability> > FindInventoryItemStatus(FindInventoryItemStatusParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.Skus == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.Skus)), nameof(param));
            }
            if (param.Skus.Count == 0)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.Skus)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.InventoryLocationId))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.InventoryLocationId)), nameof(param));
            }

            var request = new FindInventoryItemStatusByLocationAndSkusRequest
            {
                Date = param.Date,
                InventoryLocationId = param.InventoryLocationId,
                ScopeId             = param.Scope,
                Skus = param.Skus
            };

            var result = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            return(result);
        }
        /// <summary>
        /// Retrieve the detail about the status of Inventory Items represented by the specified InventoryLocationId and a list of skus for the specified date
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <List <InventoryItemAvailability> > FindInventoryItemStatus(FindInventoryItemStatusParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Scope"), "param");
            }
            if (param.Skus == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Skus"), "param");
            }
            if (param.Skus.Count == 0)
            {
                throw new ArgumentException("Skus is empty", "param");
            }
            if (string.IsNullOrWhiteSpace(param.InventoryLocationId))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("InventoryLocationId"), "param");
            }

            var request = new FindInventoryItemStatusByLocationAndSkusRequest
            {
                Date = param.Date,
                InventoryLocationId = param.InventoryLocationId,
                ScopeId             = param.Scope,
                Skus = param.Skus
            };

            var result = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            return(result);
        }
示例#8
0
        public virtual Task <Payment> GetPaymentAsync(GetPaymentParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(ArgumentNullMessageFormatter.FormatErrorMessage(nameof(param)));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage(nameof(param.CustomerId)));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage(nameof(param.Scope)));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage(nameof(param.CultureInfo)));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage(nameof(param.CartName)));
            }

            var getPaymentRequest = new GetPaymentRequest
            {
                CustomerId  = param.CustomerId,
                CartName    = param.CartName,
                ScopeId     = param.Scope,
                CultureName = param.CultureInfo.Name,
                Id          = param.PaymentId
            };

            return(OvertureClient.SendAsync(getPaymentRequest));
        }
        /// <summary>
        /// Obtains a scope description from Overture including the currency of the scope, but not its children.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual Task <Scope> GetScopeAsync(GetScopeParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("Scope is required", nameof(param.Scope));
            }

            var key = new CacheKey(CacheConfigurationCategoryNames.Scopes, param.Scope);

            var scope = CacheProvider.GetOrAddAsync(key, async() =>
            {
                var req = new GetScopeRequest
                {
                    ScopeId         = param.Scope,
                    IncludeCurrency = true,
                    IncludeChildren = false,
                    CultureName     = null
                };

                var response = await OvertureClient.SendAsync(req).ConfigureAwait(false);
                return(response);
            });

            return(scope);
        }
示例#10
0
        /// <summary>
        /// Get line items of a cart of a customer
        /// </summary>
        /// <param name="param"></param>
        /// <returns>Line items of a cart</returns>
        public virtual Task <List <LineItem> > GetLineItemsAsync(GetLineItemsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }

            GetLineItemsInCartRequest request = new GetLineItemsInCartRequest
            {
                CultureName = param.CultureInfo.Name,
                CustomerId  = param.CustomerId,
                ScopeId     = param.Scope,
                CartName    = param.CartName,
                CartType    = param.CartType
            };

            //Avoid caching because of returning with type of line items
            return(OvertureClient.SendAsync(request));
        }
示例#11
0
        public virtual Task <Overture.ServiceModel.Orders.Order> CompleteCheckoutAsync(CompleteCheckoutParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }

            var request = new CompleteCheckoutRequest
            {
                CartName    = param.CartName,
                CultureName = param.CultureInfo.Name,
                CustomerId  = param.CustomerId,
                ScopeId     = param.Scope
            };

            return(OvertureClient.SendAsync(request));
        }
示例#12
0
        /// <summary>
        /// Retrieves the list of carts belonging to a customer
        ///
        /// param.IncludeChildScopes is optional
        /// A value indicating whether to include carts found in child scopes.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>List of Cart Summaries</returns>
        public virtual Task <List <CartSummary> > GetCartsByCustomerIdAsync(GetCartsByCustomerIdParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }

            var request = new GetCartsByCustomerIdRequest
            {
                CultureName        = param.CultureInfo.Name,
                CustomerId         = param.CustomerId,
                ScopeId            = param.Scope,
                IncludeChildScopes = param.IncludeChildScopes,
                CartType           = param.CartType
            };

            return(OvertureClient.SendAsync(request));
        }
示例#13
0
        /// <summary>
        /// Delete a cart
        /// </summary>
        /// <param name="param">Parameters to be used for deleting</param>
        /// <returns>Http web response of deleting operation</returns>
        public virtual async Task <HttpWebResponse> DeleteCartAsync(DeleteCartParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }

            DeleteCartRequest request = new DeleteCartRequest
            {
                CartName    = param.CartName,
                CultureName = param.CultureInfo.Name,
                CustomerId  = param.CustomerId,
                ScopeId     = param.Scope
            };
            CacheKey cacheKey = BuildCartCacheKey(param.Scope, param.CustomerId, param.CartName);
            await CacheProvider.RemoveAsync(cacheKey);

            return(await OvertureClient.SendAsync(request));
        }
示例#14
0
        public virtual async Task <ListOfRecurringOrderLineItems> UpdateRecurringOrderTemplateLineItemAsync(UpdateRecurringOrderTemplateLineItemParam param)
        {
            var lineitems = await GetRecurringOrderTemplates(param.ScopeId, param.CustomerId).ConfigureAwait(false);

            var lineitem = GetRecurringOrderLineItemFromTemplates(lineitems, param.LineItemId);

            if (lineitem != null)
            {
                lineitem.RecurringOrderFrequencyName = param.RecurringOrderFrequencyName;

                var nextOccurenceWithTime = lineitem.NextOccurence;
                var newDate = new DateTime(param.NextOccurence.Year, param.NextOccurence.Month, param.NextOccurence.Day,
                                           nextOccurenceWithTime.Hour, nextOccurenceWithTime.Minute, nextOccurenceWithTime.Second, DateTimeKind.Utc);

                lineitem.NextOccurence     = newDate;
                lineitem.ShippingAddressId = param.ShippingAddressId.ToGuid();
                lineitem.BillingAddressId  = param.BillingAddressId.ToGuid();
                lineitem.PaymentMethodId   = param.PaymentMethodId.ToGuid();

                lineitem.ShippingProviderId    = param.ShippingProviderId.ToGuid();
                lineitem.FulfillmentMethodName = param.ShippingMethodName;

                var request = new AddOrUpdateRecurringOrderLineItemsRequest()
                {
                    CustomerId = param.CustomerId,
                    MustApplyUpdatesToRecurringCart = true,
                    ScopeId   = param.ScopeId,
                    LineItems = lineitems.RecurringOrderLineItems
                };

                return(await OvertureClient.SendAsync(request));
            }

            return(new ListOfRecurringOrderLineItems());
        }
示例#15
0
        /// <summary>
        /// Update order with current id.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual Task <Overture.ServiceModel.Orders.Order> UpdateOrderAsync(UpdateOrderParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.OrderId == default)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.OrderId)));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)));
            }
            if (param.Order == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.Order)));
            }

            var request = new SaveOrderRequest
            {
                ScopeId = param.Scope,
                OrderId = param.OrderId,
                Order   = param.Order,
            };

            return(OvertureClient.SendAsync(request));
        }
示例#16
0
        /// <summary>
        /// Create a cart draft of some order
        /// </summary>
        /// <param name="orderId">Id of the order</param>
        /// <returns>Cart draft</returns>
        public Task <ProcessedCart> CreateCartOrderDraft(CreateCartOrderDraftParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.OrderId == default)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.OrderId)));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)));
            }
            if (param.CustomerId == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CustomerId)));
            }

            var request = new CreateCartOrderDraftRequest
            {
                CultureName = param.CultureInfo.Name,
                CustomerId  = param.CustomerId,
                OrderId     = param.OrderId,
                ScopeId     = param.Scope
            };

            return(OvertureClient.SendAsync(request));
        }
示例#17
0
        /// <summary>
        /// Gets an Order by number.
        /// </summary>
        /// <param name="param">The get order parameter.</param>
        /// <returns></returns>
        public virtual Task <Overture.ServiceModel.Orders.Order> GetOrderAsync(GetOrderParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.OrderNumber))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.OrderNumber)), nameof(param));
            }

            var request = new GetOrderByNumberRequest
            {
                ScopeId          = param.Scope,
                OrderNumber      = param.OrderNumber,
                IncludeShipment  = true,
                IncludeLineItems = true,
                IncludePayment   = true
            };

            return(OvertureClient.SendAsync(request));
        }
示例#18
0
        /// <summary>
        /// Change ownership of an order draft to the requested user and revert pending changes to the original order cart when required.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual Task <ProcessedCart> ChangeOwnership(ChangeOrderDraftOwnershipParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.OrderId == default)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.OrderId)));
            }
            if (param.CustomerId == default)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)));
            }
            if (param.Scope == default)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.Scope)));
            }

            var request = new ChangeOwnershipCartOrderDraftRequest()
            {
                ScopeId              = param.Scope,
                CustomerId           = param.CustomerId,
                OrderId              = param.OrderId,
                RevertPendingChanges = param.RevertPendingChanges,
                CultureName          = param.CultureName
            };

            return(OvertureClient.SendAsync(request));
        }
        public virtual async Task <SearchQueryResult> SearchQueryProductAsync(SearchQueryProductParams param)
        {
            var criteria = param.Criteria;
            var request  = GerSearchQueryRequest(param);

            request.Query.IncludeTotalCount = true;
            request.Query.MaximumItems      = criteria.NumberOfItemsPerPage;
            request.Query.StartingIndex     = (criteria.Page - 1) * criteria.NumberOfItemsPerPage;
            request.CultureName             = criteria.CultureInfo.Name;
            request.SearchTerms             = criteria.Keywords;
            request.ScopeId         = criteria.Scope;
            request.IncludeFacets   = criteria.IncludeFacets;
            request.Facets          = GetFacetFieldNameToQuery(criteria);
            request.FacetPredicates = BuildFacetPredicates(criteria);
            request.AutoCorrect     = criteria.AutoCorrect;
            var sortDefinitions = BuildQuerySortings(criteria);

            if (sortDefinitions != null)
            {
                request.Query.Sortings.Add(sortDefinitions);
            }

            var result = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            return(result);
        }
示例#20
0
        public virtual Task <HttpWebResponse> DeleteCartOrderDraft(DeleteCartOrderDraftParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.OrderId == default)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.OrderId)));
            }
            if (param.CustomerId == default)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)));
            }

            var request = new DeleteCartOrderDraftRequest()
            {
                ScopeId    = param.Scope,
                CustomerId = param.CustomerId,
                OrderId    = param.OrderId
            };

            return(OvertureClient.SendAsync(request));
        }
        /// <summary>
        /// Retrieve a list of InventoryItemStatusDetails represented by sku from all inventory location associated to the specific scope. The list of inventory location ids is all existing Fulfillment Locations inside the specific Scope
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <InventoryItemStatusDetailsQueryResult> GetInventoryItemsBySkuAsync(GetInventoryItemsBySkuParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Scope"), "param");
            }
            if (param.Sku == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Sku"), "param");
            }

            var cacheKey = new CacheKey(CacheConfigurationCategoryNames.StoreInventoryItems)
            {
                Scope = param.Scope
            };

            cacheKey.AppendKeyParts("sku", param.Sku);

            var request = new GetInventoryItemsByScopeAndSkuRequest
            {
                Date               = param.Date,
                Sku                = param.Sku,
                ScopeId            = param.Scope,
                IncludeChildScopes = param.IncludeChildScopes
            };

            return(await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false));
        }
示例#22
0
        public virtual Task <OrderFulfillmentState> ChangeShipmentStatusAsync(ChangeShipmentStatusParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.ScopeId))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.ScopeId)), nameof(param));
            }
            if (param.OrderId == default)
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.OrderId)), nameof(param));
            }
            if (param.RequestedStatus == default)
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.RequestedStatus)), nameof(param));
            }

            var request = new ChangeShipmentStatusRequest()
            {
                ScopeId         = param.ScopeId,
                OrderId         = param.OrderId,
                ShipmentId      = param.ShipmentId,
                Reason          = param.Reason,
                RequestedStatus = param.RequestedStatus
            };

            return(OvertureClient.SendAsync(request));
        }
示例#23
0
        public virtual async Task <FulfillmentSchedule> GetStoreScheduleAsync(GetStoreScheduleParam param)
        {
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("scope");
            }
            if (param.FulfillmentLocationId == null)
            {
                throw new ArgumentException("fulfillmentLocationId");
            }

            var cacheKey = new CacheKey(CacheConfigurationCategoryNames.StoreSchedule)
            {
                Scope = param.Scope
            };

            cacheKey.AppendKeyParts(param.FulfillmentLocationId.ToString());

            var request = new GetScheduleRequest
            {
                ScopeId = param.Scope,
                FulfillmentLocationId = param.FulfillmentLocationId,
                ScheduleType          = ScheduleType.OpeningHours
            };

            return
                (await
                 CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false));
        }
示例#24
0
        public virtual Task <OrderFulfillmentState> AddShipmentFulfillmentMessagesAsync(AddShipmentFulfillmentMessagesParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.ScopeId))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.ScopeId)), nameof(param));
            }
            if (param.OrderId == default)
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.OrderId)), nameof(param));
            }

            var request = new AddShipmentFulfillmentMessagesRequest()
            {
                ScopeId           = param.ScopeId,
                OrderId           = param.OrderId,
                ShipmentId        = param.ShipmentId,
                ExecutionMessages = param.ExecutionMessages ?? new List <ExecutionMessage>(),
                ValidationResults = param.ValidationResults ?? new List <ValidationResult>()
            };

            return(OvertureClient.SendAsync(request));
        }
示例#25
0
        /// <summary>
        /// Resets the password for a customer
        /// This will change the password without actually needing the current password at all.
        /// and is part of the ForgotPassword process
        /// </summary>
        /// <getCustomerByIdParam name="username">The unique login Name of the customer to reset</getCustomerByIdParam>
        /// <getCustomerByIdParam name="newPassword">The new password to set</getCustomerByIdParam>
        /// <getCustomerByIdParam name="passwordAnswer">The answer to the password question</getCustomerByIdParam>
        public virtual async Task ResetPasswordAsync(string username, string scopeId, string newPassword, string passwordAnswer)
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(), nameof(username));
            }
            if (string.IsNullOrWhiteSpace(newPassword))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(), nameof(newPassword));
            }

            var request = new ResetPasswordRequest
            {
                Username       = username,
                Password       = newPassword,
                PasswordAnswer = passwordAnswer,
                ScopeId        = scopeId
            };

            var response = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            if (response.Success)
            {
                return;
            }

            throw new ComposerException(errorCode: "ResetPasswordFailed");
        }
        public virtual Task <List <PaymentMethod> > GetCustomerPaymentMethodForProviderAsync(GetCustomerPaymentMethodsForProviderParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.ScopeId))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.ScopeId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.ProviderName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.ProviderName)), nameof(param));
            }

            var getCustomerPaymentMethodsRequest = new GetCustomerPaymentMethodsRequest
            {
                CustomerId          = param.CustomerId,
                PaymentProviderName = param.ProviderName,
                ScopeId             = param.ScopeId
            };

            return(OvertureClient.SendAsync(getCustomerPaymentMethodsRequest));
        }
示例#27
0
        /// <summary>
        /// Retrieves the list of carts belonging to a customer
        ///
        /// param.IncludeChildScopes is optional
        /// A value indicating whether to include carts found in child scopes.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>List of Cart Summaries</returns>
        public virtual Task <List <CartSummary> > GetCartsByCustomerIdAsync(GetCartsByCustomerIdParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param", "param is required");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("param.Scope is required", "param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException("param.CultureInfo is required", "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("param.CustomerId is required", "param");
            }

            var request = new GetCartsByCustomerIdRequest
            {
                CultureName        = param.CultureInfo.Name,
                CustomerId         = param.CustomerId,
                ScopeId            = param.Scope,
                IncludeChildScopes = param.IncludeChildScopes,
            };

            return(OvertureClient.SendAsync(request));
        }
        /// <summary>
        /// Gets all payments hold by a cart.
        /// </summary>
        /// <param name="param">Parameters used to make the query.</param>
        /// <returns>A list of Payments.</returns>
        public virtual Task <List <Payment> > GetCartPaymentsAsync(GetCartPaymentsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }

            var request = new GetPaymentsInCartRequest
            {
                CartName    = param.CartName,
                CultureName = param.CultureInfo.Name,
                CustomerId  = param.CustomerId,
                ScopeId     = param.Scope
            };

            return(OvertureClient.SendAsync(request));
        }
示例#29
0
        /// <summary>
        /// Get the Shipping methods available for a shipment.
        /// The Cost and Expected Delivery Date are calculated in overture.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>The ShippingMethodsViewModel</returns>
        /// <remarks>This cannot be cached because Overture may include custom logic depending on the current cart state.</remarks>
        public virtual Task <List <FulfillmentMethod> > GetCalculatedFulfillmentMethods(GetShippingMethodsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }

            var request = new FindCalculatedFulfillmentMethodsRequest
            {
                CartName   = param.CartName,
                CustomerId = param.CustomerId,
                ScopeId    = param.Scope,
                ShipmentId = param.ShipmentId
            };

            return(OvertureClient.SendAsync(request));
        }
示例#30
0
        /// <summary>
        /// Update preferred store of a customer
        /// </summary>
        /// <param name="param">Parameters container</param>
        /// <returns>The updated customer</returns>
        public virtual async Task <Customer> UpdateUserPreferredStoreAsync(UpdateUserPreferredStoreParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.ScopeId))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.ScopeId)), nameof(param));
            }
            if (param.StoreId == Guid.Empty && string.IsNullOrWhiteSpace(param.StoreNumber))
            {
                throw new ArgumentException($"Both {nameof(param.StoreId)} and {nameof(param.StoreNumber)} are null or empty", nameof(param));
            }

            var request = new UpdatePreferredStoreRequest
            {
                ScopeId     = param.ScopeId.ToString(),
                StoreId     = param.StoreId,
                StoreNumber = param.StoreNumber,
                CustomerId  = param.CustomerId
            };

            var updatedCustomer = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            return(updatedCustomer);
        }