2013-04-11 12:36:50 -07:00
using System.Collections.Generic ;
using System.Linq ;
using MediaBrowser.Model.Entities ;
using MediaBrowser.Model.Querying ;
2013-03-10 22:06:55 -07:00
using ServiceStack.ServiceHost ;
using System ;
namespace MediaBrowser.Api.UserLibrary
{
public abstract class BaseItemsRequest
{
/// <summary>
/// Skips over a given number of items within the results. Use for paging.
/// </summary>
/// <value>The start index.</value>
[ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? StartIndex { get ; set ; }
/// <summary>
/// The maximum number of items to return
/// </summary>
/// <value>The limit.</value>
[ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? Limit { get ; set ; }
/// <summary>
/// Whether or not to perform the query recursively
/// </summary>
/// <value><c>true</c> if recursive; otherwise, <c>false</c>.</value>
[ApiMember(Name = "Recursive", Description = "When searching within folders, this determines whether or not the search will be recursive. true/false", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool Recursive { get ; set ; }
/// <summary>
/// Gets or sets the sort order.
/// </summary>
/// <value>The sort order.</value>
[ApiMember(Name = "SortOrder", Description = "Sort Order - Ascending,Descending", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public SortOrder ? SortOrder { get ; set ; }
/// <summary>
/// Specify this to localize the search to a specific item or folder. Omit to use the root.
/// </summary>
/// <value>The parent id.</value>
[ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string ParentId { get ; set ; }
/// <summary>
/// Fields to return within the items, in addition to basic information
/// </summary>
/// <value>The fields.</value>
2013-07-22 10:07:46 -07:00
[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
2013-03-10 22:06:55 -07:00
public string Fields { get ; set ; }
2013-04-11 12:36:50 -07:00
/// <summary>
/// Gets or sets the exclude item types.
/// </summary>
/// <value>The exclude item types.</value>
[ApiMember(Name = "ExcludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string ExcludeItemTypes { get ; set ; }
/// <summary>
/// Gets or sets the include item types.
/// </summary>
/// <value>The include item types.</value>
[ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string IncludeItemTypes { get ; set ; }
/// <summary>
/// Filters to apply to the results
/// </summary>
/// <value>The filters.</value>
[ApiMember(Name = "Filters", Description = "Optional. Specify additional filters to apply. This allows multiple, comma delimeted. Options: IsFolder, IsNotFolder, IsUnplayed, IsPlayed, IsFavorite, IsRecentlyAdded, IsResumable, Likes, Dislikes", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Filters { get ; set ; }
2013-04-24 13:28:42 -07:00
/// <summary>
/// Gets or sets the media types.
/// </summary>
/// <value>The media types.</value>
[ApiMember(Name = "MediaTypes", Description = "Optional filter by MediaType. Allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string MediaTypes { get ; set ; }
2013-09-05 22:13:43 -07:00
/// <summary>
/// Gets or sets the image types.
/// </summary>
/// <value>The image types.</value>
[ApiMember(Name = "ImageTypes", Description = "Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string ImageTypes { get ; set ; }
2013-04-11 12:36:50 -07:00
/// <summary>
/// Gets the filters.
/// </summary>
/// <returns>IEnumerable{ItemFilter}.</returns>
public IEnumerable < ItemFilter > GetFilters ( )
{
var val = Filters ;
if ( string . IsNullOrEmpty ( val ) )
{
return new ItemFilter [ ] { } ;
}
return val . Split ( ',' ) . Select ( v = > ( ItemFilter ) Enum . Parse ( typeof ( ItemFilter ) , v , true ) ) ;
}
/// <summary>
/// Gets the item fields.
/// </summary>
/// <returns>IEnumerable{ItemFields}.</returns>
public IEnumerable < ItemFields > GetItemFields ( )
{
var val = Fields ;
if ( string . IsNullOrEmpty ( val ) )
{
return new ItemFields [ ] { } ;
}
2013-07-22 07:58:38 -07:00
return val . Split ( ',' ) . Select ( v = >
{
ItemFields value ;
if ( Enum . TryParse ( v , true , out value ) )
{
return ( ItemFields ? ) value ;
}
return null ;
} ) . Where ( i = > i . HasValue ) . Select ( i = > i . Value ) ;
2013-04-11 12:36:50 -07:00
}
2013-09-05 22:13:43 -07:00
/// <summary>
/// Gets the image types.
/// </summary>
/// <returns>IEnumerable{ImageType}.</returns>
public IEnumerable < ImageType > GetImageTypes ( )
{
var val = ImageTypes ;
if ( string . IsNullOrEmpty ( val ) )
{
return new ImageType [ ] { } ;
}
return val . Split ( ',' ) . Select ( v = > ( ImageType ) Enum . Parse ( typeof ( ImageType ) , v , true ) ) ;
}
2013-03-10 22:06:55 -07:00
}
}