-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: TV Season Aggregate Credits (#175)
* Model and request * Update TV Season service * Add integration tests
- Loading branch information
1 parent
a6cd279
commit 3a5246e
Showing
10 changed files
with
353 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// TVSeasonAggregateCredits.swift | ||
// TMDb | ||
// | ||
// Copyright © 2024 Adam Young. | ||
// | ||
// 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. | ||
// | ||
|
||
import Foundation | ||
|
||
/// | ||
/// A model representing a TV series aggregated credits. | ||
/// | ||
/// A person can be both a cast member and crew member of the same show. | ||
/// | ||
public struct TVSeasonAggregateCredits: Identifiable, Codable, Equatable, Hashable, Sendable { | ||
|
||
/// | ||
/// TV season identifier. | ||
/// | ||
public let id: TVSeason.ID | ||
|
||
/// | ||
/// Cast members of the TV series. | ||
/// | ||
public let cast: [AggregrateCastMember] | ||
|
||
/// | ||
/// Crew members of the TV series. | ||
/// | ||
public let crew: [AggregrateCrewMember] | ||
|
||
/// | ||
/// Creates a TV season aggregrate credits object. | ||
/// | ||
/// - Parameters: | ||
/// - id: TV season identifier. | ||
/// - cast: Cast members of the TV series. | ||
/// - crew: Crew members of the TV series. | ||
/// | ||
public init(id: TVSeason.ID, cast: [AggregrateCastMember], crew: [AggregrateCrewMember]) { | ||
self.id = id | ||
self.cast = cast | ||
self.crew = crew | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
Sources/TMDb/Domain/Services/TVSeasons/Requests/TVSeasonAggregateCreditsRequest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// TVSeasonAggregateCreditsRequest.swift | ||
// TMDb | ||
// | ||
// Copyright © 2024 Adam Young. | ||
// | ||
// 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. | ||
// | ||
|
||
import Foundation | ||
|
||
final class TVSeasonAggregateCreditsRequest: DecodableAPIRequest<TVSeasonAggregateCredits> { | ||
|
||
init(seasonNumber: Int, tvSeriesID: TVSeries.ID) { | ||
let path = "/tv/\(tvSeriesID)/season/\(seasonNumber)/aggregate_credits" | ||
|
||
super.init(path: path) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Tests/TMDbTests/Domain/Models/TVSeasonAggregateCreditsTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// TVSeasonAggregateCreditsTests.swift | ||
// TMDb | ||
// | ||
// Copyright © 2024 Adam Young. | ||
// | ||
// 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. | ||
// | ||
|
||
@testable import TMDb | ||
import XCTest | ||
|
||
final class TVSeasonAggregateCreditsTests: XCTestCase { | ||
|
||
func testDecodeReturnsTVSeasonAggregateCredits() throws { | ||
let result = try JSONDecoder.theMovieDatabase.decode( | ||
TVSeriesAggregateCredits.self, | ||
fromResource: "tv-season-aggregate-credits" | ||
) | ||
|
||
XCTAssertEqual(result.id, 3625) | ||
XCTAssertEqual(result.cast.count, 3) | ||
XCTAssertEqual(result.crew.count, 2) | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
...s/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonAggregateCreditsRequestTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// TVSeasonAggregateCreditsRequestTests.swift | ||
// TMDb | ||
// | ||
// Copyright © 2024 Adam Young. | ||
// | ||
// 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. | ||
// | ||
|
||
@testable import TMDb | ||
import XCTest | ||
|
||
final class TVSeasonAggregateCreditsRequestTests: XCTestCase { | ||
|
||
var request: TVSeasonAggregateCreditsRequest! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1) | ||
} | ||
|
||
override func tearDown() { | ||
request = nil | ||
super.tearDown() | ||
} | ||
|
||
func testPath() { | ||
XCTAssertEqual(request.path, "/tv/1/season/2/aggregate_credits") | ||
} | ||
|
||
func testQueryItemsAreEmpty() { | ||
XCTAssertTrue(request.queryItems.isEmpty) | ||
} | ||
|
||
func testMethodIsGet() { | ||
XCTAssertEqual(request.method, .get) | ||
} | ||
|
||
func testHeadersIsEmpty() { | ||
XCTAssertTrue(request.headers.isEmpty) | ||
} | ||
|
||
func testBodyIsNil() { | ||
XCTAssertNil(request.body) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
Tests/TMDbTests/Resources/json/tv-season-aggregate-credits.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"cast": [ | ||
{ | ||
"adult": false, | ||
"gender": 2, | ||
"id": 22970, | ||
"known_for_department": "Acting", | ||
"name": "Peter Dinklage", | ||
"original_name": "Peter Dinklage", | ||
"popularity": 44.296, | ||
"profile_path": "/9CAd7wr8QZyIN0E7nm8v1B6WkGn.jpg", | ||
"roles": [ | ||
{ | ||
"credit_id": "5256c8b219c2956ff6047cd8", | ||
"character": "Tyrion 'The Halfman' Lannister", | ||
"episode_count": 10 | ||
} | ||
], | ||
"total_episode_count": 10, | ||
"order": 0 | ||
}, | ||
{ | ||
"adult": false, | ||
"gender": 2, | ||
"id": 239019, | ||
"known_for_department": "Acting", | ||
"name": "Kit Harington", | ||
"original_name": "Kit Harington", | ||
"popularity": 32.025, | ||
"profile_path": "/htGBMno71BJAEGF3Y9f62MdA3Yt.jpg", | ||
"roles": [ | ||
{ | ||
"credit_id": "5256c8af19c2956ff6047af6", | ||
"character": "Jon Snow", | ||
"episode_count": 10 | ||
} | ||
], | ||
"total_episode_count": 10, | ||
"order": 1 | ||
}, | ||
{ | ||
"adult": false, | ||
"gender": 2, | ||
"id": 512991, | ||
"known_for_department": "Acting", | ||
BFEC | "name": "Richard Madden", | |
"original_name": "Richard Madden", | ||
"popularity": 44.12, | ||
"profile_path": "/kC7X9LgAtJfpxUBRtVwaVTEXomH.jpg", | ||
"roles": [ | ||
{ | ||
"credit_id": "5256c8af19c2956ff6047b1a", | ||
"character": "Robb Stark", | ||
"episode_count": 10 | ||
} | ||
], | ||
"total_episode_count": 10, | ||
"order": 4 | ||
} | ||
], | ||
"crew": [ | ||
{ | ||
"adult": false, | ||
"gender": 0, | ||
"id": 982992, | ||
"known_for_department": "Art", | ||
"name": "Ashleigh Jeffers", | ||
"original_name": "Ashleigh Jeffers", | ||
"popularity": 5.33, | ||
"profile_path": null, | ||
"jobs": [ | ||
{ | ||
"credit_id": "622da5c312970c007974b75d", | ||
"job": "Art Direction", | ||
"episode_count": 9 | ||
} | ||
], | ||
"department": "Art", | ||
"total_episode_count": 9 | ||
}, | ||
{ | ||
"adult": false, | ||
"gender": 2, | ||
"id": 37301, | ||
"known_for_department": "Art", | ||
"name": "Frank Walsh", | ||
"original_name": "Frank Walsh", | ||
"popularity": 5.677, | ||
"profile_path": null, | ||
"jobs": [ | ||
{ | ||
"credit_id": "622da5b2534661001b7d306f", | ||
"job": "Supervising Art Director", | ||
"episode_count": 9 | ||
} | ||
], | ||
"department": "Art", | ||
"total_episode_count": 9 | ||
} | ||
], | ||
"id": 3625 | ||
} |