/// <summary>
        /// Specifies the field names used to sort results descending.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="field">The field.</param>
        public static MaximoResourceSearch OrderByDescending(this MaximoResourceSearch query, string field)
        {
            query.OrderBy           = field;
            query.OrderByDescending = true;

            return(query);
        }
        /// <summary>
        /// Searches the specified fields.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="attributes">The names of the attributes.</param>
        public static MaximoResourceSearch SearchAttributes(this MaximoResourceSearch query, params string[] attributes)
        {
            if (attributes != null && attributes.Length > 0)
            {
                foreach (var attribute in attributes)
                {
                    if (attribute != null && !query.SearchAttributes.Contains(attribute))
                    {
                        query.SearchAttributes.Add(attribute);
                    }
                }
            }

            return(query);
        }
        /// <summary>
        /// Performs a GET using the search query.
        /// </summary>
        /// <typeparam name="T">Specifies the type of the return object.</typeparam>
        /// <param name="query">The search query.</param>
        /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param>
        /// <param name="pageSize">The maximum number of items to return.</param>
        /// <param name="page">The page number to retrieve.</param>
        /// <returns>An <see cref="IList{TResult}"/> containing a collection of items from the API.</returns>
        public static async Task <IList <T> > GetListAsync <T>(this MaximoResourceSearch query, CancellationToken cancellationToken, int?pageSize = null, int?page = null)
        {
            query.PageSize   = pageSize;
            query.PageNumber = page;

            var uri = query.ToUri();

            var response = await query.Client.SendAndGetStringResponseAsync(HttpMethod.Get, uri, null, query.Headers, query.ImpersonateIdentity, cancellationToken);

            var jObj = JObject.Parse(response);

            if (jObj["member"] == null)
            {
                throw new KeyNotFoundException(@"The ""member"" attribute was not found.");
            }

            return(jObj["member"].ToObject <List <T> >());
        }
        /// <summary>
        /// Specifies the term to search for.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="term">The term.</param>
        public static MaximoResourceSearch SearchTerm(this MaximoResourceSearch query, string term)
        {
            query.SearchTerm = term;

            return(query);
        }
        /// <summary>
        /// Searches the specified field.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="attribute">The attribute name.</param>
        public static MaximoResourceSearch SearchAttributes(this MaximoResourceSearch query, string attribute)
        {
            query.SearchAttributes.Add(attribute);

            return(query);
        }