/** * @param \DateTime $fromTime * @param \DateTime $toTime * @return UpdateData * @throws RequestFailedException * @throws UnauthorizedException * @throws InvalidArgumentException * @throws InvalidJsonInResponseException */ public function query(\DateTime $fromTime, \DateTime $toTime = null) { $options = ['query' => ['fromTime' => $fromTime->getTimestamp()]]; if ($toTime !== null) { $options['query']['toTime'] = $toTime->getTimestamp(); } $json = $this->client->performApiCallWithJsonResponse('get', '/updated/query', $options); return ResponseHandler::create($json, ResponseHandler::METHOD_UPDATES)->handle(); }
/** * E.g.: $query = [ * 'keyType' => 'fanart', * 'resolution' => '1920x1080', * 'subKey' => 'graphical' * ] * * @param $seriesId * @param array $query * @return SeriesImageQueryResults * @throws RequestFailedException * @throws UnauthorizedException * @throws InvalidJsonInResponseException * @throws InvalidArgumentException */ public function getImagesWithQuery($seriesId, array $query) { $options = ['query' => $query]; $json = $this->client->performApiCallWithJsonResponse('get', sprintf('/series/%d/images/query', (int) $seriesId), $options); return ResponseHandler::create($json, ResponseHandler::METHOD_SERIES_IMAGES_QUERY)->handle(); }
/** * Search for a series based on parameter and value. * * @param string $parameter * @param string $value * @return SeriesData * @throws RequestFailedException * @throws UnauthorizedException * @throws InvalidArgumentException * @throws InvalidJsonInResponseException */ private function search($parameter, $value) { $options = ['query' => [$parameter => $value], 'http_errors' => false]; $json = $this->client->performApiCallWithJsonResponse('get', '/search/series', $options); return ResponseHandler::create($json, ResponseHandler::METHOD_SEARCH_SERIES)->handle(); }
/** * Returns the full information for a given episode ID. * * @param int $episodeId * @return Episode * @throws RequestFailedException * @throws UnauthorizedException * @throws InvalidJsonInResponseException * @throws InvalidArgumentException */ public function get($episodeId) { $json = $this->client->performApiCallWithJsonResponse('get', '/episodes/' . (int) $episodeId); return ResponseHandler::create($json, ResponseHandler::METHOD_EPISODE)->handle(); }
/** * Get information about a particular language, given the language ID. * * @param int $identifier * @return Language * @throws RequestFailedException * @throws UnauthorizedException * @throws InvalidJsonInResponseException * @throws InvalidArgumentException */ public function get($identifier) { $json = $this->client->performApiCallWithJsonResponse('get', sprintf('/languages/%d', (int) $identifier)); return ResponseHandler::create($json, ResponseHandler::METHOD_LANGUAGE)->handle(); }
/** * Add user rating. * * @param int $type Use class constants UsersExtension::RATING_TYPE_* * @param int $itemId * @param int $rating Value between 1 and 10 * @return UserRatingsDataNoLinks * @throws RequestFailedException * @throws UnauthorizedException * @throws InvalidArgumentException * @throws InvalidJsonInResponseException */ public function addRating($type, $itemId, $rating) { if (!in_array($type, self::$ratingTypes, true)) { throw new InvalidArgumentException('Invalid rating type, use one of these instead: ' . implode(self::$ratingTypes, ', ')); } try { $json = $this->client->performApiCallWithJsonResponse('put', sprintf('user/ratings/%s/%d/%d', $type, (int) $itemId, (int) $rating), ['http_errors' => true]); } catch (ClientException $e) { $message = $this->getApiErrorMessage($e->getResponse()); if ($message !== '') { throw CouldNotAddOrUpdateUserRatingException::reason($message); } throw CouldNotAddOrUpdateUserRatingException::reason($e->getMessage()); } return ResponseHandler::create($json, ResponseHandler::METHOD_USER_RATINGS_ADD)->handle(); }