├── .gitignore ├── .travis.yml ├── Dockerfile ├── OAuthExample ├── authorize.php ├── refresh.php └── token.php ├── bin ├── docker-php-pecl-install ├── phpunit ├── setfacl-cache-for └── trakt ├── composer.json ├── composer.lock ├── docker-compose.yml ├── php.ini ├── phpunit.xml ├── readme.md ├── scripts └── phpunit ├── src └── Wubs │ └── Trakt │ ├── Api │ ├── Calendars.php │ ├── Calendars │ │ ├── My.php │ │ └── Shows.php │ ├── CheckIn.php │ ├── Comments.php │ ├── Comments │ │ └── Like.php │ ├── Endpoint.php │ ├── Episodes.php │ ├── Genres.php │ ├── Movies.php │ ├── People.php │ ├── Recommendations.php │ ├── Recommendations │ │ └── Dismiss.php │ ├── Scrobble.php │ ├── Search.php │ ├── Seasons.php │ ├── Shows.php │ ├── Shows │ │ └── Progress.php │ ├── Sync.php │ ├── Sync │ │ ├── Collection.php │ │ ├── History.php │ │ ├── Ratings.php │ │ └── Watchlist.php │ ├── Users.php │ └── Users │ │ ├── Followers.php │ │ ├── Lists.php │ │ └── Lists │ │ └── Like.php │ ├── Auth │ ├── Auth.php │ ├── Token.php │ └── TraktProvider.php │ ├── Console │ ├── Generators │ │ ├── EndpointGenerator.php │ │ ├── Method.php │ │ ├── Property.php │ │ └── TemplateWriter.php │ ├── TraktGenerateCommand.php │ └── stubs │ │ ├── api.stub │ │ ├── method.stub │ │ └── property.stub │ ├── Contracts │ └── ResponseHandler.php │ ├── Exception │ ├── CheckInTypeNotSupportedException.php │ ├── ClassCanNotBeImplementedAsEndpointException.php │ ├── InvalidOauthRequestException.php │ ├── MalformedParameterException.php │ ├── MediaTypeNotSupportedException.php │ └── RequestMalformedException.php │ ├── Media │ ├── Episode.php │ ├── Media.php │ ├── Movie.php │ ├── Person.php │ ├── Season.php │ └── Show.php │ ├── Providers │ └── Laravel │ │ ├── TraktApiServiceProvider.php │ │ └── trakt.php │ ├── Request │ ├── AbstractRequest.php │ ├── Calendars │ │ ├── Movies.php │ │ ├── My │ │ │ ├── Movies.php │ │ │ ├── NewShows.php │ │ │ ├── Premieres.php │ │ │ └── Shows.php │ │ ├── Shows.php │ │ └── Shows │ │ │ ├── NewShows.php │ │ │ └── Premieres.php │ ├── CheckIn │ │ ├── Create.php │ │ └── Delete.php │ ├── Comments │ │ ├── CommentSize.php │ │ ├── Create.php │ │ ├── Delete.php │ │ ├── Get.php │ │ ├── Like.php │ │ ├── Like │ │ │ └── Delete.php │ │ ├── Replies.php │ │ └── Update.php │ ├── Episodes │ │ ├── Comments.php │ │ ├── EpisodeTrait.php │ │ ├── Ratings.php │ │ ├── Stats.php │ │ ├── Summary.php │ │ └── Watching.php │ ├── Exception │ │ ├── CommentTooShortException.php │ │ ├── ExpectedStatusCodeException.php │ │ ├── HttpCodeException │ │ │ ├── BadRequestException.php │ │ │ ├── ConflictException.php │ │ │ ├── ExceptionStatusCodeFactory.php │ │ │ ├── ForbiddenException.php │ │ │ ├── MethodNotFoundException.php │ │ │ ├── NotFoundException.php │ │ │ ├── PreconditionException.php │ │ │ ├── RateLimitExceededException.php │ │ │ ├── ServerErrorException.php │ │ │ ├── ServerUnavailableException.php │ │ │ ├── StatusCodeException.php │ │ │ ├── UnauthorizedException.php │ │ │ └── UnprocessableEntityException.php │ │ ├── RequestCallException.php │ │ └── TokenRequiredException.php │ ├── Genres │ │ └── Get.php │ ├── Movies │ │ ├── Aliases.php │ │ ├── Collected.php │ │ ├── Comments.php │ │ ├── People.php │ │ ├── Played.php │ │ ├── Popular.php │ │ ├── Ratings.php │ │ ├── Related.php │ │ ├── Releases.php │ │ ├── Stats.php │ │ ├── Summary.php │ │ ├── Translations.php │ │ ├── Trending.php │ │ ├── Watched.php │ │ └── Watching.php │ ├── Parameters │ │ ├── AbstractParameter.php │ │ ├── IdType.php │ │ ├── MediaIdTrait.php │ │ ├── Parameter.php │ │ ├── Section.php │ │ ├── TimePeriod.php │ │ └── Type.php │ ├── People │ │ ├── Movies.php │ │ ├── Shows.php │ │ └── Summary.php │ ├── Recommendations │ │ ├── Dismiss │ │ │ ├── Movie.php │ │ │ └── Show.php │ │ ├── Movies.php │ │ └── Shows.php │ ├── RequestType.php │ ├── Scrobble │ │ ├── Pause.php │ │ ├── ScrobblerTrait.php │ │ ├── Start.php │ │ └── Stop.php │ ├── Search │ │ ├── ById.php │ │ └── ByText.php │ ├── Seasons │ │ ├── Comments.php │ │ ├── Ratings.php │ │ ├── Season.php │ │ ├── Summary.php │ │ └── Watching.php │ ├── Shows │ │ ├── Aliases.php │ │ ├── Collected.php │ │ ├── Comments.php │ │ ├── People.php │ │ ├── Played.php │ │ ├── Popular.php │ │ ├── Progress │ │ │ ├── Collection.php │ │ │ └── Watched.php │ │ ├── Ratings.php │ │ ├── Related.php │ │ ├── Stats.php │ │ ├── Summary.php │ │ ├── Translations.php │ │ ├── Trending.php │ │ ├── Updates.php │ │ ├── Watched.php │ │ └── Watching.php │ ├── Sync │ │ ├── Collection │ │ │ ├── Add.php │ │ │ ├── Get.php │ │ │ └── Remove.php │ │ ├── History │ │ │ ├── Add.php │ │ │ ├── Get.php │ │ │ └── Remove.php │ │ ├── LastActivities.php │ │ ├── Playback.php │ │ ├── Ratings │ │ │ ├── Add.php │ │ │ ├── Get.php │ │ │ └── Remove.php │ │ ├── Watched.php │ │ └── Watchlist │ │ │ ├── Add.php │ │ │ ├── Get.php │ │ │ └── Remove.php │ ├── UriBuilder.php │ └── Users │ │ ├── Collection.php │ │ ├── Comments.php │ │ ├── Follow.php │ │ ├── Followers │ │ ├── Approve.php │ │ ├── Deny.php │ │ └── Get.php │ │ ├── Following.php │ │ ├── Friends.php │ │ ├── Hidden.php │ │ ├── History.php │ │ ├── Likes.php │ │ ├── Lists │ │ ├── Create.php │ │ ├── Delete.php │ │ ├── Get.php │ │ ├── Like │ │ │ ├── Create.php │ │ │ └── Delete.php │ │ ├── Remove.php │ │ └── Update.php │ │ ├── Profile.php │ │ ├── Ratings.php │ │ ├── Settings.php │ │ ├── Stats.php │ │ ├── Watching.php │ │ └── Watchlist.php │ ├── Response │ ├── Calendar │ │ ├── Calendar.php │ │ └── Day.php │ ├── CheckIn.php │ ├── Comment.php │ ├── Handlers │ │ ├── AbstractResponseHandler.php │ │ ├── Calendars │ │ │ ├── MoviesHandler.php │ │ │ └── Shows.php │ │ ├── CheckIn │ │ │ └── CheckInHandler.php │ │ ├── Comments │ │ │ └── CommentHandler.php │ │ ├── DefaultDeleteHandler.php │ │ ├── DefaultResponseHandler.php │ │ ├── Movies │ │ │ ├── CommentsHandler.php │ │ │ ├── PopularHandler.php │ │ │ ├── SummaryHandler.php │ │ │ ├── TrendingHandler.php │ │ │ └── UpdatedHandler.php │ │ └── Search │ │ │ └── SearchHandler.php │ ├── People.php │ ├── Trending.php │ └── Updated.php │ ├── Trakt.php │ └── TraktHttpClient.php └── tests ├── Api ├── ApiTest.php ├── CalendarsRequestTest.php ├── CheckInRequestTest.php ├── CheckOutRequestTest.php ├── CommentsRequestTest.php ├── EpisodesRequestTest.php ├── ExtendedInfoTest.php ├── MoviesRequestTest.php ├── PaginationTest.php ├── PropertiesTest.php ├── SearchTest.php └── ShowsRequestTest.php ├── Console └── Generators │ ├── ApiGeneratorTest.php │ ├── MethodGeneratorTest.php │ └── NestedRequestsGeneratorTest.php ├── HowItShouldWorkTest.php ├── Media ├── MovieTest.php └── ShowTest.php ├── Request ├── AbstractRequestTest.php ├── Calendars │ ├── MoviesTest.php │ ├── PremieresTest.php │ ├── ShowsNewTest.php │ └── ShowsTest.php ├── CheckIn │ ├── CheckInTest.php │ └── MovieCheckInTest.php ├── Comments │ ├── CommentsTest.php │ ├── GetCommentTest.php │ └── RepliesTest.php ├── Scrobble │ └── ScrobbleTest.php ├── Search │ └── TextTest.php ├── UriBuilderTest.php └── Users │ ├── HistoryTest.php │ └── SettingsTest.php ├── RequestTest.php ├── Response ├── Calendar │ └── DayTest.php ├── Handlers │ ├── Calendars │ │ └── MoviesHandlerTest.php │ └── Movies │ │ └── UpdatedHandlerTest.php └── TestResponse.php ├── TraktProviderTest.php ├── TraktTest.php ├── TraktTokenTest.php └── bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/* 2 | *.json 3 | Gemfile 4 | Guardfile 5 | tests.txt 6 | .idea 7 | .env 8 | _site 9 | composer.phar 10 | *.DS_Store 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | services: 4 | - docker 5 | 6 | before_script: 7 | - env | grep TRAKT_ > .env 8 | 9 | before_install: 10 | - docker pull megawubs/trakt-api:dev 11 | 12 | install: 13 | - docker-compose run trakt-api composer install --prefer-dist 14 | 15 | script: bin/phpunit 16 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-fpm-alpine 2 | 3 | COPY bin/docker-php-pecl-install /usr/local/bin/docker-php-pecl-install 4 | RUN chmod +x /usr/local/bin/docker-php-pecl-install 5 | 6 | COPY php.ini /usr/local/etc/php/php.ini 7 | 8 | RUN apk --no-cache add icu-dev autoconf build-base acl git\ 9 | && docker-php-pecl-install -o -f apcu uuid xdebug \ 10 | && docker-php-ext-install bcmath intl mbstring opcache pdo_mysql sockets \ 11 | && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ 12 | && composer global require hirak/prestissimo 13 | 14 | ADD bin /tmp/bin 15 | RUN mkdir -p /usr/local/bin \ 16 | && mv /tmp/bin/* /usr/local/bin \ 17 | && chmod +x /usr/local/bin/* \ 18 | && rm -rf /tmp/bin 19 | 20 | WORKDIR /source 21 | -------------------------------------------------------------------------------- /OAuthExample/authorize.php: -------------------------------------------------------------------------------- 1 | load(); 18 | 19 | $provider = new TraktProvider(getenv("CLIENT_ID"), getenv("CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI")); 20 | $auth = new Auth($provider); 21 | 22 | $trakt = new Trakt($auth, TraktHttpClient::make()); 23 | 24 | $trakt->auth->authorize(); 25 | //after authorization the user will be redirected to the page where you preform a token 26 | // request. see token.php -------------------------------------------------------------------------------- /OAuthExample/refresh.php: -------------------------------------------------------------------------------- 1 | load(); 11 | 12 | $provider = new TraktProvider(getenv("CLIENT_ID"), getenv("CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI")); 13 | $auth = new Auth($provider); 14 | 15 | $trakt = new Trakt($auth, TraktHttpClient::make()); 16 | 17 | $token = $trakt->auth->refresh(getenv("TRAKT_REFRESH_TOKEN")); 18 | 19 | dump($token); -------------------------------------------------------------------------------- /OAuthExample/token.php: -------------------------------------------------------------------------------- 1 | load(); 11 | 12 | $provider = new TraktProvider(getenv("CLIENT_ID"), getenv("CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI")); 13 | $auth = new Auth($provider); 14 | 15 | $trakt = new Trakt($auth, TraktHttpClient::make()); 16 | 17 | $token = $trakt->auth->token("token-retrieval-code-here"); -------------------------------------------------------------------------------- /bin/docker-php-pecl-install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #https://raw.githubusercontent.com/helderco/docker-php/master/template/bin/docker-php-pecl-install 3 | set -e 4 | 5 | usage () { 6 | echo "usage: $0 [channel/] ..." 7 | echo " ie: $0 uploadprogress oauth-1.2.3" 8 | } 9 | 10 | if [ $# -eq 0 ]; then 11 | usage >&2 12 | exit 1 13 | fi 14 | 15 | pecl install "$@" 16 | 17 | while [ $# -gt 0 ]; do 18 | ext="$1" 19 | ext=$(echo "$ext" | cut -d- -f1) 20 | ext=$(echo "$ext" | cut -d\/ -f2) 21 | shift 22 | 23 | for module in $(find /usr/local/lib/php/extensions -name "$ext.so"); do 24 | ini="/usr/local/etc/php/conf.d/$ext.ini" 25 | if grep -q zend_extension_entry "$module"; then 26 | # https://wiki.php.net/internals/extensions#loading_zend_extensions 27 | line="zend_extension=$(basename "$module")" 28 | else 29 | line="extension=$(basename "$module")" 30 | fi 31 | if ! grep -q "$line" "$ini" 2>/dev/null; then 32 | echo "$line" >> "$ini" 33 | fi 34 | done 35 | done 36 | 37 | rm -rf /tmp/* 38 | -------------------------------------------------------------------------------- /bin/phpunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker-compose run trakt-api scripts/phpunit tests 4 | 5 | -------------------------------------------------------------------------------- /bin/setfacl-cache-for: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | user=${1:?'Please provide a user as first argument'} 4 | path=${2:?'Please provide a path as second argument'} 5 | 6 | setfacl -R -m u:${user}:rwX ${path} 7 | setfacl -dR -m u:${user}:rwX ${path} 8 | -------------------------------------------------------------------------------- /bin/trakt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | add(new TraktGenerateCommand()); 11 | 12 | $console->run(); 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wubs/trakt", 3 | "description": "Trakt API wrapper", 4 | "authors": [ 5 | { 6 | "name": "megawubs", 7 | "email": "bwubs@me.com" 8 | } 9 | ], 10 | "minimum-stability": "stable", 11 | "require": { 12 | "php": ">=5.4.7", 13 | "illuminate/support": "~5.2", 14 | "nesbot/carbon": "~1", 15 | "guzzlehttp/guzzle": "~5", 16 | "league/oauth2-client": "~0.8", 17 | "league/url": "^3.3" 18 | }, 19 | "require-dev": { 20 | "vlucas/phpdotenv": "^2.0", 21 | "mockery/mockery": "^0.9.4", 22 | "symfony/console": "^2.7", 23 | "league/flysystem": "^1.0", 24 | "symfony/var-dumper": "v2.7.1", 25 | "psr/log": "^1.0", 26 | "phpunit/phpunit": "^5.4" 27 | }, 28 | "autoload": { 29 | "psr-0": { 30 | "Wubs": "src/" 31 | }, 32 | "classmap": [ 33 | "tests" 34 | ] 35 | }, 36 | "bin": [ 37 | "bin/trakt" 38 | ], 39 | "config": { 40 | "bin-dir": "scripts" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | trakt-api: 2 | image: megawubs/trakt-api:dev 3 | volumes: 4 | - '.:/source' 5 | environment: 6 | - PHP_IDE_CONFIG=serverName=trakt.dev 7 | - XDEBUG_CONFIG=idekey=phpstorm remote_host=192.168.1.123 8 | 9 | -------------------------------------------------------------------------------- /php.ini: -------------------------------------------------------------------------------- 1 | date.timezone = Europe/Amsterdam 2 | display_errors = On 3 | display_startup_errors = On 4 | log_errors = On 5 | error_log = /dev/stderr 6 | always_populate_raw_post_data = -1 7 | upload_max_filesize = 50M 8 | post_max_size = 50M 9 | memory_limit = 256M 10 | xdebug.remote_enable = 1 11 | xdebug.remote_port = 9000 12 | xdebug.remote_handler = dbgp 13 | xdebug.remote_autostart = 1 14 | xdebug.remote_connect_back = 1 15 | error_reporting = E_ALL 16 | 17 | 18 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /scripts/phpunit: -------------------------------------------------------------------------------- 1 | ../vendor/phpunit/phpunit/phpunit -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Calendars.php: -------------------------------------------------------------------------------- 1 | request(new MoviesRequest($startDate, $days)); 31 | } 32 | 33 | public function shows(Carbon $startDate = null, $days = null) 34 | { 35 | return $this->request(new ShowsRequest($startDate, $days)); 36 | } 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Calendars/My.php: -------------------------------------------------------------------------------- 1 | request(new MoviesRequest($accessToken, $startDate, $days)); 27 | } 28 | 29 | public function newShows(AccessToken $accessToken, Carbon $startDate = null, $days = null) 30 | { 31 | return $this->request(new NewShowsRequest($accessToken, $startDate, $days)); 32 | } 33 | 34 | public function premieres(AccessToken $accessToken, Carbon $startDate = null, $days = null) 35 | { 36 | return $this->request(new PremieresRequest($accessToken, $startDate, $days)); 37 | } 38 | 39 | public function shows(AccessToken $accessToken, Carbon $startDate = null, $days = null) 40 | { 41 | return $this->request(new ShowsRequest($accessToken, $startDate, $days)); 42 | } 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Calendars/Shows.php: -------------------------------------------------------------------------------- 1 | request(new NewShowsRequest($startDate, $days)); 24 | } 25 | 26 | public function premieres(Carbon $startDate = null, $days = null) 27 | { 28 | return $this->request(new PremieresRequest($startDate, $days)); 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/CheckIn.php: -------------------------------------------------------------------------------- 1 | request(new CreateRequest($token, $media, $message, $sharing, $venueId, $venueName, $appVersion, $appDate)); 24 | } 25 | 26 | public function delete(AccessToken $token) 27 | { 28 | return $this->request(new DeleteRequest($token)); 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Comments/Like.php: -------------------------------------------------------------------------------- 1 | request(new DeleteRequest($token, $commentId)); 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Episodes.php: -------------------------------------------------------------------------------- 1 | request(new CommentsRequest($showId, $season, $episode)); 25 | } 26 | 27 | public function ratings($mediaId, $season, $episode) 28 | { 29 | return $this->request(new RatingsRequest($mediaId, $season, $episode)); 30 | } 31 | 32 | public function stats($mediaId, $season, $episode) 33 | { 34 | return $this->request(new StatsRequest($mediaId, $season, $episode)); 35 | } 36 | 37 | public function summary($mediaId, $season, $episode) 38 | { 39 | return $this->request(new SummaryRequest($mediaId, $season, $episode)); 40 | } 41 | 42 | public function get($mediaId, $season, $episode) 43 | { 44 | return $this->request(new SummaryRequest($mediaId, $season, $episode)); 45 | } 46 | 47 | public function watching($mediaId, $season, $episode) 48 | { 49 | return $this->request(new WatchingRequest($mediaId, $season, $episode)); 50 | } 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Genres.php: -------------------------------------------------------------------------------- 1 | request(new GetRequest($type)); 21 | } 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/People.php: -------------------------------------------------------------------------------- 1 | request(new MoviesRequest($mediaId)); 23 | } 24 | 25 | public function shows($mediaId) 26 | { 27 | return $this->request(new ShowsRequest($mediaId)); 28 | } 29 | 30 | public function summary($mediaId) 31 | { 32 | return $this->request(new SummaryRequest($mediaId)); 33 | } 34 | 35 | public function get($mediaId) 36 | { 37 | return $this->request(new SummaryRequest($mediaId)); 38 | } 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Recommendations.php: -------------------------------------------------------------------------------- 1 | request(new MoviesRequest($token)); 26 | } 27 | 28 | public function shows(AccessToken $token) 29 | { 30 | return $this->request(new ShowsRequest($token)); 31 | } 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Recommendations/Dismiss.php: -------------------------------------------------------------------------------- 1 | request(new MovieRequest($mediaId)); 23 | } 24 | 25 | public function show($mediaId) 26 | { 27 | return $this->request(new ShowRequest($mediaId)); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Scrobble.php: -------------------------------------------------------------------------------- 1 | request(new PauseRequest($token, $media, $progress)); 25 | } 26 | 27 | public function start(AccessToken $token, Media $media, $progress) 28 | { 29 | return $this->request(new StartRequest($token, $media, $progress)); 30 | } 31 | 32 | public function stop(AccessToken $token, Media $media, $progress) 33 | { 34 | return $this->request(new StopRequest($token, $media, $progress)); 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Search.php: -------------------------------------------------------------------------------- 1 | request(new ByIdRequest($idType, $mediaId, $token)); 23 | } 24 | 25 | public function byText($query, $type = null, $year = null, AccessToken $token = null) 26 | { 27 | return $this->request(new ByTextRequest($query, $type, $year, $token)); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Seasons.php: -------------------------------------------------------------------------------- 1 | request(new CommentsRequest($mediaId, $season)); 25 | } 26 | 27 | public function ratings($mediaId, $season) 28 | { 29 | return $this->request(new RatingsRequest($mediaId, $season)); 30 | } 31 | 32 | public function season($mediaId, $season) 33 | { 34 | return $this->request(new SeasonRequest($mediaId, $season)); 35 | } 36 | 37 | public function summary($mediaId) 38 | { 39 | return $this->request(new SummaryRequest($mediaId)); 40 | } 41 | 42 | public function get($mediaId) 43 | { 44 | return $this->request(new SummaryRequest($mediaId)); 45 | } 46 | 47 | public function watching($mediaId, $season) 48 | { 49 | return $this->request(new WatchingRequest($mediaId, $season)); 50 | } 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Shows/Progress.php: -------------------------------------------------------------------------------- 1 | request(new CollectionRequest($token, $mediaId)); 24 | } 25 | 26 | public function watched(AccessToken $token, $mediaId) 27 | { 28 | return $this->request(new WatchedRequest($token, $mediaId)); 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Sync.php: -------------------------------------------------------------------------------- 1 | request(new LastActivitiesRequest($token)); 42 | } 43 | 44 | public function playback(AccessToken $token, $type) 45 | { 46 | return $this->request(new PlaybackRequest($token, $type)); 47 | } 48 | 49 | public function watched(AccessToken $token, $type) 50 | { 51 | return $this->request(new WatchedRequest($token, $type)); 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Sync/Collection.php: -------------------------------------------------------------------------------- 1 | request(new AddRequest($token, $items)); 25 | } 26 | 27 | public function get(AccessToken $token, $type) 28 | { 29 | return $this->request(new GetRequest($token, $type)); 30 | } 31 | 32 | public function remove(AccessToken $token, $items) 33 | { 34 | return $this->request(new RemoveRequest($token, $items)); 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Sync/History.php: -------------------------------------------------------------------------------- 1 | request(new AddRequest($token, $items)); 25 | } 26 | 27 | public function get(AccessToken $token, $type, $id = null) 28 | { 29 | return $this->request(new GetRequest($token, $type, $id)); 30 | } 31 | 32 | public function remove(AccessToken $token, $items) 33 | { 34 | return $this->request(new RemoveRequest($token, $items)); 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Sync/Ratings.php: -------------------------------------------------------------------------------- 1 | request(new AddRequest($token, $items)); 25 | } 26 | 27 | public function get(AccessToken $token, $type, $rating = null) 28 | { 29 | return $this->request(new GetRequest($token, $type, $rating)); 30 | } 31 | 32 | public function remove(AccessToken $token, $items) 33 | { 34 | return $this->request(new RemoveRequest($token, $items)); 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Sync/Watchlist.php: -------------------------------------------------------------------------------- 1 | request(new AddRequest($token, $items)); 25 | } 26 | 27 | public function get(AccessToken $token, $type = null) 28 | { 29 | return $this->request(new GetRequest($token, $type)); 30 | } 31 | 32 | public function remove(AccessToken $token, $items) 33 | { 34 | return $this->request(new RemoveRequest($token, $items)); 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Users/Followers.php: -------------------------------------------------------------------------------- 1 | request(new ApproveRequest($token, $followerRequestId)); 25 | } 26 | 27 | public function deny(AccessToken $token, $followerRequestId) 28 | { 29 | return $this->request(new DenyRequest($token, $followerRequestId)); 30 | } 31 | 32 | public function get(AccessToken $token) 33 | { 34 | return $this->request(new GetRequest($token)); 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Api/Users/Lists/Like.php: -------------------------------------------------------------------------------- 1 | request(new CreateRequest($token, $username, $listId)); 24 | } 25 | 26 | public function delete(AccessToken $token, $username, $listId) 27 | { 28 | return $this->request(new DeleteRequest($token, $username, $listId)); 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Auth/Auth.php: -------------------------------------------------------------------------------- 1 | provider = $provider; 21 | } 22 | 23 | public function authorize() 24 | { 25 | $_SESSION['trakt_oauth_state'] = $this->provider->state; 26 | return $this->provider->authorize(); 27 | } 28 | 29 | public function token($code) 30 | { 31 | try { 32 | return $this->provider->getAccessToken("authorization_code", ["code" => $code]); 33 | } catch (\Exception $exception) { 34 | throw new InvalidOauthRequestException; 35 | } 36 | } 37 | 38 | public function isValid() 39 | { 40 | return (empty($_GET['state']) || ($_GET['state'] === $_SESSION['trakt_oauth_state'])); 41 | } 42 | 43 | public function invalid() 44 | { 45 | unset($_SESSION['trakt_oauth_state']); 46 | } 47 | 48 | public function refresh($refreshToken) 49 | { 50 | return $this->provider->getAccessToken("refresh_token", ['refresh_token' => $refreshToken, 'code' => $refreshToken]); 51 | } 52 | 53 | public function createToken($token, $type, $expires, $refresh, $scope) 54 | { 55 | return Token::create($token, $type, $expires, $refresh, $scope); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Auth/Token.php: -------------------------------------------------------------------------------- 1 | $token, 23 | "token_type" => $type, 24 | "expires_in" => $expires, 25 | "refresh_token" => $refresh, 26 | "scope" => $scope 27 | ] 28 | ); 29 | 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Console/Generators/Property.php: -------------------------------------------------------------------------------- 1 | template = $filesystem->read("/Console/stubs/property.stub"); 26 | $this->filesystem = $filesystem; 27 | $this->fullClassName = collect(explode("\\", $fullClassName)); 28 | } 29 | 30 | public function generate() 31 | { 32 | return $this->writeInTemplate("property_type", $this->fullClassName->implode("\\")) 33 | ->writeInTemplate("property_name", lcfirst($this->fullClassName->last()))->template; 34 | } 35 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Console/Generators/TemplateWriter.php: -------------------------------------------------------------------------------- 1 | template = str_replace("{{" . $key . "}}", $value, $this->template); 23 | return $this; 24 | } 25 | 26 | /** 27 | * @return $this 28 | */ 29 | protected function deleteUnusedPlaceholders() 30 | { 31 | 32 | $this->template = preg_replace("/{.*}/", "", $this->template); 33 | return $this; 34 | } 35 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Console/stubs/api.stub: -------------------------------------------------------------------------------- 1 | request(new {{request_class}}({{request_parameters}}){{auth_token}}); 4 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Console/stubs/property.stub: -------------------------------------------------------------------------------- 1 | /** 2 | * @var \{{property_type}} 3 | */ 4 | public ${{property_name}}; -------------------------------------------------------------------------------- /src/Wubs/Trakt/Contracts/ResponseHandler.php: -------------------------------------------------------------------------------- 1 | media = $this->json->episode; 29 | } 30 | 31 | public function getTitle() 32 | { 33 | return $this->media->title; 34 | } 35 | 36 | public function getIds() 37 | { 38 | return $this->media->ids; 39 | } 40 | 41 | public function getShow() 42 | { 43 | return new Show($this->json->show, $this->id, $this->token, $this->client); 44 | } 45 | 46 | public function getSeasonNumber() 47 | { 48 | return $this->media->season; 49 | } 50 | 51 | public function getEpisodeNumber() 52 | { 53 | return $this->media->number; 54 | } 55 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Media/Movie.php: -------------------------------------------------------------------------------- 1 | media->number; 20 | } 21 | 22 | public function getIds() 23 | { 24 | return $this->media->ids; 25 | } 26 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Media/Show.php: -------------------------------------------------------------------------------- 1 | publishes( 18 | [ 19 | __DIR__ . '/trakt.php' => config_path('trakt.php'), 20 | ] 21 | ); 22 | } 23 | 24 | /** 25 | * Register the service provider. 26 | * 27 | * @return void 28 | */ 29 | public function register() 30 | { 31 | $this->app->singleton( 32 | TraktProvider::class, 33 | function ($app) { 34 | return new TraktProvider( 35 | config("trakt.client_id"), 36 | config('trakt.client_secret'), 37 | config('trakt.trakt_redirect_uri') 38 | ); 39 | } 40 | ); 41 | 42 | $this->app->bind('trakt', Trakt::class); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Providers/Laravel/trakt.php: -------------------------------------------------------------------------------- 1 | getenv("CLIENT_ID"), 5 | "client_secret" => getenv("CLIENT_SECRET"), 6 | "redirect_uri" => getenv("TRAKT_REDIRECT_URI") 7 | ]; -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Calendars/Movies.php: -------------------------------------------------------------------------------- 1 | setStartDate($startDate); 20 | $this->setDays($days); 21 | } 22 | 23 | public function getRequestType() 24 | { 25 | return RequestType::GET; 26 | } 27 | 28 | public function getUri() 29 | { 30 | return "calendars/all/movies/:start_date/:days"; 31 | } 32 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Calendars/My/Movies.php: -------------------------------------------------------------------------------- 1 | setStartDate($startDate); 26 | $this->setDays($days); 27 | $this->setToken($accessToken); 28 | } 29 | 30 | public function getRequestType() 31 | { 32 | return RequestType::GET; 33 | } 34 | 35 | public function getUri() 36 | { 37 | return "calendars/my/movies/:start_date/:days"; 38 | } 39 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Calendars/My/NewShows.php: -------------------------------------------------------------------------------- 1 | setStartDate($startDate); 27 | $this->setDays($days); 28 | // $this->setResponseHandler(new ShowsResponseHandler()); 29 | $this->setToken($accessToken); 30 | } 31 | 32 | public function getRequestType() 33 | { 34 | return RequestType::GET; 35 | } 36 | 37 | public function getUri() 38 | { 39 | return "calendars/my/shows/new/:start_date/:days"; 40 | } 41 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Calendars/My/Premieres.php: -------------------------------------------------------------------------------- 1 | setDays($days); 31 | $this->setStartDate($startDate); 32 | 33 | // $this->setResponseHandler(new ShowsResponse()); 34 | $this->setToken($accessToken); 35 | } 36 | 37 | public function getRequestType() 38 | { 39 | return RequestType::GET; 40 | } 41 | 42 | public function getUri() 43 | { 44 | return "calendars/my/shows/premieres/:start_date/:days"; 45 | } 46 | 47 | 48 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Calendars/My/Shows.php: -------------------------------------------------------------------------------- 1 | setDays($days); 28 | $this->setStartDate($startDate); 29 | 30 | $this->setToken($accessToken); 31 | } 32 | 33 | public function getRequestType() 34 | { 35 | return RequestType::GET; 36 | } 37 | 38 | public function getUri() 39 | { 40 | return "calendars/my/shows/:start_date/:days"; 41 | } 42 | 43 | 44 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Calendars/Shows.php: -------------------------------------------------------------------------------- 1 | setStartDate($startDate); 21 | $this->setDays($days); 22 | } 23 | 24 | public function getRequestType() 25 | { 26 | return RequestType::GET; 27 | } 28 | 29 | public function getUri() 30 | { 31 | return "calendars/all/shows/:start_date/:days"; 32 | } 33 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Calendars/Shows/NewShows.php: -------------------------------------------------------------------------------- 1 | setStartDate($startDate); 21 | $this->setDays($days); 22 | } 23 | 24 | public function getRequestType() 25 | { 26 | return RequestType::GET; 27 | } 28 | 29 | public function getUri() 30 | { 31 | return "calendars/all/shows/new/:start_date/:days"; 32 | } 33 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Calendars/Shows/Premieres.php: -------------------------------------------------------------------------------- 1 | setStartDate($startDate); 20 | $this->setDays($days); 21 | } 22 | 23 | public function getRequestType() 24 | { 25 | return RequestType::GET; 26 | } 27 | 28 | public function getUri() 29 | { 30 | return "calendars/all/shows/premieres/:start_date/:days"; 31 | } 32 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/CheckIn/Delete.php: -------------------------------------------------------------------------------- 1 | setResponseHandler(new DefaultDeleteHandler()); 24 | $this->setToken($token); 25 | } 26 | 27 | public function getRequestType() 28 | { 29 | return RequestType::DELETE; 30 | } 31 | 32 | public function getUri() 33 | { 34 | return "checkin"; 35 | } 36 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Comments/CommentSize.php: -------------------------------------------------------------------------------- 1 | comment) < 5); 20 | } 21 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Comments/Delete.php: -------------------------------------------------------------------------------- 1 | commentId = $commentId; 30 | $this->setToken($token); 31 | $this->setResponseHandler(new DefaultDeleteHandler()); 32 | } 33 | 34 | public function getRequestType() 35 | { 36 | return RequestType::DELETE; 37 | } 38 | 39 | /** 40 | * @return int 41 | */ 42 | public function getId() 43 | { 44 | return $this->commentId; 45 | } 46 | 47 | public function getUri() 48 | { 49 | return 'comments/:id'; 50 | } 51 | 52 | 53 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Comments/Get.php: -------------------------------------------------------------------------------- 1 | id = $commentId; 24 | } 25 | 26 | public function getRequestType() 27 | { 28 | return RequestType::GET; 29 | } 30 | 31 | public function getId() 32 | { 33 | return $this->id; 34 | } 35 | 36 | public function getUri() 37 | { 38 | return "comments/:id"; 39 | } 40 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Comments/Like.php: -------------------------------------------------------------------------------- 1 | id = $commentId; 30 | $this->setResponseHandler(new DefaultDeleteHandler()); 31 | } 32 | 33 | public function getRequestType() 34 | { 35 | return RequestType::POST; 36 | } 37 | 38 | /** 39 | * @return CommentId 40 | */ 41 | public function getId() 42 | { 43 | return $this->id; 44 | } 45 | 46 | public function getUri() 47 | { 48 | return "comments/:id/like"; 49 | } 50 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Comments/Like/Delete.php: -------------------------------------------------------------------------------- 1 | setToken($token); 27 | 28 | $this->setResponseHandler(new DefaultDeleteHandler()); 29 | $this->commentId = $commentId; 30 | } 31 | 32 | public function getRequestType() 33 | { 34 | return RequestType::DELETE; 35 | } 36 | 37 | public function getUri() 38 | { 39 | return 'comments/:id/like'; 40 | } 41 | 42 | /** 43 | * @return mixed 44 | */ 45 | public function getId() 46 | { 47 | return $this->commentId; 48 | } 49 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Comments/Replies.php: -------------------------------------------------------------------------------- 1 | id = $commentId; 30 | $this->setResponseHandler(new CommentHandler()); 31 | } 32 | 33 | public function getRequestType() 34 | { 35 | return RequestType::GET; 36 | } 37 | 38 | public function getId() 39 | { 40 | return $this->id; 41 | } 42 | 43 | public function getUri() 44 | { 45 | return "comments/:id/replies"; 46 | } 47 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Episodes/Comments.php: -------------------------------------------------------------------------------- 1 | id = $showId; 30 | $this->season = $season; 31 | $this->episode = $episode; 32 | } 33 | 34 | public function getRequestType() 35 | { 36 | return RequestType::GET; 37 | } 38 | 39 | public function getUri() 40 | { 41 | return "shows/:id/seasons/:season/episodes/:episode/comments"; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Episodes/EpisodeTrait.php: -------------------------------------------------------------------------------- 1 | episode; 31 | } 32 | 33 | /** 34 | * @return int 35 | */ 36 | public function getSeason() 37 | { 38 | return $this->season; 39 | } 40 | 41 | 42 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Episodes/Ratings.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 30 | $this->season = $season; 31 | $this->episode = $episode; 32 | } 33 | 34 | public function getRequestType() 35 | { 36 | return RequestType::GET; 37 | } 38 | 39 | public function getUri() 40 | { 41 | return "shows/:id/seasons/:season/ratings"; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Episodes/Stats.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 29 | $this->episode = $episode; 30 | $this->season = $season; 31 | } 32 | 33 | public function getRequestType() 34 | { 35 | return RequestType::GET; 36 | } 37 | 38 | public function getUri() 39 | { 40 | return "shows/:id/seasons/:season/episode/:episode/stats"; 41 | } 42 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Episodes/Summary.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 29 | $this->episode = $episode; 30 | $this->season = $season; 31 | } 32 | 33 | public function getRequestType() 34 | { 35 | return RequestType::GET; 36 | } 37 | 38 | public function getUri() 39 | { 40 | return "shows/:id/seasons/:season/episodes/:episode"; 41 | } 42 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Episodes/Watching.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 30 | $this->season = $season; 31 | $this->episode = $episode; 32 | } 33 | 34 | public function getRequestType() 35 | { 36 | return RequestType::GET; 37 | } 38 | 39 | public function getUri() 40 | { 41 | return "shows/:id/seasons/:season/episode/:episode/watching"; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Exception/CommentTooShortException.php: -------------------------------------------------------------------------------- 1 | message,$wrongCode,$expectedCode)); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Exception/HttpCodeException/BadRequestException.php: -------------------------------------------------------------------------------- 1 | message,$code)); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Exception/HttpCodeException/UnauthorizedException.php: -------------------------------------------------------------------------------- 1 | message, 0, $previousException); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Exception/TokenRequiredException.php: -------------------------------------------------------------------------------- 1 | type = $type; 30 | } 31 | 32 | public function getRequestType() 33 | { 34 | return RequestType::GET; 35 | } 36 | 37 | public function getType() 38 | { 39 | return $this->type; 40 | } 41 | 42 | public function getUri() 43 | { 44 | return "genres/list/:type"; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Aliases.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "movies/:id/aliases"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Collected.php: -------------------------------------------------------------------------------- 1 | period = $period; 24 | } 25 | 26 | public function getRequestType() 27 | { 28 | return RequestType::GET; 29 | } 30 | 31 | public function getUri() 32 | { 33 | return "movies/collected/:period"; 34 | } 35 | 36 | /** 37 | * @return null 38 | */ 39 | public function getPeriod() 40 | { 41 | return $this->period; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Comments.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 28 | // $this->setResponseHandler(new CommentsHandler()); 29 | } 30 | 31 | public function getRequestType() 32 | { 33 | return RequestType::GET; 34 | } 35 | 36 | public function getUri() 37 | { 38 | return "movies/:id/comments"; 39 | } 40 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/People.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "movies/:id/people"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Played.php: -------------------------------------------------------------------------------- 1 | period = $period; 24 | } 25 | 26 | public function getRequestType() 27 | { 28 | return RequestType::GET; 29 | } 30 | 31 | public function getUri() 32 | { 33 | return "movies/played/:period"; 34 | } 35 | 36 | /** 37 | * @return null 38 | */ 39 | public function getPeriod() 40 | { 41 | return $this->period; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Popular.php: -------------------------------------------------------------------------------- 1 | setResponseHandler(new PopularHandler()); 23 | } 24 | 25 | public function getRequestType() 26 | { 27 | return RequestType::GET; 28 | } 29 | 30 | public function getUri() 31 | { 32 | return "movies/popular"; 33 | } 34 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Ratings.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "movies/:id/ratings"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Related.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "movies/:id/related"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Releases.php: -------------------------------------------------------------------------------- 1 | country = $country; 33 | $this->id = $mediaId; 34 | } 35 | 36 | public function getRequestType() 37 | { 38 | return RequestType::GET; 39 | } 40 | 41 | /** 42 | * @return Country 43 | */ 44 | public function getCountry() 45 | { 46 | return $this->country; 47 | } 48 | 49 | public function getUri() 50 | { 51 | return "movies/:id/releases/:country"; 52 | } 53 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Stats.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "movies/:id/stats"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Summary.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 30 | $this->setToken($token); 31 | $this->setResponseHandler(new SummaryHandler()); 32 | } 33 | 34 | public function getRequestType() 35 | { 36 | return RequestType::GET; 37 | } 38 | 39 | public function getUri() 40 | { 41 | return "movies/:id"; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Translations.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 33 | $this->language = $language; 34 | } 35 | 36 | public function getRequestType() 37 | { 38 | return RequestType::GET; 39 | } 40 | 41 | /** 42 | * @return string 43 | */ 44 | public function getLanguage() 45 | { 46 | return $this->language; 47 | } 48 | 49 | 50 | public function getUri() 51 | { 52 | return "movies/:id/translations/:language"; 53 | } 54 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Trending.php: -------------------------------------------------------------------------------- 1 | setResponseHandler(new TrendingHandler()); 24 | } 25 | 26 | public function getRequestType() 27 | { 28 | return RequestType::GET; 29 | } 30 | 31 | public function getUri() 32 | { 33 | return "movies/trending"; 34 | } 35 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Watched.php: -------------------------------------------------------------------------------- 1 | period = $period; 24 | } 25 | 26 | public function getRequestType() 27 | { 28 | return RequestType::GET; 29 | } 30 | 31 | public function getUri() 32 | { 33 | return "movies/watched/:period"; 34 | } 35 | 36 | /** 37 | * @return mixed 38 | */ 39 | public function getPeriod() 40 | { 41 | return $this->period; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Movies/Watching.php: -------------------------------------------------------------------------------- 1 | id = $id; 28 | } 29 | 30 | 31 | public function getRequestType() 32 | { 33 | return RequestType::GET; 34 | } 35 | 36 | public function getUri() 37 | { 38 | return "movies/:id/watching"; 39 | } 40 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Parameters/AbstractParameter.php: -------------------------------------------------------------------------------- 1 | value = $value; 26 | } 27 | 28 | public function __toString() 29 | { 30 | return (string)$this->value; 31 | } 32 | 33 | /** 34 | * @param $value 35 | * @return static 36 | */ 37 | public static function set($value) 38 | { 39 | return new static($value); 40 | } 41 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Parameters/IdType.php: -------------------------------------------------------------------------------- 1 | id; 25 | } 26 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Parameters/Parameter.php: -------------------------------------------------------------------------------- 1 | startDate = $startDate; 33 | } 34 | 35 | public function setDays($days = null) 36 | { 37 | if (is_null($days)) { 38 | $days = 7; 39 | } 40 | 41 | $this->days = $days; 42 | } 43 | 44 | public function getStartDate() 45 | { 46 | return $this->startDate->format("Y-m-d"); 47 | } 48 | 49 | public function getDays() 50 | { 51 | return $this->days; 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Parameters/Type.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "people/:id/movies"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/People/Shows.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 30 | } 31 | 32 | public function getRequestType() 33 | { 34 | return RequestType::GET; 35 | } 36 | 37 | public function getUri() 38 | { 39 | return "people/:id/shows"; 40 | } 41 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/People/Summary.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "people/:id"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Recommendations/Dismiss/Movie.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 29 | } 30 | 31 | public function getRequestType() 32 | { 33 | return RequestType::DELETE; 34 | } 35 | 36 | public function getUri() 37 | { 38 | return "recommendations/movies/:id"; 39 | } 40 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Recommendations/Dismiss/Show.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 29 | } 30 | 31 | public function getRequestType() 32 | { 33 | return RequestType::DELETE; 34 | } 35 | 36 | public function getUri() 37 | { 38 | return "recommendations/shows/:id"; 39 | } 40 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Recommendations/Movies.php: -------------------------------------------------------------------------------- 1 | setToken($token); 25 | } 26 | 27 | public function getRequestType() 28 | { 29 | return RequestType::GET; 30 | } 31 | 32 | public function getUri() 33 | { 34 | return "recommendations/movies"; 35 | } 36 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Recommendations/Shows.php: -------------------------------------------------------------------------------- 1 | setToken($token); 22 | } 23 | 24 | public function getRequestType() 25 | { 26 | return RequestType::GET; 27 | } 28 | 29 | public function getUri() 30 | { 31 | return "recommendations/shows"; 32 | } 33 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/RequestType.php: -------------------------------------------------------------------------------- 1 | setToken($token); 33 | $this->media = $media; 34 | $this->progress = $progress; 35 | } 36 | 37 | public function getUri() 38 | { 39 | return "scrobble/pause"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Scrobble/ScrobblerTrait.php: -------------------------------------------------------------------------------- 1 | media->getType() => $this->media->getStandardFields(), 30 | 'progress' => $this->progress 31 | ]; 32 | } 33 | 34 | public function getRequestType() 35 | { 36 | return RequestType::POST; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Scrobble/Start.php: -------------------------------------------------------------------------------- 1 | setToken($token); 29 | $this->media = $media; 30 | $this->progress = $progress; 31 | } 32 | 33 | public function getUri() 34 | { 35 | return "scrobble/start"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Scrobble/Stop.php: -------------------------------------------------------------------------------- 1 | setToken($token); 32 | $this->media = $media; 33 | $this->progress = $progress; 34 | } 35 | 36 | public function getUri() 37 | { 38 | return "scrobble/stop"; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Search/ById.php: -------------------------------------------------------------------------------- 1 | setQueryParams( 28 | [ 29 | "id_type" => $idType, 30 | "id" => $mediaId 31 | ] 32 | ); 33 | if ($token !== null) { 34 | $this->setToken($token); 35 | } 36 | $this->setResponseHandler(new SearchHandler()); 37 | } 38 | 39 | public function getRequestType() 40 | { 41 | return RequestType::GET; 42 | } 43 | 44 | public function getUri() 45 | { 46 | return "search"; 47 | } 48 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Seasons/Comments.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 32 | $this->season = $season; 33 | } 34 | 35 | public function getRequestType() 36 | { 37 | return RequestType::GET; 38 | } 39 | 40 | /** 41 | * @return Season 42 | */ 43 | public function getSeason() 44 | { 45 | return $this->season; 46 | } 47 | 48 | public function getUri() 49 | { 50 | return "shows/:id/seasons/:season/comments"; 51 | } 52 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Seasons/Ratings.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 32 | $this->season = $season; 33 | } 34 | 35 | public function getRequestType() 36 | { 37 | return RequestType::GET; 38 | } 39 | 40 | /** 41 | * @return Season 42 | */ 43 | public function getSeason() 44 | { 45 | return $this->season; 46 | } 47 | 48 | public function getUri() 49 | { 50 | return "shows/:id/seasons/:season/ratings"; 51 | } 52 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Seasons/Season.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 32 | $this->season = $season; 33 | } 34 | 35 | public function getRequestType() 36 | { 37 | return RequestType::GET; 38 | } 39 | 40 | /** 41 | * @return Season 42 | */ 43 | public function getSeason() 44 | { 45 | return $this->season; 46 | } 47 | 48 | public function getUri() 49 | { 50 | return "shows/:id/seasons/:season"; 51 | } 52 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Seasons/Summary.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "shows/:id/seasons"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Seasons/Watching.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 32 | $this->season = $season; 33 | } 34 | 35 | public function getRequestType() 36 | { 37 | return RequestType::GET; 38 | } 39 | 40 | /** 41 | * @return Season 42 | */ 43 | public function getSeason() 44 | { 45 | return $this->season; 46 | } 47 | 48 | public function getUri() 49 | { 50 | return "shows/:id/seasons/:season/watching"; 51 | } 52 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Aliases.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "shows/:id/aliases"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Collected.php: -------------------------------------------------------------------------------- 1 | period = $period; 24 | } 25 | 26 | public function getRequestType() 27 | { 28 | return RequestType::GET; 29 | } 30 | 31 | public function getUri() 32 | { 33 | return "shows/collected/:period"; 34 | } 35 | 36 | /** 37 | * @return null 38 | */ 39 | public function getPeriod() 40 | { 41 | return $this->period; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Comments.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 28 | $this->setResponseHandler(new CommentsHandler()); 29 | } 30 | 31 | public function getRequestType() 32 | { 33 | return RequestType::GET; 34 | } 35 | 36 | public function getUri() 37 | { 38 | return "shows/:id/comments"; 39 | } 40 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/People.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "shows/:id/people"; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Played.php: -------------------------------------------------------------------------------- 1 | period = $period; 24 | } 25 | 26 | public function getRequestType() 27 | { 28 | return RequestType::GET; 29 | } 30 | 31 | public function getUri() 32 | { 33 | return "shows/played/:period"; 34 | } 35 | 36 | /** 37 | * @return null 38 | */ 39 | public function getPeriod() 40 | { 41 | return $this->period; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Popular.php: -------------------------------------------------------------------------------- 1 | setToken($token); 29 | $this->id = $mediaId; 30 | } 31 | 32 | public function getRequestType() 33 | { 34 | return RequestType::GET; 35 | } 36 | 37 | public function getUri() 38 | { 39 | return "shows/:id/progress/collection"; 40 | } 41 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Progress/Watched.php: -------------------------------------------------------------------------------- 1 | setToken($token); 29 | $this->id = $mediaId; 30 | } 31 | 32 | public function getRequestType() 33 | { 34 | return RequestType::GET; 35 | } 36 | 37 | public function getUri() 38 | { 39 | return "shows/:id/progress/watched"; 40 | } 41 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Ratings.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 28 | } 29 | 30 | public function getRequestType() 31 | { 32 | return RequestType::GET; 33 | } 34 | 35 | public function getUri() 36 | { 37 | return "shows/:id/ratings"; 38 | } 39 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Related.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 28 | } 29 | 30 | public function getRequestType() 31 | { 32 | return RequestType::GET; 33 | } 34 | 35 | public function getUri() 36 | { 37 | return "shows/:id/related"; 38 | } 39 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Stats.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 28 | } 29 | 30 | public function getRequestType() 31 | { 32 | return RequestType::GET; 33 | } 34 | 35 | public function getUri() 36 | { 37 | return "shows/:id/stats"; 38 | } 39 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Summary.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 29 | // $this->setResponseHandler(new SummaryHandler()); 30 | } 31 | 32 | public function getRequestType() 33 | { 34 | return RequestType::GET; 35 | } 36 | 37 | public function getUri() 38 | { 39 | return "shows/:id"; 40 | } 41 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Translations.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 33 | $this->language = $language; 34 | } 35 | 36 | public function getRequestType() 37 | { 38 | return RequestType::GET; 39 | } 40 | 41 | /** 42 | * @return string 43 | */ 44 | public function getLanguage() 45 | { 46 | return $this->language; 47 | } 48 | 49 | 50 | public function getUri() 51 | { 52 | return "shows/:id/translations/:language"; 53 | } 54 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Trending.php: -------------------------------------------------------------------------------- 1 | setStartDate($date); 25 | } 26 | 27 | public function getRequestType() 28 | { 29 | return RequestType::GET; 30 | } 31 | 32 | public function getUri() 33 | { 34 | return "shows/updates/:start_date"; 35 | } 36 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Watched.php: -------------------------------------------------------------------------------- 1 | period = $period; 24 | } 25 | 26 | public function getRequestType() 27 | { 28 | return RequestType::GET; 29 | } 30 | 31 | public function getUri() 32 | { 33 | return "shows/watched/:period"; 34 | } 35 | 36 | /** 37 | * @return mixed 38 | */ 39 | public function getPeriod() 40 | { 41 | return $this->period; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Shows/Watching.php: -------------------------------------------------------------------------------- 1 | id = $mediaId; 28 | } 29 | 30 | 31 | public function getRequestType() 32 | { 33 | return RequestType::GET; 34 | } 35 | 36 | public function getUri() 37 | { 38 | return "shows/:id/watching"; 39 | } 40 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Collection/Add.php: -------------------------------------------------------------------------------- 1 | items = $items; 26 | } 27 | 28 | public function getRequestType() 29 | { 30 | return RequestType::POST; 31 | } 32 | 33 | public function getUri() 34 | { 35 | return "sync/collection"; 36 | } 37 | 38 | protected function getPostBody() 39 | { 40 | return $this->items; 41 | } 42 | 43 | 44 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Collection/Get.php: -------------------------------------------------------------------------------- 1 | setToken($token); 22 | $this->type = $type; 23 | } 24 | 25 | /** 26 | * @return mixed 27 | */ 28 | public function getType() 29 | { 30 | return $this->type; 31 | } 32 | 33 | public function getRequestType() 34 | { 35 | return RequestType::GET; 36 | } 37 | 38 | public function getUri() 39 | { 40 | return 'sync/collection/:type'; 41 | } 42 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Collection/Remove.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->items = $items; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::POST; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "sync/collection/remove"; 37 | } 38 | 39 | protected function getPostBody() 40 | { 41 | return $this->items; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/History/Add.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->items = $items; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::POST; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "sync/history"; 37 | } 38 | 39 | protected function getPostBody() 40 | { 41 | return $this->items; 42 | } 43 | 44 | 45 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/History/Get.php: -------------------------------------------------------------------------------- 1 | setToken($token); 31 | $this->id = $id; 32 | $this->type = $type; 33 | } 34 | 35 | public function getRequestType() 36 | { 37 | return RequestType::GET; 38 | } 39 | 40 | public function getUri() 41 | { 42 | 43 | return (!is_null($this->id)) ? "sync/history/:type/:id" : "sync/history/:type"; 44 | } 45 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/History/Remove.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | 27 | $this->items = $items; 28 | } 29 | 30 | public function getRequestType() 31 | { 32 | return RequestType::POST; 33 | } 34 | 35 | public function getUri() 36 | { 37 | return "sync/history/remove"; 38 | } 39 | 40 | protected function getPostBody() 41 | { 42 | return $this->items; 43 | } 44 | 45 | 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/LastActivities.php: -------------------------------------------------------------------------------- 1 | setToken($token); 18 | } 19 | 20 | public function getRequestType() 21 | { 22 | return RequestType::GET; 23 | } 24 | 25 | public function getUri() 26 | { 27 | return "sync/last_activities"; 28 | } 29 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Playback.php: -------------------------------------------------------------------------------- 1 | setToken($token); 27 | $this->type = $type; 28 | } 29 | 30 | /** 31 | * @return mixed 32 | */ 33 | public function getType() 34 | { 35 | return $this->type; 36 | } 37 | 38 | public function getRequestType() 39 | { 40 | return RequestType::GET; 41 | } 42 | 43 | public function getUri() 44 | { 45 | return "sync/playback/:type"; 46 | } 47 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Ratings/Add.php: -------------------------------------------------------------------------------- 1 | items = $items; 26 | } 27 | 28 | public function getRequestType() 29 | { 30 | return RequestType::POST; 31 | } 32 | 33 | public function getUri() 34 | { 35 | return "sync/ratings"; 36 | } 37 | 38 | protected function getPostBody() 39 | { 40 | return $this->items; 41 | } 42 | 43 | 44 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Ratings/Get.php: -------------------------------------------------------------------------------- 1 | setToken($token); 31 | $this->rating = $rating; 32 | $this->type = $type; 33 | } 34 | 35 | /** 36 | * @return mixed 37 | */ 38 | public function getType() 39 | { 40 | return $this->type; 41 | } 42 | 43 | /** 44 | * @return null 45 | */ 46 | public function getRating() 47 | { 48 | return $this->rating; 49 | } 50 | 51 | public function getRequestType() 52 | { 53 | return RequestType::GET; 54 | } 55 | 56 | public function getUri() 57 | { 58 | return (!is_null($this->rating)) 59 | ? "sync/ratings/:type/:rating" 60 | : "sync/ratings/:type"; 61 | } 62 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Ratings/Remove.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->items = $items; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::POST; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "sync/ratings/remove"; 37 | } 38 | 39 | protected function getPostBody() 40 | { 41 | return $this->items; 42 | } 43 | 44 | 45 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Watched.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->type = $type; 27 | } 28 | 29 | /** 30 | * @return mixed 31 | */ 32 | public function getType() 33 | { 34 | return $this->type; 35 | } 36 | 37 | public function getRequestType() 38 | { 39 | return RequestType::GET; 40 | } 41 | 42 | public function getUri() 43 | { 44 | return "sync/watched/:type"; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Watchlist/Add.php: -------------------------------------------------------------------------------- 1 | items = $items; 26 | } 27 | 28 | public function getRequestType() 29 | { 30 | return RequestType::POST; 31 | } 32 | 33 | public function getUri() 34 | { 35 | return "sync/watchlist"; 36 | } 37 | 38 | protected function getPostBody() 39 | { 40 | return $this->items; 41 | } 42 | 43 | 44 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Watchlist/Get.php: -------------------------------------------------------------------------------- 1 | setToken($token); 22 | $this->type = $type; 23 | } 24 | 25 | /** 26 | * @return mixed 27 | */ 28 | public function getType() 29 | { 30 | return $this->type; 31 | } 32 | 33 | public function getRequestType() 34 | { 35 | return RequestType::GET; 36 | } 37 | 38 | public function getUri() 39 | { 40 | return (!is_null($this->type)) 41 | ? 'sync/watchlist/:type' 42 | : "sync/watchlist"; 43 | } 44 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Sync/Watchlist/Remove.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->items = $items; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::POST; 32 | } 33 | 34 | public function getUri() 35 | { 36 | return "sync/watchlist/remove"; 37 | } 38 | 39 | protected function getPostBody() 40 | { 41 | return $this->items; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Collection.php: -------------------------------------------------------------------------------- 1 | setToken($token); 30 | $this->type = $type; 31 | $this->username = $username; 32 | } 33 | 34 | public function getRequestType() 35 | { 36 | return RequestType::GET; 37 | } 38 | 39 | public function getUri() 40 | { 41 | return "users/:username/collection/:type"; 42 | } 43 | 44 | /** 45 | * @return mixed 46 | */ 47 | public function getType() 48 | { 49 | return $this->type; 50 | } 51 | 52 | /** 53 | * @return mixed 54 | */ 55 | public function getUsername() 56 | { 57 | return $this->username; 58 | } 59 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Comments.php: -------------------------------------------------------------------------------- 1 | setToken($token); 34 | $this->type = $type; 35 | $this->commentType = $commentType; 36 | $this->username = $username; 37 | } 38 | 39 | /** 40 | * @return mixed 41 | */ 42 | public function getCommentType() 43 | { 44 | return $this->commentType; 45 | } 46 | 47 | /** 48 | * @return mixed 49 | */ 50 | public function getType() 51 | { 52 | return $this->type; 53 | } 54 | 55 | /** 56 | * @return mixed 57 | */ 58 | public function getUsername() 59 | { 60 | return $this->username; 61 | } 62 | 63 | 64 | public function getRequestType() 65 | { 66 | return RequestType::GET; 67 | } 68 | 69 | public function getUri() 70 | { 71 | return "users/:username/comments/:commentType/:type"; 72 | } 73 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Follow.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->username = $username; 27 | } 28 | 29 | /** 30 | * @return mixed 31 | */ 32 | public function getUsername() 33 | { 34 | return $this->username; 35 | } 36 | 37 | public function getRequestType() 38 | { 39 | return RequestType::POST; 40 | } 41 | 42 | public function getUri() 43 | { 44 | return 'users/:username/follow'; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Followers/Approve.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->id = $followerRequestId; 27 | } 28 | 29 | /** 30 | * @return int 31 | */ 32 | public function getId() 33 | { 34 | return $this->id; 35 | } 36 | 37 | public function getRequestType() 38 | { 39 | return RequestType::POST; 40 | } 41 | 42 | 43 | public function getUri() 44 | { 45 | return "users/requests/:id"; 46 | } 47 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Followers/Deny.php: -------------------------------------------------------------------------------- 1 | setToken($token); 27 | $this->id = $followerRequestId; 28 | } 29 | 30 | public function getId() 31 | { 32 | return $this->id; 33 | } 34 | 35 | public function getRequestType() 36 | { 37 | return RequestType::DELETE; 38 | } 39 | 40 | 41 | public function getUri() 42 | { 43 | return "users/requests/:id"; 44 | } 45 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Followers/Get.php: -------------------------------------------------------------------------------- 1 | setToken($token); 17 | } 18 | 19 | public function getRequestType() 20 | { 21 | return RequestType::GET; 22 | } 23 | 24 | public function getUri() 25 | { 26 | return "users/requests"; 27 | } 28 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Following.php: -------------------------------------------------------------------------------- 1 | username = $username; 26 | } 27 | 28 | /** 29 | * @return mixed 30 | */ 31 | public function getUsername() 32 | { 33 | return $this->username; 34 | } 35 | 36 | 37 | public function getRequestType() 38 | { 39 | return RequestType::GET; 40 | } 41 | 42 | public function getUri() 43 | { 44 | return 'users/:username/following'; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Friends.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->username = $username; 27 | } 28 | 29 | /** 30 | * @return mixed 31 | */ 32 | public function getUsername() 33 | { 34 | return $this->username; 35 | } 36 | 37 | 38 | public function getRequestType() 39 | { 40 | return RequestType::GET; 41 | } 42 | 43 | public function getUri() 44 | { 45 | return 'users/:username/friends'; 46 | } 47 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Hidden.php: -------------------------------------------------------------------------------- 1 | setToken($token); 31 | $this->section = $section; 32 | $this->type = $type; 33 | } 34 | 35 | /** 36 | * @return string 37 | */ 38 | public function getSection() 39 | { 40 | return $this->section; 41 | } 42 | 43 | /** 44 | * @return string 45 | */ 46 | public function getType() 47 | { 48 | return $this->type; 49 | } 50 | 51 | 52 | public function getRequestType() 53 | { 54 | return RequestType::GET; 55 | } 56 | 57 | public function getUri() 58 | { 59 | return "users/hidden/:section?type=:type"; 60 | } 61 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Likes.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->type = $type; 27 | } 28 | 29 | /** 30 | * @return mixed 31 | */ 32 | public function getType() 33 | { 34 | return $this->type; 35 | } 36 | 37 | public function getRequestType() 38 | { 39 | return RequestType::GET; 40 | } 41 | 42 | public function getUri() 43 | { 44 | return 'users/likes/:type'; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Lists/Create.php: -------------------------------------------------------------------------------- 1 | setToken($token); 31 | 32 | $this->list = $list; 33 | $this->username = $username; 34 | } 35 | 36 | /** 37 | * @return mixed 38 | */ 39 | public function getUsername() 40 | { 41 | return $this->username; 42 | } 43 | 44 | public function getRequestType() 45 | { 46 | return RequestType::POST; 47 | } 48 | 49 | public function getUri() 50 | { 51 | return 'users/:username/lists'; 52 | } 53 | 54 | protected function getPostBody() 55 | { 56 | return $this->list; 57 | } 58 | 59 | 60 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Lists/Delete.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | 27 | $this->listId = $listId; 28 | $this->username = $username; 29 | } 30 | 31 | public function getRequestType() 32 | { 33 | return RequestType::DELETE; 34 | } 35 | 36 | /** 37 | * @return mixed 38 | */ 39 | public function getId() 40 | { 41 | return $this->listId; 42 | } 43 | 44 | /** 45 | * @return mixed 46 | */ 47 | public function getUsername() 48 | { 49 | return $this->username; 50 | } 51 | 52 | public function getUri() 53 | { 54 | return 'users/:username/lists/:id'; 55 | } 56 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Lists/Get.php: -------------------------------------------------------------------------------- 1 | setToken($token); 31 | $this->username = $username; 32 | $this->listId = $listId; 33 | } 34 | 35 | /** 36 | * @return array 37 | */ 38 | public function getUsername() 39 | { 40 | return $this->username; 41 | } 42 | 43 | /** 44 | * @return null 45 | */ 46 | public function getListId() 47 | { 48 | return $this->listId; 49 | } 50 | 51 | public function getRequestType() 52 | { 53 | return RequestType::GET; 54 | } 55 | 56 | public function getUri() 57 | { 58 | return ($this->listId === null) ? 'users/:username/lists' : 'users/:username/lists/:listId'; 59 | } 60 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Lists/Like/Create.php: -------------------------------------------------------------------------------- 1 | setToken($token); 31 | 32 | $this->listId = $listId; 33 | $this->username = $username; 34 | } 35 | 36 | public function getRequestType() 37 | { 38 | return RequestType::POST; 39 | } 40 | 41 | /** 42 | * @return mixed 43 | */ 44 | public function getId() 45 | { 46 | return $this->listId; 47 | } 48 | 49 | /** 50 | * @return mixed 51 | */ 52 | public function getUsername() 53 | { 54 | return $this->username; 55 | } 56 | 57 | 58 | public function getUri() 59 | { 60 | return "users/:username/lists/:id/like"; 61 | } 62 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Lists/Like/Delete.php: -------------------------------------------------------------------------------- 1 | setToken($token); 31 | 32 | $this->listId = $listId; 33 | $this->username = $username; 34 | } 35 | 36 | public function getRequestType() 37 | { 38 | return RequestType::POST; 39 | } 40 | 41 | /** 42 | * @return mixed 43 | */ 44 | public function getId() 45 | { 46 | return $this->listId; 47 | } 48 | 49 | /** 50 | * @return mixed 51 | */ 52 | public function getUsername() 53 | { 54 | return $this->username; 55 | } 56 | 57 | 58 | public function getUri() 59 | { 60 | return "users/:username/lists/:id/like"; 61 | } 62 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Lists/Remove.php: -------------------------------------------------------------------------------- 1 | setToken($token); 36 | 37 | $this->itemsToRemove = $itemsToRemove; 38 | $this->listId = $listId; 39 | $this->username = $username; 40 | } 41 | 42 | public function getRequestType() 43 | { 44 | return RequestType::POST; 45 | } 46 | 47 | public function getUri() 48 | { 49 | return 'users/:username/lists/:id/items/remove'; 50 | } 51 | 52 | protected function getPostBody() 53 | { 54 | return $this->itemsToRemove; 55 | } 56 | 57 | 58 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Lists/Update.php: -------------------------------------------------------------------------------- 1 | setToken($token); 36 | $this->id = $id; 37 | $this->username = $username; 38 | $this->updates = $updates; 39 | } 40 | 41 | /** 42 | * @return mixed 43 | */ 44 | public function getUsername() 45 | { 46 | return $this->username; 47 | } 48 | 49 | /** 50 | * @return mixed 51 | */ 52 | public function getId() 53 | { 54 | return $this->id; 55 | } 56 | 57 | 58 | public function getRequestType() 59 | { 60 | return RequestType::PUT; 61 | } 62 | 63 | public function getUri() 64 | { 65 | return 'users/:username/lists/:id'; 66 | } 67 | 68 | protected function getPostBody() 69 | { 70 | return $this->updates; 71 | } 72 | 73 | 74 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Profile.php: -------------------------------------------------------------------------------- 1 | setToken($token); 24 | $this->username = $username; 25 | } 26 | 27 | public function getRequestType() 28 | { 29 | return RequestType::GET; 30 | } 31 | 32 | public function getUri() 33 | { 34 | return "users/:username"; 35 | } 36 | 37 | /** 38 | * @return string 39 | */ 40 | public function getUsername() 41 | { 42 | return $this->username; 43 | } 44 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Ratings.php: -------------------------------------------------------------------------------- 1 | setToken($token); 36 | $this->rating = $rating; 37 | $this->type = $type; 38 | $this->username = $username; 39 | } 40 | 41 | public function getRequestType() 42 | { 43 | return RequestType::GET; 44 | } 45 | 46 | /** 47 | * @return null 48 | */ 49 | public function getRating() 50 | { 51 | return $this->rating; 52 | } 53 | 54 | /** 55 | * @return mixed 56 | */ 57 | public function getType() 58 | { 59 | return $this->type; 60 | } 61 | 62 | /** 63 | * @return mixed 64 | */ 65 | public function getUsername() 66 | { 67 | return $this->username; 68 | } 69 | 70 | 71 | public function getUri() 72 | { 73 | if (!is_null($this->rating)) { 74 | return "users/:username/ratings/:type/:rating"; 75 | } 76 | 77 | return "users/:username/ratings/:type"; 78 | } 79 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Settings.php: -------------------------------------------------------------------------------- 1 | setToken($token); 22 | } 23 | 24 | public function getRequestType() 25 | { 26 | return RequestType::GET; 27 | } 28 | 29 | public function getUri() 30 | { 31 | return "users/settings"; 32 | } 33 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Stats.php: -------------------------------------------------------------------------------- 1 | setToken($token); 26 | $this->username = $username; 27 | } 28 | 29 | public function getRequestType() 30 | { 31 | return RequestType::GET; 32 | } 33 | 34 | /** 35 | * @return mixed 36 | */ 37 | public function getUsername() 38 | { 39 | return $this->username; 40 | } 41 | 42 | public function getUri() 43 | { 44 | return 'users/:username/stats'; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Watching.php: -------------------------------------------------------------------------------- 1 | username = $username; 27 | } 28 | 29 | /** 30 | * @return mixed 31 | */ 32 | public function getUsername() 33 | { 34 | return $this->username; 35 | } 36 | 37 | public function getRequestType() 38 | { 39 | return RequestType::GET; 40 | } 41 | 42 | public function getUri() 43 | { 44 | return 'users/:username/watching'; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Request/Users/Watchlist.php: -------------------------------------------------------------------------------- 1 | setToken($token); 32 | $this->type = $type; 33 | $this->username = $username; 34 | } 35 | 36 | 37 | public function getRequestType() 38 | { 39 | return RequestType::GET; 40 | } 41 | 42 | public function getUri() 43 | { 44 | 45 | return (!is_null($this->type)) 46 | ? "users/:username/watchlist/:type" 47 | : "users/:username/watchlist"; 48 | } 49 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Calendar/Calendar.php: -------------------------------------------------------------------------------- 1 | id = $id; 49 | $this->token = $token; 50 | $this->type = $type; 51 | $this->client = $client; 52 | 53 | $this->setDays($json); 54 | 55 | } 56 | 57 | /** 58 | * @param $json 59 | * @return Day[] 60 | */ 61 | private function setDays($json) 62 | { 63 | foreach ($json as $date => $movies) { 64 | $this->days[] = new Day($date, $movies, $this->type, $this->id, $this->token, $this->client); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/Calendars/MoviesHandler.php: -------------------------------------------------------------------------------- 1 | getJson($response); 32 | 33 | return new Calendar($json, Type::movie(), $this->getClientId(), $this->getToken(), $client); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/Calendars/Shows.php: -------------------------------------------------------------------------------- 1 | getJson($response); 29 | 30 | return $this->toDays($json); 31 | } 32 | 33 | /** 34 | * @param $json 35 | * @return Day[] 36 | */ 37 | private function toDays($json) 38 | { 39 | $days = []; 40 | 41 | foreach ($json as $date => $movies) { 42 | $days[] = new Day($date, $movies, Type::show(), $this->getClientId(), $this->getToken()); 43 | } 44 | 45 | return $days; 46 | } 47 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/CheckIn/CheckInHandler.php: -------------------------------------------------------------------------------- 1 | getJson($response); 29 | 30 | return new CheckIn($object, $this->getClientId(), $this->getToken(), $client); 31 | } 32 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/Comments/CommentHandler.php: -------------------------------------------------------------------------------- 1 | getJson($response); 30 | 31 | // it are more comments 32 | if (is_array($response)) { 33 | return $this->createComments($response, $client); 34 | } 35 | // it's one comment 36 | return new Comment($response, $this->getClientId(), $client); 37 | 38 | } 39 | 40 | /** 41 | * @param array $response 42 | * @param \GuzzleHttp\ClientInterface $client 43 | * @return Comment[]\Collection 44 | */ 45 | private function createComments($response, \GuzzleHttp\ClientInterface $client) 46 | { 47 | $map = []; 48 | foreach ($response as $comment) { 49 | $map[] = new Comment($comment, $this->getClientId(), $client); 50 | } 51 | return collect($map); 52 | } 53 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/DefaultDeleteHandler.php: -------------------------------------------------------------------------------- 1 | getStatusCode() === 204); 28 | } 29 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/DefaultResponseHandler.php: -------------------------------------------------------------------------------- 1 | getJson($response); 27 | return (is_array($json)) ? collect($json) : collect([$json]); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/Movies/CommentsHandler.php: -------------------------------------------------------------------------------- 1 | getJson($response); 29 | 30 | return $this->makeComments($json); 31 | 32 | } 33 | 34 | /** 35 | * @param $json 36 | * @return array 37 | */ 38 | private function makeComments($json) 39 | { 40 | $comments = []; 41 | 42 | foreach ($json as $item) { 43 | $comments[] = new Comment($item, $this->getClientId(), $this->getToken()); 44 | } 45 | return collect($comments); 46 | } 47 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/Movies/PopularHandler.php: -------------------------------------------------------------------------------- 1 | getJson($response); 28 | 29 | return $this->makeMovies($json); 30 | } 31 | 32 | /** 33 | * @param $json 34 | * @return array 35 | */ 36 | private function makeMovies($json) 37 | { 38 | $movies = []; 39 | 40 | foreach ($json as $item) { 41 | $movies[] = new Movie($item, $this->getClientId(), $this->getToken()); 42 | } 43 | 44 | return $movies; 45 | } 46 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/Movies/SummaryHandler.php: -------------------------------------------------------------------------------- 1 | getJson($response); 23 | 24 | return new Movie($json, $this->getClientId(), $this->getToken(), $client); 25 | } 26 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/Movies/TrendingHandler.php: -------------------------------------------------------------------------------- 1 | getJson($response); 28 | 29 | return $this->makeTrendingObjects($json); 30 | } 31 | 32 | /** 33 | * @param $json 34 | * @return array 35 | */ 36 | private function makeTrendingObjects($json) 37 | { 38 | $trending = []; 39 | foreach ($json as $trendingItem) { 40 | $trending[] = new Trending($trendingItem, $this->getClientId(), $this->getToken()); 41 | } 42 | return $trending; 43 | } 44 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Handlers/Movies/UpdatedHandler.php: -------------------------------------------------------------------------------- 1 | transformToObjects($response, Updated::class, $client); 23 | } 24 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/People.php: -------------------------------------------------------------------------------- 1 | cast = $json->cast; 28 | 29 | $this->crew = $json->crew; 30 | } 31 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Trending.php: -------------------------------------------------------------------------------- 1 | watchers = $json->watchers; 34 | $this->movie = new Movie($json->movie, $id, $token, $client); 35 | } 36 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/Response/Updated.php: -------------------------------------------------------------------------------- 1 | updated_at)); 40 | $this->updatedAt = Carbon::createFromTimestamp($timestamp); 41 | $this->movie = new Movie($json, $clientId, $token, $client); 42 | } 43 | } -------------------------------------------------------------------------------- /src/Wubs/Trakt/TraktHttpClient.php: -------------------------------------------------------------------------------- 1 | [static::API_SCHEME . '://' . $host, ['version' => static::API_VERSION]]]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Api/CheckOutRequestTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive("createRequest")->andReturn($request); 25 | $client->shouldReceive("send")->once()->andReturn($response); 26 | $response->shouldReceive("getStatusCode")->twice()->andReturn(204); 27 | 28 | $trakt = new Trakt(mock_auth(), $client); 29 | 30 | $this->assertTrue($trakt->checkIn->delete(get_token())); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Api/EpisodesRequestTest.php: -------------------------------------------------------------------------------- 1 | episodes->comments(8, 2, 1); 42 | 43 | $this->assertInstanceOf(Collection::class, $comments); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/Api/ExtendedInfoTest.php: -------------------------------------------------------------------------------- 1 | withImages()->withFull(); 28 | 29 | $calendar = $endpoint->shows(get_token()); 30 | 31 | $first = $calendar->first(); 32 | 33 | $this->assertObjectHasAttribute("images", $first->episode); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/Api/PropertiesTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(Followers::class, $trakt->users->followers); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/HowItShouldWorkTest.php: -------------------------------------------------------------------------------- 1 | trakt = new Trakt($auth, TraktHttpClient::make()); 35 | 36 | } 37 | 38 | /** 39 | * @expectedException Wubs\Trakt\Request\Exception\HttpCodeException\MethodNotFoundException; 40 | */ 41 | public function testPublicApi() 42 | { 43 | 44 | $popular = $this->trakt->movies->popular(); 45 | $this->assertInternalType("object", $popular); 46 | 47 | } 48 | 49 | public function testOAuthFlowAuthorization() 50 | { 51 | $provider = Mockery::mock(TraktProvider::class); 52 | $provider->shouldReceive("authorize")->once(); 53 | $provider->shouldReceive("getClientId")->once()->andReturn(get_client_id()); 54 | $auth = new Auth($provider); 55 | 56 | $trakt = new Trakt($auth, TraktHttpClient::make()); 57 | 58 | $trakt->auth->authorize(getenv("TRAKT_CLIENT_ID"), getenv("TRAKT_CLIENT_SECRET"), "uri"); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /tests/Request/Calendars/MoviesTest.php: -------------------------------------------------------------------------------- 1 | setToken(get_token()); 24 | 25 | $formatted = $request->getUrl(); 26 | 27 | $this->assertEquals("calendars/my/movies/2014-03-01/25", $formatted); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/Request/Calendars/PremieresTest.php: -------------------------------------------------------------------------------- 1 | subYears(3); 19 | $request = new NewShows(get_token(), $date, 500); 20 | 21 | $uri = $request->getUrl(); 22 | 23 | $this->assertContains($date->format("Y-m-d"), $uri); 24 | $this->assertContains("500", $uri); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/Request/Calendars/ShowsNewTest.php: -------------------------------------------------------------------------------- 1 | subYears(3); 19 | $request = new NewShows(get_token(), $startDate, 500); 20 | 21 | $url = $request->getUrl(); 22 | 23 | $this->assertEquals("calendars/my/shows/new/" . $startDate->format("Y-m-d") . "/500", $url); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/Request/Calendars/ShowsTest.php: -------------------------------------------------------------------------------- 1 | assertContains($today->format("Y-m-d"), (string)$request->getStartDate()); 24 | } 25 | 26 | public function testCallShowsRequestWith14Days() 27 | { 28 | $request = new NewShows(get_token(), Carbon::today(), 14); 29 | 30 | $this->assertContains("14", (string)$request->getDays()); 31 | } 32 | 33 | public function testWithDaysAndStartDate() 34 | { 35 | $startDate = Carbon::createFromFormat("Y-m-d", "2014-03-01"); 36 | $request = new Shows(get_token(), $startDate, 25); 37 | 38 | $this->assertContains("25", (string)$request->getDays()); 39 | $this->assertContains("2014-03-01", (string)$request->getStartDate()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/Request/CheckIn/MovieCheckInTest.php: -------------------------------------------------------------------------------- 1 | getUrl(); 30 | 31 | $type = $request->getRequestType(); 32 | 33 | $this->assertEquals(RequestType::POST, $type); 34 | $this->assertEquals("checkin", $url); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/Request/Comments/GetCommentTest.php: -------------------------------------------------------------------------------- 1 | getUrl(); 20 | 21 | $this->assertEquals("comments/41", $url); 22 | 23 | $this->assertEquals(RequestType::GET, $request->getRequestType()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/Request/Comments/RepliesTest.php: -------------------------------------------------------------------------------- 1 | assertEquals("comments/41/replies", $request->getUrl()); 21 | 22 | $this->assertEquals(RequestType::GET, $request->getRequestType()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/Request/Scrobble/ScrobbleTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(\Wubs\Trakt\Request\RequestType::POST, $request->getRequestType()); 10 | $request->make(get_client_id(), \Wubs\Trakt\TraktHttpClient::make(), new \Wubs\Trakt\Response\Handlers\DefaultResponseHandler()); 11 | } 12 | 13 | public function testCanPauseScrobble() 14 | { 15 | $client = Mockery::mock(\GuzzleHttp\ClientInterface::class); 16 | $request = new \Wubs\Trakt\Request\Scrobble\Pause(get_token(), movie($client), 5); 17 | $this->assertEquals(\Wubs\Trakt\Request\RequestType::POST, $request->getRequestType()); 18 | $request->make(get_client_id(), \Wubs\Trakt\TraktHttpClient::make(), new \Wubs\Trakt\Response\Handlers\DefaultResponseHandler()); 19 | } 20 | 21 | public function testCanStopScrobble() 22 | { 23 | $client = Mockery::mock(\GuzzleHttp\ClientInterface::class); 24 | $request = new \Wubs\Trakt\Request\Scrobble\Stop(get_token(), movie($client), 5); 25 | $this->assertEquals(\Wubs\Trakt\Request\RequestType::POST, $request->getRequestType()); 26 | $request->make(get_client_id(), \Wubs\Trakt\TraktHttpClient::make(), new \Wubs\Trakt\Response\Handlers\DefaultResponseHandler()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/Request/Search/TextTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(RequestType::GET, $request->getRequestType()); 25 | 26 | $this->assertEquals("search", $request->getUrl()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/Request/UriBuilderTest.php: -------------------------------------------------------------------------------- 1 | assertContains($formattedUri, $formattedUri); 25 | $this->assertContains(Carbon::now()->format("Y-m-d"), $formattedUri); 26 | 27 | } 28 | 29 | public function testReturnsFormattedUriFromRequestObjectWithParameterNotAsLastParameter() 30 | { 31 | $request = new Comments("guardians-of-the-galaxy-2014"); 32 | 33 | $formattedUri = UriBuilder::format($request); 34 | 35 | $this->assertContains("guardians-of-the-galaxy-2014", $formattedUri); 36 | $this->assertContains("/comments", $formattedUri); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/Request/Users/HistoryTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive("createRequest")->once()->andReturn($request); 24 | $response->shouldReceive("getStatusCode")->once()->andReturn(200); 25 | $response->shouldReceive("json")->once()->andReturn([]); 26 | $client->shouldReceive("send")->andReturn($response); 27 | 28 | $clientId = getenv("TRAKT_CLIENT_ID"); 29 | 30 | $response = (new History('rolle', Type::movies(), get_token()))->make($clientId, $client); 31 | 32 | $this->assertInternalType("object", $response); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/Request/Users/SettingsTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(RequestType::GET, $settingsRequest->getRequestType()); 20 | $this->assertEquals("users/settings", $settingsRequest->getUrl()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/RequestTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped(); 23 | try { 24 | $result = (new Movies(get_token(), Carbon::today(), 7))->make( 25 | get_client_id(), 26 | TraktHttpClient::make() 27 | ); 28 | 29 | $this->assertInternalType("object", $result); 30 | } catch (\GuzzleHttp\Exception\ClientException $exception) { 31 | if ($exception->getCode() === 401) $this->markTestSkipped('Test skipped because your token is outdated'); 32 | } 33 | } 34 | 35 | public function testRequestWithoutToken() 36 | { 37 | $response = (new History('megawubs', Type::movies()))->make(get_client_id(), TraktHttpClient::make()); 38 | 39 | $this->assertInternalType("object", $response); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /tests/TraktProviderTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(TraktProvider::class, $provider); 18 | } 19 | 20 | public function testAuthUrlHasClientId() 21 | { 22 | $clientId = getenv("TRAKT_CLIENT_ID"); 23 | $provider = new TraktProvider($clientId, getenv("TRAKT_CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI")); 24 | 25 | $authUrl = $provider->getAuthorizationUrl(); 26 | 27 | $this->assertContains(getenv("TRAKT_CLIENT_ID"), $authUrl); 28 | 29 | } 30 | 31 | public function testGetTraktAuthorizationUrl() 32 | { 33 | $clientId = get_client_id(); 34 | $provider = new TraktProvider($clientId, getenv("TRAKT_CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI")); 35 | $authUrl = $provider->getAuthorizationUrl(); 36 | 37 | $this->assertContains("https://trakt.tv/oauth/authorize", $authUrl); 38 | $this->assertContains(get_client_id(), $authUrl); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/TraktTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf("Wubs\\Trakt\\Trakt", $trakt); 23 | } 24 | 25 | public function testInvalidAuthorization() 26 | { 27 | $provider = new TraktProvider(getenv("TRAKT_CLIENT_ID"), getenv("TRAKT_CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI")); 28 | $auth = new Auth($provider); 29 | 30 | $trakt = new Trakt($auth, new Client()); 31 | $_SESSION['trakt_oauth_state'] = "ADifferentState"; 32 | $_GET['state'] = 'NotTheStateItShouldBe'; 33 | 34 | $test = $trakt->auth->isValid(); 35 | 36 | $this->assertFalse($test); 37 | } 38 | 39 | public function testValidAuthorization() 40 | { 41 | $provider = new TraktProvider(getenv("TRAKT_CLIENT_ID"), getenv("TRAKT_CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI")); 42 | $auth = new Auth($provider); 43 | 44 | $trakt = new Trakt($auth, new Client()); 45 | 46 | $_SESSION['trakt_oauth_state'] = "AState"; 47 | $_GET['state'] = 'AState'; 48 | 49 | $test = $trakt->auth->isValid(); 50 | 51 | $this->assertTrue($test); 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/TraktTokenTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(getenv("TRAKT_ACCESS_TOKEN"), $token->accessToken); 25 | $this->assertEquals(time() + ((int)getenv("TRAKT_EXPIRES_IN")), $token->expires); 26 | $this->assertEquals(getenv("TRAKT_REFRESH_TOKEN"), $token->refreshToken); 27 | } 28 | } 29 | --------------------------------------------------------------------------------