Exemplo n.º 1
0
        /// <summary>
        /// Order placement date/time (lower bound). Supported formats:
        /// <list type="bullet">
        ///     <item>
        ///         <description>UNIX timestamp</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd HH:mm:ss Z</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd HH:mm:ss</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd</description>
        ///     </item>
        /// </list>
        /// Examples:
        /// <list type="bullet">
        ///     <item>
        ///         <description>"1447804800"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22 18:48:38 -0500"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22 18:48:38"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22" (this is 2015-04-22 00:00:00 UTC)</description>
        ///     </item>
        /// </list>
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="dateFrom">The date from.</param>
        /// <exception cref="ArgumentException"><paramref name="dateFrom" /> string is null or empty.</exception>
        /// <exception cref="ArgumentException"><paramref name="dateFrom" /> string is invalid.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> CreatedFrom(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string dateFrom)
        {
            if (Validators.ValidateDateTime(dateFrom))
            {
                query.AddOrUpdate("createdFrom", dateFrom);
            }

            return(query);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Order update date/time (upper bound). Supported formats:
        /// <list type="bullet">
        ///     <item>
        ///         <description>UNIX timestamp</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd HH:mm:ss Z</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd HH:mm:ss</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd</description>
        ///     </item>
        /// </list>
        /// Examples:
        /// <list type="bullet">
        ///     <item>
        ///         <description>"1447804800"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22 18:48:38 -0500"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22 18:48:38"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22" (this is 2015-04-22 00:00:00 UTC)</description>
        ///     </item>
        /// </list>
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="dateTo">The date to.</param>
        /// <exception cref="ArgumentException"><paramref name="dateTo" /> string is null or empty.</exception>
        /// <exception cref="ArgumentException"><paramref name="dateTo" /> string is invalid.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> UpdatedTo(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string dateTo)
        {
            if (Validators.ValidateDateTime(dateTo))
            {
                query.AddOrUpdate("updatedTo", dateTo);
            }

            return(query);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Customer search term (searches by customer).
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="customer">The customer.</param>
        /// <exception cref="ArgumentException"><paramref name="customer" /> is null or empty.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> Customer(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string customer)
        {
            if (string.IsNullOrEmpty(customer))
            {
                throw new ArgumentException("Customer is null or empty.", nameof(customer));
            }

            query.AddOrUpdate("customer", customer);
            return(query);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Set query parameter "total to".
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="totalTo">The total to.</param>
        /// <exception cref="ArgumentException"><paramref name="totalTo" /> must be greater than 0.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> TotalTo(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, double totalTo)
        {
            if (totalTo <= 0)
            {
                throw new ArgumentException("TotalTo must be greater than 0.", nameof(totalTo));
            }

            query.AddOrUpdate("totalTo", totalTo);
            return(query);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Set query parameter "specified number".
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="number">The ordinary order number</param>
        /// <exception cref="ArgumentException"><paramref name="number" /> must be greater than 0.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> Order(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, int number)
        {
            if (number <= 0)
            {
                throw new ArgumentException("Number must be greater than 0.", nameof(number));
            }

            query.AddOrUpdate("orderNumber", number);
            return(query);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Search term. Ecwid will look for this term in order number, ordered items and customer details.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="keywords">The keywords.</param>
        /// <exception cref="ArgumentException"><paramref name="keywords" /> is null or empty.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> Keywords(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string keywords)
        {
            if (string.IsNullOrEmpty(keywords))
            {
                throw new ArgumentException("Keywords is null or empty.", nameof(keywords));
            }

            query.AddOrUpdate("keywords", keywords);
            return(query);
        }
Exemplo n.º 7
0
        /// <summary>
        /// The code of coupon applied to order.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="couponCode">The order coupon code number</param>
        /// <exception cref="ArgumentException"><paramref name="couponCode" /> must be greater than 0.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> CouponCode(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, int couponCode)
        {
            if (couponCode <= 0)
            {
                throw new ArgumentException("Coupon code must be greater than 0.", nameof(couponCode));
            }

            query.AddOrUpdate("couponCode", couponCode);
            return(query);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Shipping method used by customer.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="shippingMethod">The payment method.</param>
        /// <exception cref="ArgumentException"><paramref name="shippingMethod" /> is null or empty.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> ShippingMethod(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string shippingMethod)
        {
            if (string.IsNullOrEmpty(shippingMethod))
            {
                throw new ArgumentException("ShippingMethod is null or empty.", nameof(shippingMethod));
            }

            query.AddOrUpdate("shippingMethod", shippingMethod);
            return(query);
        }
        /// <summary>
        /// Payment method used by customer.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="paymentMethod">The payment method.</param>
        /// <exception cref="ArgumentException"><paramref name="paymentMethod" /> is null or empty.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> PaymentMethod(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string paymentMethod)
        {
            if (string.IsNullOrWhiteSpace(paymentMethod))
            {
                throw new ArgumentException("PaymentMethod is null or empty.", nameof(paymentMethod));
            }

            query.AddOrUpdate("paymentMethod", paymentMethod);
            return(query);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Set query parameter "specified vendor number".
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="vendorNumber">The vendor order number (order number with prefix/suffix)</param>
        /// <exception cref="ArgumentException"><paramref name="vendorNumber" /> is null or empty.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> Order(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string vendorNumber)
        {
            if (string.IsNullOrEmpty(vendorNumber))
            {
                throw new ArgumentException("VendorNumber is null or empty.", nameof(vendorNumber));
            }

            query.AddOrUpdate("vendorOrderNumber", vendorNumber);
            return(query);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Order update date/time (lower and upper bounds). Supported formats:
        /// <list type="bullet">
        ///     <item>
        ///         <description>UNIX timestamp</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd HH:mm:ss Z</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd HH:mm:ss</description>
        ///     </item>
        ///     <item>
        ///         <description>yyyy-MM-dd</description>
        ///     </item>
        /// </list>
        /// Examples:
        /// <list type="bullet">
        ///     <item>
        ///         <description>"1447804800"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22 18:48:38 -0500"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22 18:48:38"</description>
        ///     </item>
        ///     <item>
        ///         <description>"2015-04-22" (this is 2015-04-22 00:00:00 UTC)</description>
        ///     </item>
        /// </list>
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="dateFrom">The date from.</param>
        /// <param name="dateTo">The date from.</param>
        /// <exception cref="ArgumentException"><paramref name="dateFrom" /> or <paramref name="dateTo" /> string is null or empty.</exception>
        /// <exception cref="ArgumentException"><paramref name="dateFrom" /> or <paramref name="dateTo" /> string is invalid.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> Updated(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string dateFrom, string dateTo)
        {
            // ReSharper disable once InvertIf
            if (Validators.ValidateDateTime(dateFrom) && Validators.ValidateDateTime(dateTo))
            {
                query.AddOrUpdate("updatedFrom", dateFrom);
                query.AddOrUpdate("updatedTo", dateTo);
            }

            return(query);
        }
Exemplo n.º 12
0
        /// <summary>
        /// How many orders skip from beginning.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="offset">The offset.</param>
        /// <exception cref="ArgumentException"><paramref name="offset" /> must be greater than 0.</exception>
        public static OrdersQueryBuilder <TOrder, TUpdateResponse> Offset <TOrder, TUpdateResponse>(
            this OrdersQueryBuilder <TOrder, TUpdateResponse> query, int offset)
            where TOrder : BaseOrder
            where TUpdateResponse : class
        {
            if (offset <= 0)
            {
                throw new ArgumentException("Offset must be greater than 0.", nameof(offset));
            }

            query.AddOrUpdate("offset", offset);
            return(query);
        }
        /// <summary>
        /// Order update date/time (upper bound).
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="dateTo">The date from.</param>
        /// <exception cref="ArgumentException"><paramref name="dateTo" /> is invalid.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> UpdatedTo(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, DateTime dateTo)
        {
            try
            {
                query.AddOrUpdate("updatedTo", dateTo.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            catch (Exception exception)
            {
                throw new ArgumentException("Date is invalid.", nameof(dateTo), exception);
            }

            return(query);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Add fulfillment comma or space separated status names.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="fulfillmentStatuses">
        /// Fulfillment statuses: AWAITING_PROCESSING, PROCESSING, SHIPPED, DELIVERED, WILL_NOT_DELIVER, RETURNED.
        /// </param>
        /// <exception cref="EcwidConfigException">Can not add or update statuses. Look inner exception.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> FulfillmentStatuses(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, string fulfillmentStatuses)
        {
            try
            {
                Validators.StatusesValidate(fulfillmentStatuses, Validators.AvailableFulfillmentStatuses);

                query.AddOrUpdateStatuses("fulfillmentStatus", fulfillmentStatuses.TrimUpperReplaceSplit());
            }
            catch (ArgumentException exception)
            {
                throw new EcwidConfigException("Can not add or update statuses. Look inner exception.", exception);
            }
            return(query);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Number of orders returned in response. The default and maximal value is 100, any greater value is reset to 100.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="limit">
        /// Number of orders returned in response. The default and maximal value is 100, any greater value is
        /// reset to 100.
        /// </param>
        /// <exception cref="ArgumentException"><paramref name="limit" /> must be greater than 0.</exception>
        public static OrdersQueryBuilder <OrderEntry, UpdateStatus> Limit(
            this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, int limit)
        {
            if (limit <= 0)
            {
                throw new ArgumentException("Limit must be greater than 0.", nameof(limit));
            }

            if (limit > 100)
            {
                limit = 100;
            }

            query.AddOrUpdate("limit", limit);
            return(query);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Set custom query parameter.
        /// </summary>
        /// <typeparam name="TOrder">The type of the order.</typeparam>
        /// <typeparam name="TUpdateResponse">The type of the update response.</typeparam>
        /// <param name="query">The query.</param>
        /// <param name="name">The name. Must be not <see langword="null" /> or <see langword="empty" />.</param>
        /// <param name="value">The value. Must be not <see langword="null" />.</param>
        /// <exception cref="ArgumentException"><paramref name="value" /> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentException"><paramref name="name" /> is <see langword="null" /> or empty</exception>
        public static OrdersQueryBuilder <TOrder, TUpdateResponse> Custom <TOrder, TUpdateResponse>(
            this OrdersQueryBuilder <TOrder, TUpdateResponse> query, string name, object value)
            where TOrder : BaseOrder
            where TUpdateResponse : class
        {
            if (value == null)
            {
                throw new ArgumentException(nameof(value));
            }
            if (Validators.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Name is null or empty.", nameof(name));
            }

            query.AddOrUpdate(name, value);
            return(query);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Order update date/time (lower bound).
 /// </summary>
 /// <param name="query">The query.</param>
 /// <param name="dateFrom">The date from.</param>
 /// <exception cref="ArgumentException"><paramref name="dateFrom" /> is invalid.</exception>
 public static OrdersQueryBuilder <OrderEntry, UpdateStatus> UpdatedFrom(
     this OrdersQueryBuilder <OrderEntry, UpdateStatus> query, DateTime dateFrom)
 {
     try
     {
         query.AddOrUpdate("updatedFrom", dateFrom.ToString("yyyy-MM-dd HH:mm:ss"));
     }
     catch (FormatException exception)
     {
         throw new ArgumentException("Date is invalid.", nameof(dateFrom), exception);
     }
     catch (ArgumentOutOfRangeException exception)
     {
         throw new ArgumentException("Date is invalid.", nameof(dateFrom), exception);
     }
     return(query);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Gets the orders asynchronous.
 /// </summary>
 /// <typeparam name="TOrder">The type of the order.</typeparam>
 /// <typeparam name="TUpdateResponse">The type of the update response.</typeparam>
 /// <param name="query">The query.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static async Task <List <TOrder> > GetAsync <TOrder, TUpdateResponse>(
     this OrdersQueryBuilder <TOrder, TUpdateResponse> query,
     CancellationToken cancellationToken)
     where TOrder : BaseOrder
     where TUpdateResponse : class
 => await query.Client.GetOrdersAsync(query.Query, cancellationToken);
Exemplo n.º 19
0
 /// <summary>
 /// Gets the orders asynchronous.
 /// </summary>
 /// <typeparam name="TOrder">The type of the order.</typeparam>
 /// <typeparam name="TUpdateResponse">The type of the update response.</typeparam>
 /// <param name="query">The query.</param>
 public static async Task <List <TOrder> > GetAsync <TOrder, TUpdateResponse>(
     this OrdersQueryBuilder <TOrder, TUpdateResponse> query)
     where TOrder : BaseOrder
     where TUpdateResponse : class
 => await query.GetAsync(CancellationToken.None);
 /// <summary>
 /// Gets the orders asynchronous.
 /// </summary>
 /// <typeparam name="TOrder">The type of the order.</typeparam>
 /// <typeparam name="TUpdateResponse">The type of the update response.</typeparam>
 /// <param name="query">The query.</param>
 public static Task <IEnumerable <TOrder> > GetAsync <TOrder, TUpdateResponse>(
     this OrdersQueryBuilder <TOrder, TUpdateResponse> query)
     where TOrder : BaseOrder
     where TUpdateResponse : class
 => query.GetAsync(CancellationToken.None);