示例#1
0
        /// <summary>
        /// Gets a list of orders. Max 100 per call.
        /// </summary>
        /// <returns></returns>
        public virtual async Task <OrderModelCollection> ListAsync(OrderFilter filter = null)
        {
            var req = PrepareRequest("orders");

            if (filter != null)
            {
                req.QueryParams.AddRange(filter.ToParameters());
            }

            return(await ExecuteRequestAsync <OrderModelCollection>(req, HttpMethod.Get, rootElement : ""));
        }
示例#2
0
        /// <summary>
        /// Gets a list of up to 250 of the shop's orders.
        /// </summary>
        /// <param name="options">Options for filtering the list.</param>
        /// <returns>The list of orders matching the filter.</returns>
        public virtual async Task <IEnumerable <Order> > ListAsync(OrderFilter options = null)
        {
            var req = PrepareRequest("orders.json");

            if (options != null)
            {
                req.QueryParams.AddRange(options.ToParameters());
            }

            return(await ExecuteRequestAsync <List <Order> >(req, HttpMethod.Get, rootElement : "orders"));
        }
示例#3
0
        /// <summary>
        /// Gets a count of all of the shop's orders.
        /// </summary>
        /// <param name="filter">Options for filtering the count.</param>
        /// <returns>The count of all orders for the shop.</returns>
        public virtual async Task <int> CountAsync(OrderFilter filter = null)
        {
            var req = PrepareRequest("orders/count.json");

            if (filter != null)
            {
                req.QueryParams.AddRange(filter.ToParameters());
            }

            return(await ExecuteRequestAsync <int>(req, HttpMethod.Get, rootElement : "count"));
        }
示例#4
0
        /// <summary>
        ///     Count an order.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public virtual async Task <int> CountAsync(OrderFilter options = null)
        {
            var req = PrepareRequest("orders");

            if (options != null)
            {
                req.QueryParams.AddRange(options.ToParameters());
            }

            return(await ExecuteRequestAsync <int>(req, HttpMethod.Head));
        }
示例#5
0
        /// <summary>
        ///     Gets a list of up to 100 of the shop's orders.
        /// </summary>
        /// <param name="scopes"></param>
        /// <param name="options">Options for filtering the list.</param>
        /// <returns>The list of orders matching the filter.</returns>
        public virtual async Task <IEnumerable <Entities.TictailOrder> > ListAsync(IEnumerable <TictailOrderScope> scopes, OrderFilter options = null)
        {
            var req = PrepareRequest("orders");

            if (options == null)
            {
                return(await ExecuteRequestAsync <List <Entities.TictailOrder> >(req, HttpMethod.Get));
            }
            req.QueryParams.AddRange(options.ToParameters());
            req.QueryParams.Add("expand", string.Join(",", scopes.Select(s => s.ToSerializedString())));
            return(await ExecuteRequestAsync <List <Entities.TictailOrder> >(req, HttpMethod.Get));
        }
示例#6
0
        public virtual async Task <IEnumerable <Refund> > ListForOrderAsync(long orderId, OrderFilter options = null)
        {
            var req = PrepareRequest($"orders/{orderId}/refunds.json");

            req.QueryParams.Add("customer_id", orderId);

            if (options != null)
            {
                req.QueryParams.AddRange(options.ToParameters());
            }

            return(await ExecuteRequestAsync <List <Refund> >(req, HttpMethod.Get, rootElement : "refunds"));
        }
示例#7
0
        /// <summary>
        /// Count orders
        /// </summary>
        /// <returns></returns>
        public virtual async Task <int> CountAsync()
        {
            var req    = PrepareRequest("orders");
            var filter = new OrderFilter()
            {
                Page = 1000
            };

            req.QueryParams.AddRange(filter.ToParameters());
            var orderMeta = await ExecuteRequestAsync <OrderModelCollection>(req, HttpMethod.Get, rootElement : "");

            return(orderMeta.Meta.Pagination.Total.GetValueOrDefault(0));
        }