forked from UweTrottmann/trakt-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSync.java
More file actions
533 lines (487 loc) · 16.5 KB
/
Sync.java
File metadata and controls
533 lines (487 loc) · 16.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
/*
* Copyright 2024 Uwe Trottmann
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uwetrottmann.trakt5.services;
import com.uwetrottmann.trakt5.entities.BaseMovie;
import com.uwetrottmann.trakt5.entities.BaseShow;
import com.uwetrottmann.trakt5.entities.HistoryEntry;
import com.uwetrottmann.trakt5.entities.LastActivities;
import com.uwetrottmann.trakt5.entities.PlaybackResponse;
import com.uwetrottmann.trakt5.entities.RatedEpisode;
import com.uwetrottmann.trakt5.entities.RatedMovie;
import com.uwetrottmann.trakt5.entities.RatedSeason;
import com.uwetrottmann.trakt5.entities.RatedShow;
import com.uwetrottmann.trakt5.entities.SyncItems;
import com.uwetrottmann.trakt5.entities.SyncResponse;
import com.uwetrottmann.trakt5.entities.WatchlistedEpisode;
import com.uwetrottmann.trakt5.entities.WatchlistedSeason;
import com.uwetrottmann.trakt5.enums.Extended;
import com.uwetrottmann.trakt5.enums.RatingsFilter;
import org.threeten.bp.OffsetDateTime;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import java.util.List;
public interface Sync {
/**
* <b>OAuth Required</b>
*
* <p> This method is a useful first step in the syncing process. We recommended caching these dates locally, then
* you can compare to know exactly what data has changed recently. This can greatly optimize your syncs so you don't
* pull down a ton of data only to see nothing has actually changed.
*/
@GET("sync/last_activities")
Call<LastActivities> lastActivities();
/**
* <b>OAuth Required</b>
*
* <p> Get all collected movies in a user's collection. A collected item indicates availability to watch digitally
* or on physical media.
*/
@GET("sync/collection/movies")
Call<List<BaseMovie>> collectionMovies(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth Required</b>
*
* <p> Get all collected shows in a user's collection. A collected item indicates availability to watch digitally or
* on physical media.
*/
@GET("sync/collection/shows")
Call<List<BaseShow>> collectionShows(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth Required</b>
*
* <p> Add one or more items to a user's collection including the format of the item.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/collection")
Call<SyncResponse> addItemsToCollection(
@Body SyncItems items
);
/**
* <b>OAuth Required</b>
*
* <p> Remove one or more items from a user's collection.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/collection/remove")
Call<SyncResponse> deleteItemsFromCollection(
@Body SyncItems items
);
/**
* <b>OAuth Required</b>
*
* <p> Returns all movies a user has watched.
*/
@GET("sync/watched/movies")
Call<List<BaseMovie>> watchedMovies(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth Required</b>
*
* <p> Returns all playbacks;
*/
@GET("sync/playback")
Call<List<PlaybackResponse>> getPlayback(
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p> Returns playbacks for a given period;
*/
@GET("sync/playback")
Call<List<PlaybackResponse>> getPlaybackPeriod(
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns playbacks since a date;
*/
@GET("sync/playback")
Call<List<PlaybackResponse>> getPlaybackSince(
@Query("start_at") OffsetDateTime startAt
);
/**
* <b>OAuth Required</b>
*
* <p> Returns all episodes playbacks;
*/
@GET("sync/playback/episodes")
Call<List<PlaybackResponse>> getPlaybackEpisodes(
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns episodes playbacks for a given period;
*/
@GET("sync/playback/episodes")
Call<List<PlaybackResponse>> getPlaybackEpisodesPeriod(
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns episodes playbacks for a since a date;
*/
@GET("sync/playback/episodes")
Call<List<PlaybackResponse>> getPlaybackEpisodesSince(
@Query("limit") Integer limit,
@Query("start_at") OffsetDateTime startAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns all movies playbacks;
*/
@GET("sync/playback/movies")
Call<List<PlaybackResponse>> getPlaybackMovies(
@Query("limit") Integer limit);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns movies playbacks for a given period;
*/
@GET("sync/playback/movies")
Call<List<PlaybackResponse>> getPlaybackMoviesPeriod(
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns movies playbacks since a date;
*/
@GET("sync/playback/movies")
Call<List<PlaybackResponse>> getPlaybackMoviesSince(
@Query("start_at") OffsetDateTime startAt
);
/**
* <b>OAuth Required</b>
* <p>
* Remove a playback item from a user's playback progress list. A 404 will be returned if the id is invalid.
* <p>
* <a href="https://trakt.docs.apiary.io/#reference/sync/remove-playback/remove-a-playback-item">Online documentation</a>
*/
@DELETE("sync/playback/{id}")
Call<Void> removePlayback(
@Path("id") long id
);
/**
* <b>OAuth Required</b>
*
* <p> Returns all shows a user has watched.
*/
@GET("sync/watched/shows")
Call<List<BaseShow>> watchedShows(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns watch history;
*/
@GET("sync/history")
Call<List<HistoryEntry>> getWatchedHistory(
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns watch history since a date;
*/
@GET("sync/history")
Call<List<HistoryEntry>> getWatchedHistorySince(
@Query("start_at") OffsetDateTime startAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns watch history for a given period;
*/
@GET("sync/history")
Call<List<HistoryEntry>> getWatchedHistoryPeriod(
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns movies watch history;
*/
@GET("sync/history/movies")
Call<List<HistoryEntry>> getWatchedHistoryMovies(
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns movies watch history since a date;
*/
@GET("sync/history/movies")
Call<List<HistoryEntry>> getWatchedHistoryMoviesSince(
@Query("start_at") OffsetDateTime startAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns movies watch history for a given period;
*/
@GET("sync/history/movies")
Call<List<HistoryEntry>> getWatchedHistoryMoviesPeriod(
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns episodes watch history;
*/
@GET("sync/history/episodes")
Call<List<HistoryEntry>> getWatchedHistoryEpisodes(
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns episodes watch history since a date;
*/
@GET("sync/history/episodes")
Call<List<HistoryEntry>> getWatchedHistoryEpisodesSince(
@Query("start_at") OffsetDateTime startAt
);
/**
* <b>OAuth Required</b>
*
* <p>
* Returns episodes watch history for a given period;
*/
@GET("sync/history/episodes")
Call<List<HistoryEntry>> getWatchedHistoryEpisodesPeriod(
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth Required</b>
*
* <p> Add items to a user's watch history. Accepts shows, seasons, episodes and movies. If only a show is passed,
* assumes all seasons are to be marked watched. Same for seasons. Send a <code>watched_at</code> UTC datetime to
* mark items as watched in the past. This is useful for syncing past watches from a media center.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/history")
Call<SyncResponse> addItemsToWatchedHistory(
@Body SyncItems items
);
/**
* <b>OAuth Required</b>
*
* <p> Remove items from a user's watch history including all watches, scrobbles, and checkins. Accepts shows,
* seasons, episodes and movies. If only a show is passed, assumes all seasons are to be removed from history. Same
* for seasons.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/history/remove")
Call<SyncResponse> deleteItemsFromWatchedHistory(
@Body SyncItems items
);
/**
* <b>OAuth Required</b>
*
* <p> Get a user's ratings filtered by movies. You can filter for a specific rating between 1 and 10.
*
* @param filter Filter for a specific rating.
* @param page Number of page of results to be returned. If {@code null} but {@code limit} is provided defaults to
* 1, otherwise items are paginated.
* @param limit Number of results to return per page. If {@code null} but {@code page} is provided defaults to 10,
* otherwise all items are returned.
*/
@GET("sync/ratings/movies{rating}")
Call<List<RatedMovie>> ratingsMovies(
@Path(value = "rating", encoded = true) RatingsFilter filter,
@Query(value = "extended", encoded = true) Extended extended,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p> Get a user's ratings filtered by shows. You can filter for a specific rating between 1 and 10.
*
* @param filter Filter for a specific rating.
* @param page Number of page of results to be returned. If {@code null} but {@code limit} is provided defaults to
* 1, otherwise items are not paginated.
* @param limit Number of results to return per page. If {@code null} but {@code page} is provided defaults to 10,
* otherwise all items are returned.
*/
@GET("sync/ratings/shows{rating}")
Call<List<RatedShow>> ratingsShows(
@Path(value = "rating", encoded = true) RatingsFilter filter,
@Query(value = "extended", encoded = true) Extended extended,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p> Get a user's ratings filtered by seasons. You can filter for a specific rating between 1 and 10.
*
* @param filter Filter for a specific rating.
* @param page Number of page of results to be returned. If {@code null} but {@code limit} is provided defaults to
* 1, otherwise items are paginated.
* @param limit Number of results to return per page. If {@code null} but {@code page} is provided defaults to 10,
* otherwise all items are returned.
*/
@GET("sync/ratings/seasons{rating}")
Call<List<RatedSeason>> ratingsSeasons(
@Path(value = "rating", encoded = true) RatingsFilter filter,
@Query(value = "extended", encoded = true) Extended extended,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p> Get a user's ratings filtered by episodes. You can filter for a specific rating between 1 and 10.
*
* @param filter Filter for a specific rating.
* @param page Number of page of results to be returned. If {@code null} but {@code limit} is provided defaults to
* 1, otherwise items are paginated.
* @param limit Number of results to return per page. If {@code null} but {@code page} is provided defaults to 10,
* otherwise all items are returned.
*/
@GET("sync/ratings/episodes{rating}")
Call<List<RatedEpisode>> ratingsEpisodes(
@Path(value = "rating", encoded = true) RatingsFilter filter,
@Query(value = "extended", encoded = true) Extended extended,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth Required</b>
*
* <p> Rate one or more items.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/ratings")
Call<SyncResponse> addRatings(
@Body SyncItems items
);
/**
* <b>OAuth Required</b>
*
* <p> Delete ratings for one or more items.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/ratings/remove")
Call<SyncResponse> deleteRatings(
@Body SyncItems items
);
/**
* <b>OAuth Required</b>
*
* <p> Returns all items in a user's watchlist filtered by movies. When an item is watched, it will be automatically
* removed from the watchlist. To track what the user is actively watching, use the progress APIs.
*/
@GET("sync/watchlist/movies")
Call<List<BaseMovie>> watchlistMovies(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth Required</b>
*
* <p> Returns all items in a user's watchlist filtered by shows. When an item is watched, it will be automatically
* removed from the watchlist. To track what the user is actively watching, use the progress APIs.
*/
@GET("sync/watchlist/shows")
Call<List<BaseShow>> watchlistShows(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth Required</b>
*
* <p> Returns all items in a user's watchlist filtered by seasons. When an item is watched, it will be
* automatically removed from the watchlist. To track what the user is actively watching, use the progress APIs.
*/
@GET("sync/watchlist/seasons")
Call<List<WatchlistedSeason>> watchlistSeasons(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth Required</b>
*
* <p> Returns all items in a user's watchlist filtered by episodes. When an item is watched, it will be
* automatically removed from the watchlist. To track what the user is actively watching, use the progress APIs.
*/
@GET("sync/watchlist/episodes")
Call<List<WatchlistedEpisode>> watchlistEpisodes(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth Required</b>
*
* <p> Add one of more items to a user's watchlist.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/watchlist")
Call<SyncResponse> addItemsToWatchlist(
@Body SyncItems items
);
/**
* <b>OAuth Required</b>
*
* <p> Delete one or more items from a user's watchlist.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/watchlist/remove")
Call<SyncResponse> deleteItemsFromWatchlist(
@Body SyncItems items
);
}