TMDbLib/Client/TMDbClientLists.cs
/// <summary>
/// Creates a new list for the user associated with the current session
/// </summary>
/// <param name="name">The name of the new list</param>
/// <param name="description">Optional description for the list</param>
/// <param name="language">Optional language that might indicate the language of the content in the list</param>
/// <param name="cancellationToken">A cancellation token</param>
/// <remarks>Requires a valid user session</remarks>
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
Creates a new list for the user associated with the current session
Creates a new list for the user associated with the current session
public async Task<string> ListCreateAsync(string name, string description = "", string language = null, CancellationToken cancellationToken = default)
        {
            RequireSessionId(SessionType.UserSession);
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException(nameof(name));
            if (string.IsNullOrWhiteSpace(description))
                description = "";
            RestRequest req = _client.Create("list");
            AddSessionId(req, SessionType.UserSession);
            language ??= DefaultLanguage;
            if (!string.IsNullOrWhiteSpace(language))
            {
                req.SetBody(new { name = name, description = description, language = language });
            }
            else
            {
                req.SetBody(new { name = name, description = description });
            }
            RestResponse<ListCreateReply> response = await req.Post<ListCreateReply>(cancellationToken).ConfigureAwait(false);
            return (await response.GetDataObject().ConfigureAwait(false)).ListId;
        }
public async Task < string > ListCreateAsync ( string name , string description = " " , string language = null , CancellationToken cancellationToken = default ) { RequireSessionId ( SessionType . UserSession ) ; if ( string . IsNullOrWhiteSpace ( name ) ) throw new ArgumentNullException ( nameof ( name ) ) ; if ( string . IsNullOrWhiteSpace ( description ) ) description = " " ; RestRequest req = _client . Create ( " " ) ; AddSessionId ( req , SessionType . UserSession ) ; language ??= DefaultLanguage ; if ( ! string . IsNullOrWhiteSpace ( language ) ) { req . SetBody ( new { name = name , description = description , language = language } ) ; } else { req . SetBody ( new { name = name , description = description } ) ; } RestResponse < ListCreateReply > response = await req . Post < ListCreateReply > ( cancellationToken ) . ConfigureAwait ( false ) ; return ( await response . GetDataObject ( ) . ConfigureAwait ( false ) ) . ListId ; }
Creates a new list for the user associated with the current session
Creates a new list for the user associated with the current session
// Description is expected by the API and can not be null
Thrown when the current client object doens't have a user session assigned.
Thrown when the current client object doens ' t have a user session assigned .
name
string
The name of the new list
The name of the new list
description
string
Optional description for the list
Optional description for the list
language
string
Optional language that might indicate the language of the content in the list
Optional language that might indicate the language of the content in the list
cancellationToken
CancellationToken
A cancellation token
A cancellation token
remarks
Requires a valid user session
Requires a valid user session