private void Validate(TraktSearchIdType searchIdType, string lookupId) { if (searchIdType == null) { throw new ArgumentNullException(nameof(searchIdType), "search id type must not be null"); } if (searchIdType == TraktSearchIdType.Unspecified) { throw new ArgumentException("search id lookup type not valid", nameof(searchIdType)); } if (string.IsNullOrEmpty(lookupId) || lookupId.ContainsSpace()) { throw new ArgumentException("search lookup id not valid", nameof(lookupId)); } }
/// <summary> /// Looks up items by their Trakt-, IMDB-, TMDB-, TVDB- or TVRage-Id. /// <para>OAuth authorization not required.</para> /// <para> /// See <a href="http://docs.trakt.apiary.io/#reference/search/text-query/get-id-lookup-results">"Trakt API Doc - Search: Id Lookup"</a> for more information. /// </para> /// </summary> /// <param name="searchIdType">The id type, which should be looked up. See also <seealso cref="TraktSearchIdType" />.</param> /// <param name="lookupId">The Trakt-, IMDB-, TMDB-, TVDB- or TVRage-Id, which will be looked up.</param> /// <param name="searchResultTypes">The object type(s), which will be looked up. See also <seealso cref="TraktSearchResultType" />.</param> /// <param name="extendedInfo"> /// The extended info, which determines how much data about the lookup object(s) should be queried. /// See also <seealso cref="TraktExtendedInfo" />. /// </param> /// <param name="pagedParameters"></param> /// <param name="cancellationToken"></param> /// <returns> /// An <see cref="TraktPagedResponse{ITraktSearchResult}"/> instance containing the found movies, shows, episodes, people and / or lists and which also /// contains the queried page number, the page's item count, maximum page count and maximum item count. /// <para> /// See also <seealso cref="TraktPagedResponse{ListItem}" /> and <seealso cref="ITraktSearchResult" />. /// </para> /// </returns> /// <exception cref="TraktException">Thrown, if the request fails.</exception> /// <exception cref="ArgumentException"> /// Thrown, if the given lookupId is null, empty or contains spaces. /// Thrown, if the given searchIdType is unspecified. /// </exception> /// <exception cref="ArgumentNullException">Thrown, if the given searchIdType is null.</exception> public Task <TraktPagedResponse <ITraktSearchResult> > GetIdLookupResultsAsync(TraktSearchIdType searchIdType, string lookupId, TraktSearchResultType searchResultTypes = null, TraktExtendedInfo extendedInfo = null, TraktPagedParameters pagedParameters = null, CancellationToken cancellationToken = default) { var requestHandler = new RequestHandler(Client); return(requestHandler.ExecutePagedRequestAsync(new SearchIdLookupRequest { IdType = searchIdType, LookupId = lookupId, ResultTypes = searchResultTypes, ExtendedInfo = extendedInfo, Page = pagedParameters?.Page, Limit = pagedParameters?.Limit }, cancellationToken)); }
public async Task <TraktPaginationListResult <TraktSearchResult> > GetIdLookupResultsAsync(TraktSearchIdType searchIdType, [NotNull] string lookupId, TraktSearchResultType searchResultType = null, TraktExtendedInfo extendedInfo = null, int?page = null, int?limitPerPage = null) { Validate(searchIdType, lookupId); return(await QueryAsync(new TraktSearchIdLookupRequest(Client) { IdType = searchIdType, LookupId = lookupId, ResultType = searchResultType, ExtendedInfo = extendedInfo, PaginationOptions = new TraktPaginationOptions(page, limitPerPage) })); }
public void TestTraktSearchIdTypeIsTraktEnumeration() { var enumeration = new TraktSearchIdType(); enumeration.Should().BeAssignableTo <TraktEnumeration>(); }