Skip to content

Commit c767a32

Browse files
adamayoungclaude
andauthored
✨ Add AccountService rated content and lists endpoints (#261)
* ✨ Add AccountService rated content and lists endpoints Add 5 new methods to AccountService for retrieving user's rated content and custom lists: **New Models:** - ✨ Created `RatedSort` enum for sorting rated content - ✨ Created `TVEpisodePageableList` typealias for pageable episode lists - ✨ Created `MediaListPageableList` typealias for pageable list results **New Service Methods:** - ✨ Added `ratedMovies(sortedBy:page:accountID:session:)` - Get user's rated movies - ✨ Added `ratedTVSeries(sortedBy:page:accountID:session:)` - Get user's rated TV series - ✨ Added `ratedTVEpisodes(sortedBy:page:accountID:session:)` - Get user's rated TV episodes - ✨ Added `lists(page:accountID:session:)` - Get user's custom lists **New Request Classes:** - ✨ Created `RatedMoviesRequest` for rated movies endpoint - ✨ Created `RatedTVSeriesRequest` for rated TV series endpoint - ✨ Created `RatedTVEpisodesRequest` for rated TV episodes endpoint - ✨ Created `AccountListsRequest` for user lists endpoint **Tests:** - ✅ Added comprehensive unit tests with mock data for all new methods - ✅ Added integration tests for rated content and lists retrieval - ✅ All AccountService tests passing **Documentation:** - 📚 Updated `AccountService.md` with new method groups - 📚 Added new models to `TMDb.md` documentation catalog Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * 🐛 Fix test build issues and file length violation - Use #require() to unwrap optional page property in integration tests - Remove duplicate MediaListPageableList typealias (use existing MediaListSummaryPageableList) - Split AccountService.swift to meet 400-line limit (move defaults to separate file) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Fix --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 70a4a93 commit c767a32

14 files changed

Lines changed: 999 additions & 57 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// TVEpisodePageableList.swift
3+
// TMDb
4+
//
5+
// Copyright © 2026 Adam Young.
6+
//
7+
8+
import Foundation
9+
10+
///
11+
/// A model representing a pageable list of TV episodes.
12+
///
13+
public typealias TVEpisodePageableList = PageableListResult<TVEpisode>
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
//
2+
// AccountService+Defaults.swift
3+
// TMDb
4+
//
5+
// Copyright © 2026 Adam Young.
6+
//
7+
8+
import Foundation
9+
10+
public extension AccountService {
11+
12+
///
13+
/// Returns a list of the user's favourited movies.
14+
///
15+
/// - Parameters:
16+
/// - sortedBy: How results should be sorted.
17+
/// - page: The page of results to return.
18+
/// - accountID: The user's account identifier.
19+
/// - session: The user's TMDb session.
20+
///
21+
/// - Throws: TMDb error ``TMDbError``.
22+
///
23+
/// - Returns: A list of the user's favourited movies.
24+
///
25+
func favouriteMovies(
26+
sortedBy: FavouriteSort? = nil,
27+
page: Int? = nil,
28+
accountID: Int,
29+
session: Session
30+
) async throws -> MoviePageableList {
31+
try await favouriteMovies(
32+
sortedBy: sortedBy,
33+
page: page,
34+
accountID: accountID,
35+
session: session
36+
)
37+
}
38+
39+
///
40+
/// Returns a list of the user's favourited TV series.
41+
///
42+
/// - Parameters:
43+
/// - sortedBy: How results should be sorted.
44+
/// - page: The page of results to return.
45+
/// - accountID: The user's account identifier.
46+
/// - session: The user's TMDb session.
47+
///
48+
/// - Throws: TMDb error ``TMDbError``.
49+
///
50+
/// - Returns: A list of the user's favourited TV series.
51+
///
52+
func favouriteTVSeries(
53+
sortedBy: FavouriteSort? = nil,
54+
page: Int? = nil,
55+
accountID: Int,
56+
session: Session
57+
) async throws -> TVSeriesPageableList {
58+
try await favouriteTVSeries(
59+
sortedBy: sortedBy,
60+
page: page,
61+
accountID: accountID,
62+
session: session
63+
)
64+
}
65+
66+
///
67+
/// Returns a list of movies in the user's watchlist.
68+
///
69+
/// - Parameters:
70+
/// - sortedBy: How results should be sorted.
71+
/// - page: The page of results to return.
72+
/// - accountID: The user's account identifier.
73+
/// - session: The user's TMDb session.
74+
///
75+
/// - Throws: TMDb error ``TMDbError``.
76+
///
77+
/// - Returns: A list of movies in the user's watchlist.
78+
///
79+
func movieWatchlist(
80+
sortedBy: WatchlistSort? = nil,
81+
page: Int? = nil,
82+
accountID: Int,
83+
session: Session
84+
) async throws -> MoviePageableList {
85+
try await movieWatchlist(
86+
sortedBy: sortedBy,
87+
page: page,
88+
accountID: accountID,
89+
session: session
90+
)
91+
}
92+
93+
///
94+
/// Returns a list of TV series in the user's watchlist.
95+
///
96+
/// - Parameters:
97+
/// - sortedBy: How results should be sorted.
98+
/// - page: The page of results to return.
99+
/// - accountID: The user's account identifier.
100+
/// - session: The user's TMDb session.
101+
///
102+
/// - Throws: TMDb error ``TMDbError``.
103+
///
104+
/// - Returns: A list of TV series in the user's watchlist.
105+
///
106+
func tvSeriesWatchlist(
107+
sortedBy: WatchlistSort? = nil,
108+
page: Int? = nil,
109+
accountID: Int,
110+
session: Session
111+
) async throws -> TVSeriesPageableList {
112+
try await tvSeriesWatchlist(
113+
sortedBy: sortedBy,
114+
page: page,
115+
accountID: accountID,
116+
session: session
117+
)
118+
}
119+
120+
///
121+
/// Returns a list of movies rated by the user.
122+
///
123+
/// - Parameters:
124+
/// - sortedBy: How results should be sorted.
125+
/// - page: The page of results to return.
126+
/// - accountID: The user's account identifier.
127+
/// - session: The user's TMDb session.
128+
///
129+
/// - Throws: TMDb error ``TMDbError``.
130+
///
131+
/// - Returns: A list of movies rated by the user.
132+
///
133+
func ratedMovies(
134+
sortedBy: RatedSort? = nil,
135+
page: Int? = nil,
136+
accountID: Int,
137+
session: Session
138+
) async throws -> MoviePageableList {
139+
try await ratedMovies(
140+
sortedBy: sortedBy,
141+
page: page,
142+
accountID: accountID,
143+
session: session
144+
)
145+
}
146+
147+
///
148+
/// Returns a list of TV series rated by the user.
149+
///
150+
/// - Parameters:
151+
/// - sortedBy: How results should be sorted.
152+
/// - page: The page of results to return.
153+
/// - accountID: The user's account identifier.
154+
/// - session: The user's TMDb session.
155+
///
156+
/// - Throws: TMDb error ``TMDbError``.
157+
///
158+
/// - Returns: A list of TV series rated by the user.
159+
///
160+
func ratedTVSeries(
161+
sortedBy: RatedSort? = nil,
162+
page: Int? = nil,
163+
accountID: Int,
164+
session: Session
165+
) async throws -> TVSeriesPageableList {
166+
try await ratedTVSeries(
167+
sortedBy: sortedBy,
168+
page: page,
169+
accountID: accountID,
170+
session: session
171+
)
172+
}
173+
174+
///
175+
/// Returns a list of TV episodes rated by the user.
176+
///
177+
/// - Parameters:
178+
/// - sortedBy: How results should be sorted.
179+
/// - page: The page of results to return.
180+
/// - accountID: The user's account identifier.
181+
/// - session: The user's TMDb session.
182+
///
183+
/// - Throws: TMDb error ``TMDbError``.
184+
///
185+
/// - Returns: A list of TV episodes rated by the user.
186+
///
187+
func ratedTVEpisodes(
188+
sortedBy: RatedSort? = nil,
189+
page: Int? = nil,
190+
accountID: Int,
191+
session: Session
192+
) async throws -> TVEpisodePageableList {
193+
try await ratedTVEpisodes(
194+
sortedBy: sortedBy,
195+
page: page,
196+
accountID: accountID,
197+
session: session
198+
)
199+
}
200+
201+
///
202+
/// Returns a list of the user's custom lists.
203+
///
204+
/// - Parameters:
205+
/// - page: The page of results to return.
206+
/// - accountID: The user's account identifier.
207+
/// - session: The user's TMDb session.
208+
///
209+
/// - Throws: TMDb error ``TMDbError``.
210+
///
211+
/// - Returns: A list of the user's custom lists.
212+
///
213+
func lists(
214+
page: Int? = nil,
215+
accountID: Int,
216+
session: Session
217+
) async throws -> MediaListSummaryPageableList {
218+
try await lists(
219+
page: page,
220+
accountID: accountID,
221+
session: session
222+
)
223+
}
224+
225+
}

Sources/TMDb/Domain/Services/Account/AccountService.swift

Lines changed: 23 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,8 @@ public protocol AccountService: Sendable {
232232
session: Session
233233
) async throws
234234

235-
}
236-
237-
public extension AccountService {
238-
239235
///
240-
/// Returns a list of the user's favourited movies.
236+
/// Returns a list of movies rated by the user.
241237
///
242238
/// - Parameters:
243239
/// - sortedBy: How results should be sorted.
@@ -247,24 +243,17 @@ public extension AccountService {
247243
///
248244
/// - Throws: TMDb error ``TMDbError``.
249245
///
250-
/// - Returns: A list of the user's favourited movies.
246+
/// - Returns: A list of movies rated by the user.
251247
///
252-
func favouriteMovies(
253-
sortedBy: FavouriteSort? = nil,
254-
page: Int? = nil,
248+
func ratedMovies(
249+
sortedBy: RatedSort?,
250+
page: Int?,
255251
accountID: Int,
256252
session: Session
257-
) async throws -> MoviePageableList {
258-
try await favouriteMovies(
259-
sortedBy: sortedBy,
260-
page: page,
261-
accountID: accountID,
262-
session: session
263-
)
264-
}
253+
) async throws -> MoviePageableList
265254

266255
///
267-
/// Returns a list of the user's favourited TV series.
256+
/// Returns a list of TV series rated by the user.
268257
///
269258
/// - Parameters:
270259
/// - sortedBy: How results should be sorted.
@@ -274,24 +263,17 @@ public extension AccountService {
274263
///
275264
/// - Throws: TMDb error ``TMDbError``.
276265
///
277-
/// - Returns: A list of the user's favourited TV series.
266+
/// - Returns: A list of TV series rated by the user.
278267
///
279-
func favouriteTVSeries(
280-
sortedBy: FavouriteSort? = nil,
281-
page: Int? = nil,
268+
func ratedTVSeries(
269+
sortedBy: RatedSort?,
270+
page: Int?,
282271
accountID: Int,
283272
session: Session
284-
) async throws -> TVSeriesPageableList {
285-
try await favouriteTVSeries(
286-
sortedBy: sortedBy,
287-
page: page,
288-
accountID: accountID,
289-
session: session
290-
)
291-
}
273+
) async throws -> TVSeriesPageableList
292274

293275
///
294-
/// Returns a list of movies in the user's watchlist.
276+
/// Returns a list of TV episodes rated by the user.
295277
///
296278
/// - Parameters:
297279
/// - sortedBy: How results should be sorted.
@@ -301,47 +283,31 @@ public extension AccountService {
301283
///
302284
/// - Throws: TMDb error ``TMDbError``.
303285
///
304-
/// - Returns: A list of movies in the user's watchlist.
286+
/// - Returns: A list of TV episodes rated by the user.
305287
///
306-
func movieWatchlist(
307-
sortedBy: WatchlistSort? = nil,
308-
page: Int? = nil,
288+
func ratedTVEpisodes(
289+
sortedBy: RatedSort?,
290+
page: Int?,
309291
accountID: Int,
310292
session: Session
311-
) async throws -> MoviePageableList {
312-
try await movieWatchlist(
313-
sortedBy: sortedBy,
314-
page: page,
315-
accountID: accountID,
316-
session: session
317-
)
318-
}
293+
) async throws -> TVEpisodePageableList
319294

320295
///
321-
/// Returns a list of TV series in the user's watchlist.
296+
/// Returns a list of the user's custom lists.
322297
///
323298
/// - Parameters:
324-
/// - sortedBy: How results should be sorted.
325299
/// - page: The page of results to return.
326300
/// - accountID: The user's account identifier.
327301
/// - session: The user's TMDb session.
328302
///
329303
/// - Throws: TMDb error ``TMDbError``.
330304
///
331-
/// - Returns: A list of TV series in the user's watchlist.
305+
/// - Returns: A list of the user's custom lists.
332306
///
333-
func tvSeriesWatchlist(
334-
sortedBy: WatchlistSort? = nil,
335-
page: Int? = nil,
307+
func lists(
308+
page: Int?,
336309
accountID: Int,
337310
session: Session
338-
) async throws -> TVSeriesPageableList {
339-
try await tvSeriesWatchlist(
340-
sortedBy: sortedBy,
341-
page: page,
342-
accountID: accountID,
343-
session: session
344-
)
345-
}
311+
) async throws -> MediaListSummaryPageableList
346312

347313
}

0 commit comments

Comments
 (0)