internal async Task <OmdbSearchResults> InternalSearchByTitleAsync( string search, OmdbSearchType resultType = OmdbSearchType.NONE, int?yearOfRelease = null, int pageNumber = 1) { RestRequest request = new(Method.GET); this.AddDefaultParameters(request); request.AddParameter("s", search); request.AddParameter("page", pageNumber); if (resultType is not OmdbSearchType.NONE) { request.AddParameter("type", resultType.ToQueryValue()); } if (yearOfRelease is not null) { request.AddParameter("y", yearOfRelease); } return(await this.restClient.GetAsync <OmdbSearchResults>(request)); }
private async Task <OmdbMovie> GetByIdOrTitleAsync( string?imdbId, string?title, OmdbSearchType resultType = OmdbSearchType.NONE, int?yearOfRelease = null, OmdbPlotOption omdbPlotOption = OmdbPlotOption.SHORT) { if (imdbId is null && title is null) { throw new ArgumentException("Both imdbId and title are null which is not allowed"); } RestRequest request = new(Method.GET); this.AddDefaultParameters(request); if (imdbId is not null) { request.AddParameter("i", imdbId); } if (title is not null) { request.AddParameter("t", title); } if (resultType is not OmdbSearchType.NONE) { request.AddParameter("type", resultType.ToQueryValue()); } if (yearOfRelease is not null) { request.AddParameter("y", yearOfRelease); } request.AddParameter("plot", omdbPlotOption.ToQueryValue()); return(await this.restClient.GetAsync <OmdbMovie>(request)); }