<commit_before>﻿#region License
/*
 * Copyright 2017 <NAME>
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
#endregion

using Newtonsoft.Json.Linq;
using ShipStation4Net.Clients.Interfaces;
using ShipStation4Net.Domain.Entities;
using ShipStation4Net.Domain.Enumerations;
using ShipStation4Net.Filters;
using ShipStation4Net.Responses;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ShipStation4Net.Clients
{
    public class Orders : ClientBase, IGetsPaginatedResponses<Order>, ICreates<Order>, IGets<Order>
    {
        public Orders(Configuration configuration) : base(configuration)
        {
            BaseUri = "orders";
        }

        /// <summary>
        /// Obtains a list of orders that match the specified criteria. All of the available filters are optional. They do not need to be 
        /// included in the URL. The filter is created just for the particular Orders return type.
        /// </summary>
        /// <param name="filter">An OrdersFilter</param>
        /// <returns>A list of orders filtered by the supplied parameters.</returns>
        public async Task<IList<Order>> GetAllPagesAsync(IFilter filter = null)
        {
            var items = new List<Order>();
            filter = filter ?? new OrdersFilter();
<commit_msg>Adds a method `IEnumerable<IEnumerable<Order>> GetAllPages(...)` which allows to get order pages in a blocking fashion. This is useful when you have thousands of pages and you want to start processing records as soon as the API returns the first page, then the second ... etc.<commit_after>﻿#region License
/*
 * Copyright 2017 <NAME>
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
#endregion

using Newtonsoft.Json.Linq;
using ShipStation4Net.Clients.Interfaces;
using ShipStation4Net.Domain.Entities;
using ShipStation4Net.Domain.Enumerations;
using ShipStation4Net.Filters;
using ShipStation4Net.Responses;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ShipStation4Net.Clients
{
    public class Orders : ClientBase, IGetsPaginatedResponses<Order>, ICreates<Order>, IGets<Order>
    {
        public Orders(Configuration configuration) : base(configuration)
        {
            BaseUri = "orders";
        }

        /// <summary>
        /// Obtains a list of order pages that match the specified criteria. All of the available filters are optional. They do not need to be 
        /// included in the URL. The filter is created just for the particular Orders return type.
        /// </summary>
        /// <param name="filter">An OrdersFilter</param>
        /// <returns>A list of order pages filtered by the supplied parameters.</returns>
        public IEnumerable<IEnumerable<Order>> GetAllPages(IFilter filter = null)
        {
            var items = new List<Order>();
            filter = filter ?? new OrdersFilter();

            var pageOne = GetDataAsync<PaginatedResponse<Order>>((OrdersFilter)filter).Result;

            yield return pageOne.Items;

            for (int i = 2; i <= pageOne.TotalPages; i++)
            {
                var currentPage = GetPageAsync(i, filter.PageSize, (OrdersFilter)filter).Result;
                yield return currentPage;
            }
        }

        /// <summary>
        /// Obtains a list of orders that match the specified criteria. All of the available filters are optional. They do not need to be 
        /// included in the URL. The filter is created just for the particular Orders return type.
        /// </summary>
        /// <param name="filter">An OrdersFilter</param>
        /// <returns>A list of orders filtered by the supplied parameters.</returns>
        public async Task<IList<Order>> GetAllPagesAsync(IFilter filter = null)
        {
            var items = new List<Order>();
            filter = filter ?? new OrdersFilter();

{'fraction_non_alphanumeric': 0.0873371335504886, 'fraction_numerical': 0.005903908794788274, 'mean_word_length': 2.927258193445244, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '343087', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1248, 'n_words': 497}