diff --git a/.swift-format b/.swift-format index 76a0dd9c..dc1bece2 100644 --- a/.swift-format +++ b/.swift-format @@ -13,7 +13,7 @@ "lineBreakBeforeEachGenericRequirement": false, "lineLength": 100, "maximumBlankLines": 1, - "multiElementCollectionTrailingCommas": true, + "multiElementCollectionTrailingCommas": false, "noAssignmentInExpressions": { "allowedFunctions": [ "XCTAssertNoThrow" @@ -22,19 +22,19 @@ "prioritizeKeepingFunctionOutputTogether": false, "respectsExistingLineBreaks": true, "rules": { - "AllPublicDeclarationsHaveDocumentation": false, - "AlwaysUseLiteralForEmptyCollectionInit": false, + "AllPublicDeclarationsHaveDocumentation": true, + "AlwaysUseLiteralForEmptyCollectionInit": true, "AlwaysUseLowerCamelCase": true, "AmbiguousTrailingClosureOverload": true, - "BeginDocumentationCommentWithOneLineSummary": false, + "BeginDocumentationCommentWithOneLineSummary": true, "DoNotUseSemicolons": true, "DontRepeatTypeInStaticProperties": true, "FileScopedDeclarationPrivacy": true, "FullyIndirectEnum": true, "GroupNumericLiterals": true, "IdentifiersMustBeASCII": true, - "NeverForceUnwrap": false, - "NeverUseForceTry": false, + "NeverForceUnwrap": true, + "NeverUseForceTry": true, "NeverUseImplicitlyUnwrappedOptionals": false, "NoAccessLevelOnExtensionDeclaration": true, "NoAssignmentInExpressions": true, @@ -42,11 +42,11 @@ "NoCasesWithOnlyFallthrough": true, "NoEmptyTrailingClosureParentheses": true, "NoLabelsInCasePatterns": true, - "NoLeadingUnderscores": false, + "NoLeadingUnderscores": true, "NoParensAroundConditions": true, "NoPlaygroundLiterals": true, "NoVoidReturnOnFunctionSignature": true, - "OmitExplicitReturns": false, + "OmitExplicitReturns": true, "OneCasePerLine": true, "OneVariableDeclarationPerLine": true, "OnlyOneTrailingClosureArgument": true, @@ -54,17 +54,17 @@ "ReplaceForEachWithForLoop": true, "ReturnVoidInsteadOfEmptyTuple": true, "TypeNamesShouldBeCapitalized": true, - "UseEarlyExits": false, + "UseEarlyExits": true, "UseExplicitNilCheckInConditions": true, "UseLetInEveryBoundCaseVariable": true, "UseShorthandTypeNames": true, "UseSingleLinePropertyGetter": true, "UseSynthesizedInitializer": true, "UseTripleSlashForDocumentationComments": true, - "UseWhereClausesInForLoops": false, - "ValidateDocumentationComments": false + "UseWhereClausesInForLoops": true, + "ValidateDocumentationComments": true }, "spacesAroundRangeFormationOperators": false, - "tabWidth": 8, + "tabWidth": 4, "version": 1 } \ No newline at end of file diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 00000000..fdac643d --- /dev/null +++ b/Package.resolved @@ -0,0 +1,24 @@ +{ + "originHash" : "30be1a8795d91fbccb4a904ab667609855569d33f57038fec1ba246343472f40", + "pins" : [ + { + "identity" : "swift-docc-plugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-plugin.git", + "state" : { + "revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64", + "version" : "1.4.3" + } + }, + { + "identity" : "swift-docc-symbolkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-docc-symbolkit", + "state" : { + "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", + "version" : "1.0.0" + } + } + ], + "version" : 3 +} diff --git a/Package.swift b/Package.swift index 1e080097..f1db32ac 100644 --- a/Package.swift +++ b/Package.swift @@ -15,7 +15,7 @@ let package = Package( .iOS(.v16), .watchOS(.v9), .tvOS(.v16), - .visionOS(.v1), + .visionOS(.v1) ], products: [ @@ -36,7 +36,7 @@ let package = Package( .testTarget( name: "TMDbIntegrationTests", dependencies: ["TMDb"] - ), + ) ] ) diff --git a/Sources/TMDb/Domain/Models/Company.swift b/Sources/TMDb/Domain/Models/Company.swift index 196f959b..93ab4ed7 100644 --- a/Sources/TMDb/Domain/Models/Company.swift +++ b/Sources/TMDb/Domain/Models/Company.swift @@ -114,6 +114,18 @@ extension Company { case parentCompany } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let container2 = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/Gender.swift b/Sources/TMDb/Domain/Models/Gender.swift index ae9d1576..ac4ea7c1 100644 --- a/Sources/TMDb/Domain/Models/Gender.swift +++ b/Sources/TMDb/Domain/Models/Gender.swift @@ -44,6 +44,18 @@ public enum Gender: Int, Codable, Equatable, Hashable, Sendable { /// case other = 3 + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { self = try Gender(rawValue: decoder.singleValueContainer().decode(RawValue.self)) ?? .unknown diff --git a/Sources/TMDb/Domain/Models/ImageMetadata.swift b/Sources/TMDb/Domain/Models/ImageMetadata.swift index 4e8b4bae..fe49d96a 100644 --- a/Sources/TMDb/Domain/Models/ImageMetadata.swift +++ b/Sources/TMDb/Domain/Models/ImageMetadata.swift @@ -74,9 +74,9 @@ public struct ImageMetadata: Identifiable, Codable, Equatable, Hashable, Sendabl /// - width: Image width. /// - height: Image height. /// - aspectRatio: Aspect ratio. - /// - languageCode: ISO 639-1 language code. /// - voteAverage: The average of user votes on this image. /// - voteCount: The number of user votes on this image. + /// - languageCode: ISO 639-1 language code. /// public init( filePath: URL, diff --git a/Sources/TMDb/Domain/Models/Media.swift b/Sources/TMDb/Domain/Models/Media.swift index 622df064..823bbeca 100644 --- a/Sources/TMDb/Domain/Models/Media.swift +++ b/Sources/TMDb/Domain/Models/Media.swift @@ -69,6 +69,18 @@ extension Media { case person } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let mediaType = try container.decode(MediaType.self, forKey: .mediaType) @@ -85,6 +97,20 @@ extension Media { } } + /// + /// Encodes this value into the given encoder. + /// + /// If the value fails to encode anything, `encoder` will encode an empty + /// keyed container in its place. + /// + /// This function throws an error if any values are invalid for the given + /// encoder's format. + /// + /// - Parameter encoder: The encoder to write data to. + /// + /// - throws: `EncodingError.invalidValue` if the given value is invalid in + /// the current context for this format. + /// public func encode(to encoder: Encoder) throws { var singleContainer = encoder.singleValueContainer() diff --git a/Sources/TMDb/Domain/Models/Movie.swift b/Sources/TMDb/Domain/Models/Movie.swift index 33edbf0c..e9243b1a 100644 --- a/Sources/TMDb/Domain/Models/Movie.swift +++ b/Sources/TMDb/Domain/Models/Movie.swift @@ -260,6 +260,18 @@ extension Movie { case isAdultOnly = "adult" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let container2 = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/MovieExternalLinksCollection.swift b/Sources/TMDb/Domain/Models/MovieExternalLinksCollection.swift index 94befec9..b5fe9d85 100644 --- a/Sources/TMDb/Domain/Models/MovieExternalLinksCollection.swift +++ b/Sources/TMDb/Domain/Models/MovieExternalLinksCollection.swift @@ -94,6 +94,18 @@ extension MovieExternalLinksCollection { case twitterID = "twitterId" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) @@ -121,6 +133,20 @@ extension MovieExternalLinksCollection { ) } + /// + /// Encodes this value into the given encoder. + /// + /// If the value fails to encode anything, `encoder` will encode an empty + /// keyed container in its place. + /// + /// This function throws an error if any values are invalid for the given + /// encoder's format. + /// + /// - Parameter encoder: The encoder to write data to. + /// + /// - throws: `EncodingError.invalidValue` if the given value is invalid in + /// the current context for this format. + /// public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/MovieListItem.swift b/Sources/TMDb/Domain/Models/MovieListItem.swift index 528ed82f..cd8deac6 100644 --- a/Sources/TMDb/Domain/Models/MovieListItem.swift +++ b/Sources/TMDb/Domain/Models/MovieListItem.swift @@ -170,6 +170,18 @@ extension MovieListItem { case isAdultOnly = "adult" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let container2 = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/Person.swift b/Sources/TMDb/Domain/Models/Person.swift index 6eab2173..305ec32a 100644 --- a/Sources/TMDb/Domain/Models/Person.swift +++ b/Sources/TMDb/Domain/Models/Person.swift @@ -159,6 +159,18 @@ extension Person { case homepageURL = "homepage" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let container2 = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/PersonExternalLinksCollection.swift b/Sources/TMDb/Domain/Models/PersonExternalLinksCollection.swift index 00fc754c..57b01c03 100644 --- a/Sources/TMDb/Domain/Models/PersonExternalLinksCollection.swift +++ b/Sources/TMDb/Domain/Models/PersonExternalLinksCollection.swift @@ -103,6 +103,18 @@ extension PersonExternalLinksCollection { case tikTokID = "tiktokId" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) @@ -133,6 +145,20 @@ extension PersonExternalLinksCollection { ) } + /// + /// Encodes this value into the given encoder. + /// + /// If the value fails to encode anything, `encoder` will encode an empty + /// keyed container in its place. + /// + /// This function throws an error if any values are invalid for the given + /// encoder's format. + /// + /// - Parameter encoder: The encoder to write data to. + /// + /// - throws: `EncodingError.invalidValue` if the given value is invalid in + /// the current context for this format. + /// public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/Show.swift b/Sources/TMDb/Domain/Models/Show.swift index 8019bce3..7daac993 100644 --- a/Sources/TMDb/Domain/Models/Show.swift +++ b/Sources/TMDb/Domain/Models/Show.swift @@ -86,6 +86,18 @@ extension Show { case tvSeries = "tv" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let mediaType = try container.decode(MediaType.self, forKey: .mediaType) @@ -99,6 +111,20 @@ extension Show { } } + /// + /// Encodes this value into the given encoder. + /// + /// If the value fails to encode anything, `encoder` will encode an empty + /// keyed container in its place. + /// + /// This function throws an error if any values are invalid for the given + /// encoder's format. + /// + /// - Parameter encoder: The encoder to write data to. + /// + /// - throws: `EncodingError.invalidValue` if the given value is invalid in + /// the current context for this format. + /// public func encode(to encoder: Encoder) throws { var singleContainer = encoder.singleValueContainer() diff --git a/Sources/TMDb/Domain/Models/TMDbError.swift b/Sources/TMDb/Domain/Models/TMDbError.swift index 326b7fd8..9666906f 100644 --- a/Sources/TMDb/Domain/Models/TMDbError.swift +++ b/Sources/TMDb/Domain/Models/TMDbError.swift @@ -32,6 +32,18 @@ public enum TMDbError: Equatable, LocalizedError, Sendable { /// An unknown error. case unknown + /// + /// Returns a Boolean value indicating whether two `TMDBError`s are equal. + /// + /// Equality is the inverse of inequality. For any values `a` and `b`, + /// `a == b` implies that `a != b` is `false`. + /// + /// - Parameters: + /// - lhs: A value to compare. + /// - rhs: Another value to compare. + /// + /// - Returns: `true` if equal, or `false` if not. + /// public static func == (lhs: TMDbError, rhs: TMDbError) -> Bool { switch (lhs, rhs) { case (.notFound, .notFound): diff --git a/Sources/TMDb/Domain/Models/TVSeries.swift b/Sources/TMDb/Domain/Models/TVSeries.swift index 400be3b2..b4810f89 100644 --- a/Sources/TMDb/Domain/Models/TVSeries.swift +++ b/Sources/TMDb/Domain/Models/TVSeries.swift @@ -287,6 +287,18 @@ extension TVSeries { case isAdultOnly = "adult" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let container2 = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/TVSeriesExternalLinksCollection.swift b/Sources/TMDb/Domain/Models/TVSeriesExternalLinksCollection.swift index 2869aade..332f1577 100644 --- a/Sources/TMDb/Domain/Models/TVSeriesExternalLinksCollection.swift +++ b/Sources/TMDb/Domain/Models/TVSeriesExternalLinksCollection.swift @@ -95,6 +95,18 @@ extension TVSeriesExternalLinksCollection { case twitterID = "twitterId" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) @@ -122,6 +134,20 @@ extension TVSeriesExternalLinksCollection { ) } + /// + /// Encodes this value into the given encoder. + /// + /// If the value fails to encode anything, `encoder` will encode an empty + /// keyed container in its place. + /// + /// This function throws an error if any values are invalid for the given + /// encoder's format. + /// + /// - Parameter encoder: The encoder to write data to. + /// + /// - throws: `EncodingError.invalidValue` if the given value is invalid in + /// the current context for this format. + /// public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/TVSeriesListItem.swift b/Sources/TMDb/Domain/Models/TVSeriesListItem.swift index bfaf08dc..f41ea3f3 100644 --- a/Sources/TMDb/Domain/Models/TVSeriesListItem.swift +++ b/Sources/TMDb/Domain/Models/TVSeriesListItem.swift @@ -170,6 +170,18 @@ extension TVSeriesListItem { case isAdultOnly = "adult" } + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let container2 = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/TMDb/Domain/Models/VideoSize.swift b/Sources/TMDb/Domain/Models/VideoSize.swift index e6a7e2de..11f85140 100644 --- a/Sources/TMDb/Domain/Models/VideoSize.swift +++ b/Sources/TMDb/Domain/Models/VideoSize.swift @@ -49,6 +49,18 @@ public enum VideoSize: Int, Codable, Equatable, Hashable, Sendable { /// case unknown + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { self = try VideoSize(rawValue: decoder.singleValueContainer().decode(RawValue.self)) diff --git a/Sources/TMDb/Domain/Models/VideoType.swift b/Sources/TMDb/Domain/Models/VideoType.swift index 70733205..f861ba13 100644 --- a/Sources/TMDb/Domain/Models/VideoType.swift +++ b/Sources/TMDb/Domain/Models/VideoType.swift @@ -64,6 +64,18 @@ public enum VideoType: String, Codable, Equatable, Hashable, Sendable { /// case unknown + /// + /// Creates a new instance by decoding from the given decoder. + /// + /// This initializer throws an error if reading from the decoder fails, or + /// if the data read is corrupted or otherwise invalid. + /// + /// - Parameter decoder: The decoder to read data from. + /// + /// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type. + /// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key. + /// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key. + /// public init(from decoder: Decoder) throws { self = try VideoType(rawValue: decoder.singleValueContainer().decode(RawValue.self)) diff --git a/Sources/TMDb/Domain/Services/Account/AccountService.swift b/Sources/TMDb/Domain/Services/Account/AccountService.swift index c41a25ed..4f0a1ba1 100644 --- a/Sources/TMDb/Domain/Services/Account/AccountService.swift +++ b/Sources/TMDb/Domain/Services/Account/AccountService.swift @@ -248,6 +248,19 @@ public protocol AccountService: Sendable { extension AccountService { + /// + /// Returns a list of the user's favourited movies. + /// + /// - Parameters: + /// - sortedBy: How results should be sorted. + /// - page: The page of results to return. + /// - accountID: The user's account identifier. + /// - session: The user's TMDb session. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A list of the user's favourited movies. + /// public func favouriteMovies( sortedBy: FavouriteSort? = nil, page: Int? = nil, @@ -262,6 +275,19 @@ extension AccountService { ) } + /// + /// Returns a list of the user's favourited TV series. + /// + /// - Parameters: + /// - sortedBy: How results should be sorted. + /// - page: The page of results to return. + /// - accountID: The user's account identifier. + /// - session: The user's TMDb session. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A list of the user's favourited TV series. + /// public func favouriteTVSeries( sortedBy: FavouriteSort? = nil, page: Int? = nil, @@ -276,6 +302,19 @@ extension AccountService { ) } + /// + /// Returns a list of movies in the user's watchlist. + /// + /// - Parameters: + /// - sortedBy: How results should be sorted. + /// - page: The page of results to return. + /// - accountID: The user's account identifier. + /// - session: The user's TMDb session. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A list of movies in the user's watchlist. + /// public func movieWatchlist( sortedBy: WatchlistSort? = nil, page: Int? = nil, @@ -290,6 +329,19 @@ extension AccountService { ) } + /// + /// Returns a list of TV series in the user's watchlist. + /// + /// - Parameters: + /// - sortedBy: How results should be sorted. + /// - page: The page of results to return. + /// - accountID: The user's account identifier. + /// - session: The user's TMDb session. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A list of TV series in the user's watchlist. + /// public func tvSeriesWatchlist( sortedBy: WatchlistSort? = nil, page: Int? = nil, diff --git a/Sources/TMDb/Domain/Services/Account/Sorts/FavouriteSort.swift b/Sources/TMDb/Domain/Services/Account/Sorts/FavouriteSort.swift index b1c5a38d..d0572c67 100644 --- a/Sources/TMDb/Domain/Services/Account/Sorts/FavouriteSort.swift +++ b/Sources/TMDb/Domain/Services/Account/Sorts/FavouriteSort.swift @@ -29,6 +29,9 @@ public enum FavouriteSort: CustomStringConvertible { /// case createdAt(descending: Bool = false) + /// + /// A textual representation of this sort. + /// public var description: String { "\(fieldName).\(isDescending ? "desc" : "asc")" } diff --git a/Sources/TMDb/Domain/Services/Account/Sorts/WatchlistSort.swift b/Sources/TMDb/Domain/Services/Account/Sorts/WatchlistSort.swift index 5ab4fb4f..ed0bc759 100644 --- a/Sources/TMDb/Domain/Services/Account/Sorts/WatchlistSort.swift +++ b/Sources/TMDb/Domain/Services/Account/Sorts/WatchlistSort.swift @@ -29,6 +29,9 @@ public enum WatchlistSort: CustomStringConvertible { /// case createdAt(descending: Bool = false) + /// + /// A textual representation of this sort. + /// public var description: String { "\(fieldName).\(isDescending ? "desc" : "asc")" } diff --git a/Sources/TMDb/Domain/Services/Authentication/AuthenticationService.swift b/Sources/TMDb/Domain/Services/Authentication/AuthenticationService.swift index a2482411..72d3a2d2 100644 --- a/Sources/TMDb/Domain/Services/Authentication/AuthenticationService.swift +++ b/Sources/TMDb/Domain/Services/Authentication/AuthenticationService.swift @@ -89,8 +89,7 @@ public protocol AuthenticationService: Sendable { /// /// Creates a TMDb session using a user's username and password. /// - /// - Parameters: - /// - credential: The user's TMDb credential. + /// - Parameter credential: The user's TMDb credential. /// /// - Throws: TMDb error ``TMDbError``. /// @@ -121,6 +120,17 @@ public protocol AuthenticationService: Sendable { extension AuthenticationService { + /// + /// Builds the URL used for the user to authenticate with after requesting an intermediate request token. + /// + /// An internediate request token can be generated by calling ``requestToken()``. + /// + /// - Parameters: + /// - token: An intermediate request token. + /// - redirectURL: Optional URL to redirect to once the user has authenticated. + /// + /// - Returns: An authenticate URL. + /// public func authenticateURL(for token: Token, redirectURL: URL? = nil) -> URL { authenticateURL(for: token, redirectURL: redirectURL) } diff --git a/Sources/TMDb/Domain/Services/Companies/CompanyService.swift b/Sources/TMDb/Domain/Services/Companies/CompanyService.swift index 5d849c29..e15df686 100644 --- a/Sources/TMDb/Domain/Services/Companies/CompanyService.swift +++ b/Sources/TMDb/Domain/Services/Companies/CompanyService.swift @@ -30,8 +30,7 @@ public protocol CompanyService: Sendable { /// /// [TMDb API - Companies: Details](https://developer.themoviedb.org/reference/company-details) /// - /// - Parameters: - /// - id: The identifier of the company. + /// - Parameter id: The identifier of the company. /// /// - Throws: TMDb error ``TMDbError``. /// diff --git a/Sources/TMDb/Domain/Services/Configuration/ConfigurationService.swift b/Sources/TMDb/Domain/Services/Configuration/ConfigurationService.swift index 6053b573..87f279e2 100644 --- a/Sources/TMDb/Domain/Services/Configuration/ConfigurationService.swift +++ b/Sources/TMDb/Domain/Services/Configuration/ConfigurationService.swift @@ -42,8 +42,7 @@ public protocol ConfigurationService: Sendable { /// /// [TMDb API - Configuration: Countries](https://developer.themoviedb.org/reference/configuration-countries) /// - /// - Parameters: - /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// - Parameter language: ISO 639-1 language code to display results in. Defaults to `en`. /// /// - Throws: TMDb error ``TMDbError``. /// @@ -76,6 +75,17 @@ public protocol ConfigurationService: Sendable { extension ConfigurationService { + /// + /// Returns the list of countries used throughout TMDb. + /// + /// [TMDb API - Configuration: Countries](https://developer.themoviedb.org/reference/configuration-countries) + /// + /// - Parameter language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Countries used throughout TMDb, + /// public func countries(language: String? = nil) async throws -> [Country] { try await countries(language: language) } diff --git a/Sources/TMDb/Domain/Services/Discover/DiscoverService.swift b/Sources/TMDb/Domain/Services/Discover/DiscoverService.swift index e754413f..844a5054 100644 --- a/Sources/TMDb/Domain/Services/Discover/DiscoverService.swift +++ b/Sources/TMDb/Domain/Services/Discover/DiscoverService.swift @@ -54,6 +54,23 @@ public protocol DiscoverService: Sendable { extension DiscoverService { + /// + /// Returns movies to be discovered. + /// + /// [TMDb API - Discover: Movie](https://developer.themoviedb.org/reference/discover-movie) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - filter: Movie filter. + /// - sortedBy: How results should be sorted. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Matching movies as a pageable list. + /// public func movies( filter: DiscoverMovieFilter? = nil, sortedBy: MovieSort? = nil, @@ -63,6 +80,22 @@ extension DiscoverService { try await movies(filter: filter, sortedBy: sortedBy, page: page, language: language) } + /// + /// Returns TV series to be discovered. + /// + /// [TMDb API - Discover: TV Series](https://developer.themoviedb.org/reference/discover-tv) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - sortedBy: How results should be sorted. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Matching TV series as a pageable list. + /// public func tvSeries( sortedBy: TVSeriesSort? = nil, page: Int? = nil, diff --git a/Sources/TMDb/Domain/Services/Discover/Filters/DiscoverMovieFilter.swift b/Sources/TMDb/Domain/Services/Discover/Filters/DiscoverMovieFilter.swift index c3f019a0..16a884d2 100644 --- a/Sources/TMDb/Domain/Services/Discover/Filters/DiscoverMovieFilter.swift +++ b/Sources/TMDb/Domain/Services/Discover/Filters/DiscoverMovieFilter.swift @@ -33,9 +33,8 @@ public struct DiscoverMovieFilter { /// /// Creates a discover movies filter. /// - /// - Parameters: - /// - people: A list of Person identifiers which to return only - /// movies they have appeared in. + /// - Parameter people: A list of Person identifiers which to return + /// only movies they have appeared in. /// public init(people: [Person.ID]? = nil) { self.people = people diff --git a/Sources/TMDb/Domain/Services/Discover/Sorts/MovieSort.swift b/Sources/TMDb/Domain/Services/Discover/Sorts/MovieSort.swift index 99ff0316..739bb9dc 100644 --- a/Sources/TMDb/Domain/Services/Discover/Sorts/MovieSort.swift +++ b/Sources/TMDb/Domain/Services/Discover/Sorts/MovieSort.swift @@ -59,6 +59,9 @@ public enum MovieSort: CustomStringConvertible, Equatable, Sendable { /// case voteCount(descending: Bool = true) + /// + /// A textual representation of this sort. + /// public var description: String { "\(fieldName).\(isDescending ? "desc" : "asc")" } diff --git a/Sources/TMDb/Domain/Services/Discover/Sorts/TVSeriesSort.swift b/Sources/TMDb/Domain/Services/Discover/Sorts/TVSeriesSort.swift index eb4b2efb..2d89da31 100644 --- a/Sources/TMDb/Domain/Services/Discover/Sorts/TVSeriesSort.swift +++ b/Sources/TMDb/Domain/Services/Discover/Sorts/TVSeriesSort.swift @@ -39,6 +39,9 @@ public enum TVSeriesSort: CustomStringConvertible, Equatable, Sendable { /// case voteAverage(descending: Bool = true) + /// + /// A textual representation of this sort. + /// public var description: String { "\(fieldName).\(isDescending ? "desc" : "asc")" } diff --git a/Sources/TMDb/Domain/Services/Genres/GenreService.swift b/Sources/TMDb/Domain/Services/Genres/GenreService.swift index edef8970..b1a9dc7d 100644 --- a/Sources/TMDb/Domain/Services/Genres/GenreService.swift +++ b/Sources/TMDb/Domain/Services/Genres/GenreService.swift @@ -30,8 +30,7 @@ public protocol GenreService: Sendable { /// /// [TMDb API - Genres: Movie List](https://developer.themoviedb.org/reference/genre-movie-list) /// - /// - Parameters: - /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// - Parameter language: ISO 639-1 language code to display results in. Defaults to `en`. /// /// - Throws: TMDb error ``TMDbError``. /// @@ -44,8 +43,7 @@ public protocol GenreService: Sendable { /// /// [TMDb API - Genres: TV List](https://developer.themoviedb.org/reference/genre-tv-list) /// - /// - Parameters: - /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// - Parameter language: ISO 639-1 language code to display results in. Defaults to `en`. /// /// - Throws: TMDb error ``TMDbError``. /// @@ -57,10 +55,32 @@ public protocol GenreService: Sendable { extension GenreService { + /// + /// Returns the list of official genres for movies. + /// + /// [TMDb API - Genres: Movie List](https://developer.themoviedb.org/reference/genre-movie-list) + /// + /// - Parameter language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A list of genres. + /// public func movieGenres(language: String? = nil) async throws -> [Genre] { try await movieGenres(language: language) } + /// + /// Returns the list of official genres for TV series. + /// + /// [TMDb API - Genres: TV List](https://developer.themoviedb.org/reference/genre-tv-list) + /// + /// - Parameter language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A list of genres. + /// public func tvSeriesGenres(language: String? = nil) async throws -> [Genre] { try await tvSeriesGenres(language: language) } diff --git a/Sources/TMDb/Domain/Services/Movies/MovieService.swift b/Sources/TMDb/Domain/Services/Movies/MovieService.swift index 88266e62..391dd03c 100644 --- a/Sources/TMDb/Domain/Services/Movies/MovieService.swift +++ b/Sources/TMDb/Domain/Services/Movies/MovieService.swift @@ -71,8 +71,11 @@ public protocol MovieService: Sendable { /// /// - Returns: Reviews for the matching movie as a pageable list. /// - func reviews(forMovie movieID: Movie.ID, page: Int?, language: String?) async throws - -> ReviewPageableList + func reviews( + forMovie movieID: Movie.ID, + page: Int?, + language: String? + ) async throws -> ReviewPageableList /// /// Returns the images that belong to a movie. @@ -87,8 +90,10 @@ public protocol MovieService: Sendable { /// /// - Returns: Collection of images for the matching movie. /// - func images(forMovie movieID: Movie.ID, filter: MovieImageFilter?) async throws - -> ImageCollection + func images( + forMovie movieID: Movie.ID, + filter: MovieImageFilter? + ) async throws -> ImageCollection /// /// Returns the videos that have been added to a movie. @@ -103,8 +108,10 @@ public protocol MovieService: Sendable { /// /// - Returns: Collection of videos for the matching movie. /// - func videos(forMovie movieID: Movie.ID, filter: MovieVideoFilter?) async throws - -> VideoCollection + func videos( + forMovie movieID: Movie.ID, + filter: MovieVideoFilter? + ) async throws -> VideoCollection /// /// Returns a list of recommended movies for a movie. @@ -122,8 +129,11 @@ public protocol MovieService: Sendable { /// /// - Returns: Recommended movies for the matching movie as a pageable list. /// - func recommendations(forMovie movieID: Movie.ID, page: Int?, language: String?) async throws - -> MoviePageableList + func recommendations( + forMovie movieID: Movie.ID, + page: Int?, + language: String? + ) async throws -> MoviePageableList /// /// Returns a list of similar movies for a movie. @@ -143,8 +153,11 @@ public protocol MovieService: Sendable { /// /// - Returns: Similar movies for the matching movie as a pageable list. /// - func similar(toMovie movieID: Movie.ID, page: Int?, language: String?) async throws - -> MoviePageableList + func similar( + toMovie movieID: Movie.ID, + page: Int?, + language: String? + ) async throws -> MoviePageableList /// /// Returns a list of currently playing movies. @@ -162,8 +175,11 @@ public protocol MovieService: Sendable { /// /// - Returns: Now playing movies as a pageable list. /// - func nowPlaying(page: Int?, country: String?, language: String?) async throws - -> MoviePageableList + func nowPlaying( + page: Int?, + country: String?, + language: String? + ) async throws -> MoviePageableList /// /// Returns a list of current popular movies. @@ -220,7 +236,7 @@ public protocol MovieService: Sendable { func upcoming(page: Int?, country: String?, language: String?) async throws -> MoviePageableList /// - /// Returns watch providers for a movie + /// Returns watch providers for a movie. /// /// [TMDb API - Movie: Watch providers](https://developer.themoviedb.org/reference/movie-watch-providers) /// @@ -234,16 +250,19 @@ public protocol MovieService: Sendable { /// /// - Returns: Watch providers for movie in current region. /// - func watchProviders(forMovie movieID: Movie.ID, country: String) async throws - -> ShowWatchProvider? + func watchProviders( + forMovie movieID: Movie.ID, + country: String + ) async throws -> ShowWatchProvider? /// /// Returns a collection of media databases and social links for a movie. /// /// [TMDb API - Movie: External IDs](https://developer.themoviedb.org/reference/movie-external-ids) /// - /// - Parameters: - /// - movieID: The identifier of the movie. + /// - Parameter movieID: The identifier of the movie. + /// + /// - Throws: TMDb data error ``TMDbError``. /// /// - Returns: A collection of external links for the specificed movie. /// @@ -253,16 +272,59 @@ public protocol MovieService: Sendable { extension MovieService { + /// + /// Returns the primary information about a movie. + /// + /// [TMDb API - Movies: Details](https://developer.themoviedb.org/reference/movie-details) + /// + /// - Parameters: + /// - id: The identifier of the movie. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: The matching movie. + /// public func details(forMovie id: Movie.ID, language: String? = nil) async throws -> Movie { try await details(forMovie: id, language: language) } - public func credits(forMovie movieID: Movie.ID, language: String? = nil) async throws - -> ShowCredits - { + /// + /// Returns the cast and crew of a movie. + /// + /// [TMDb API - Movies: Credits](https://developer.themoviedb.org/reference/movie-credits) + /// + /// - Parameters: + /// - movieID: The identifier of the movie. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Credits for the matching movie. + /// + public func credits( + forMovie movieID: Movie.ID, + language: String? = nil + ) async throws -> ShowCredits { try await credits(forMovie: movieID, language: language) } + /// + /// Returns the user reviews for a movie. + /// + /// [TMDb API - Movies: Reviews](https://developer.themoviedb.org/reference/movie-reviews) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - movieID: The identifier of the movie. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Reviews for the matching movie as a pageable list. + /// public func reviews( forMovie movieID: Movie.ID, page: Int? = nil, @@ -271,18 +333,62 @@ extension MovieService { try await reviews(forMovie: movieID, page: page, language: language) } - public func images(forMovie movieID: Movie.ID, filter: MovieImageFilter? = nil) async throws - -> ImageCollection - { + /// + /// Returns the images that belong to a movie. + /// + /// [TMDb API - Movies: Images](https://developer.themoviedb.org/reference/movie-images) + /// + /// - Parameters: + /// - movieID: The identifier of the movie. + /// - filter: Image filter. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Collection of images for the matching movie. + /// + public func images( + forMovie movieID: Movie.ID, + filter: MovieImageFilter? = nil + ) async throws -> ImageCollection { try await images(forMovie: movieID, filter: filter) } - public func videos(forMovie movieID: Movie.ID, filter: MovieVideoFilter? = nil) async throws - -> VideoCollection - { + /// + /// Returns the videos that have been added to a movie. + /// + /// [TMDb API - Movies: Videos](https://developer.themoviedb.org/reference/movie-videos) + /// + /// - Parameters: + /// - movieID: The identifier of the movie. + /// - filter: Video filter. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Collection of videos for the matching movie. + /// + public func videos( + forMovie movieID: Movie.ID, + filter: MovieVideoFilter? = nil + ) async throws -> VideoCollection { try await videos(forMovie: movieID, filter: filter) } + /// + /// Returns a list of recommended movies for a movie. + /// + /// [TMDb API - Movies: Recommendations](https://developer.themoviedb.org/reference/movie-recommendations) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - movieID: The identifier of the movie for get recommendations for. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Recommended movies for the matching movie as a pageable list. + /// public func recommendations( forMovie movieID: Movie.ID, page: Int? = nil, @@ -291,6 +397,24 @@ extension MovieService { try await recommendations(forMovie: movieID, page: page, language: language) } + /// + /// Returns a list of similar movies for a movie. + /// + /// This is not the same as the *Recommendations*. + /// + /// [TMDb API - Movies: Similar](https://developer.themoviedb.org/reference/movie-similar) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - movieID: The identifier of the movie for get similar movies for. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Similar movies for the matching movie as a pageable list. + /// public func similar( toMovie movieID: Movie.ID, page: Int? = nil, @@ -299,6 +423,22 @@ extension MovieService { try await similar(toMovie: movieID, page: page, language: language) } + /// + /// Returns a list of currently playing movies. + /// + /// [TMDb API - Movie Lists: Now Playing](https://developer.themoviedb.org/reference/movie-now-playing-list) + /// + /// - precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - page: The page of results to return. + /// - country: ISO-3166-1 country code to fetch results for. Defaults to `US`. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Now playing movies as a pageable list. + /// public func nowPlaying( page: Int? = nil, country: String? = nil, @@ -307,6 +447,22 @@ extension MovieService { try await nowPlaying(page: page, country: country, language: language) } + /// + /// Returns a list of current popular movies. + /// + /// [TMDb API - Movie List: Popular](https://developer.themoviedb.org/reference/movie-popular-list) + /// + /// - precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - page: The page of results to return. + /// - country: ISO-3166-1 country code to fetch results for. Defaults to `US`. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Current popular movies as a pageable list. + /// public func popular( page: Int? = nil, country: String? = nil, @@ -315,6 +471,22 @@ extension MovieService { try await popular(page: page, country: country, language: language) } + /// + /// Returns a list of top rated movies. + /// + /// [TMDb API - Movie List: Top Rated](https://developer.themoviedb.org/reference/movie-top-rated-list) + /// + /// - precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - page: The page of results to return. + /// - country: ISO-3166-1 country code to fetch results for. Defaults to `US`. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Top rated movies as a pageable list. + /// public func topRated( page: Int? = nil, country: String? = nil, @@ -323,6 +495,22 @@ extension MovieService { try await topRated(page: page, country: country, language: language) } + /// + /// Returns a list of upcoming movies. + /// + /// [TMDb API - Movie List: Upcoming](https://developer.themoviedb.org/reference/movie-upcoming-list) + /// + /// - precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - page: The page of results to return. + /// - country: ISO-3166-1 country code to fetch results for. Defaults to `US`. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Upcoming movies as a pageable list. + /// public func upcoming( page: Int? = nil, country: String? = nil, @@ -331,9 +519,25 @@ extension MovieService { try await upcoming(page: page, country: country, language: language) } - public func watchProviders(forMovie movieID: Movie.ID, country: String = "US") async throws - -> ShowWatchProvider? - { + /// + /// Returns watch providers for a movie. + /// + /// [TMDb API - Movie: Watch providers](https://developer.themoviedb.org/reference/movie-watch-providers) + /// + /// Data provided by [JustWatch](https://www.justwatch.com). + /// + /// - Parameters: + /// - movieID: The identifier of the movie. + /// - country: ISO-3166-1 country code to fetch results for. Defaults to `US`. + /// + /// - Throws: TMDb data error ``TMDbError``. + /// + /// - Returns: Watch providers for movie in current region. + /// + public func watchProviders( + forMovie movieID: Movie.ID, + country: String = "US" + ) async throws -> ShowWatchProvider? { try await watchProviders(forMovie: movieID, country: country) } diff --git a/Sources/TMDb/Domain/Services/People/PersonService.swift b/Sources/TMDb/Domain/Services/People/PersonService.swift index f22e910a..0f8b59df 100644 --- a/Sources/TMDb/Domain/Services/People/PersonService.swift +++ b/Sources/TMDb/Domain/Services/People/PersonService.swift @@ -53,8 +53,10 @@ public protocol PersonService: Sendable { /// /// - Returns: The matching person's combined movie and TV series credits. /// - func combinedCredits(forPerson personID: Person.ID, language: String?) async throws - -> PersonCombinedCredits + func combinedCredits( + forPerson personID: Person.ID, + language: String? + ) async throws -> PersonCombinedCredits /// /// Returns the movie credits of a person. @@ -69,8 +71,10 @@ public protocol PersonService: Sendable { /// /// - Returns: The matching person's movie credits. /// - func movieCredits(forPerson personID: Person.ID, language: String?) async throws - -> PersonMovieCredits + func movieCredits( + forPerson personID: Person.ID, + language: String? + ) async throws -> PersonMovieCredits /// /// Returns the TV series credits of a person. @@ -85,16 +89,17 @@ public protocol PersonService: Sendable { /// /// - Returns: The matching person's TV series credits. /// - func tvSeriesCredits(forPerson personID: Person.ID, language: String?) async throws - -> PersonTVSeriesCredits + func tvSeriesCredits( + forPerson personID: Person.ID, + language: String? + ) async throws -> PersonTVSeriesCredits /// /// Returns the images for a person. /// /// [TMDb API - People: Images](https://developer.themoviedb.org/reference/person-images) /// - /// - Parameters: - /// - personID: The identifier of the person. + /// - Parameter personID: The identifier of the person. /// /// - Throws: TMDb error ``TMDbError``. /// @@ -124,8 +129,9 @@ public protocol PersonService: Sendable { /// /// [TMDb API - People: External IDs](https://developer.themoviedb.org/reference/person-external-ids) /// - /// - Parameters: - /// - personID: The identifier of the person. + /// - Parameter personID: The identifier of the person. + /// + /// - Throws: TMDb error ``TMDbError``. /// /// - Returns: A collection of external links for the specificed person. /// @@ -135,31 +141,102 @@ public protocol PersonService: Sendable { extension PersonService { + /// + /// Returns the primary information about a person. + /// + /// [TMDb API - People: Details](https://developer.themoviedb.org/reference/person-details) + /// + /// - Parameters: + /// - id: The identifier of the person. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: The matching person. + /// public func details(forPerson id: Person.ID, language: String? = nil) async throws -> Person { try await details(forPerson: id, language: language) } - public func combinedCredits(forPerson personID: Person.ID, language: String? = nil) async throws - -> PersonCombinedCredits - { + /// + /// Returns the combined movie and TV series credits of a person. + /// + /// [TMDb API - People: Combined Credits](https://developer.themoviedb.org/reference/person-combined-credits) + /// + /// - Parameters: + /// - personID: The identifier of the person. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: The matching person's combined movie and TV series credits. + /// + public func combinedCredits( + forPerson personID: Person.ID, + language: String? = nil + ) async throws -> PersonCombinedCredits { try await combinedCredits(forPerson: personID, language: language) } - public func movieCredits(forPerson personID: Person.ID, language: String? = nil) async throws - -> PersonMovieCredits - { + /// + /// Returns the movie credits of a person. + /// + /// [TMDb API - People: Movie Credits](https://developer.themoviedb.org/reference/person-movie-credits) + /// + /// - Parameters: + /// - personID: The identifier of the person. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: The matching person's movie credits. + /// + public func movieCredits( + forPerson personID: Person.ID, + language: String? = nil + ) async throws -> PersonMovieCredits { try await movieCredits(forPerson: personID, language: language) } - public func tvSeriesCredits(forPerson personID: Person.ID, language: String? = nil) async throws - -> PersonTVSeriesCredits - { + /// + /// Returns the TV series credits of a person. + /// + /// [TMDb API - People: TV Credits](https://developer.themoviedb.org/reference/person-tv-credits) + /// + /// - Parameters: + /// - personID: The identifier of the person. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: The matching person's TV series credits. + /// + public func tvSeriesCredits( + forPerson personID: Person.ID, + language: String? = nil + ) async throws -> PersonTVSeriesCredits { try await tvSeriesCredits(forPerson: personID, language: language) } - public func popular(page: Int? = nil, language: String? = nil) async throws - -> PersonPageableList - { + /// + /// Returns the list of popular people. + /// + /// [TMDb API - People Lists: Popular](https://developer.themoviedb.org/reference/person-popular-list) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Current popular people as a pageable list. + /// + public func popular( + page: Int? = nil, + language: String? = nil + ) async throws -> PersonPageableList { try await popular(page: page, language: language) } diff --git a/Sources/TMDb/Domain/Services/Search/SearchService.swift b/Sources/TMDb/Domain/Services/Search/SearchService.swift index f4028ac5..707e0915 100644 --- a/Sources/TMDb/Domain/Services/Search/SearchService.swift +++ b/Sources/TMDb/Domain/Services/Search/SearchService.swift @@ -125,6 +125,23 @@ public protocol SearchService: Sendable { extension SearchService { + /// + /// Returns search results for movies, TV series and people based on a query. + /// + /// [TMDb API - Search: Multi](https://developer.themoviedb.org/reference/search-multi) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - query: A text query to search for. + /// - filter: Search filter. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Movies, TV series and people matching the query. + /// public func searchAll( query: String, filter: AllMediaSearchFilter? = nil, @@ -134,6 +151,23 @@ extension SearchService { try await searchAll(query: query, filter: filter, page: page, language: language) } + /// + /// Returns search results for movies. + /// + /// [TMDb API - Search: Movies](https://developer.themoviedb.org/reference/search-movie) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - query: A text query to search for. + /// - filter: Search filter. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Movies matching the query. + /// public func searchMovies( query: String, filter: MovieSearchFilter? = nil, @@ -143,6 +177,23 @@ extension SearchService { try await searchMovies(query: query, filter: filter, page: page, language: language) } + /// + /// Returns search results for TV series. + /// + /// [TMDb API - Search: TV](https://developer.themoviedb.org/reference/search-tv) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - query: A text query to search for. + /// - filter: Search filter. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: TV series matching the query. + /// public func searchTVSeries( query: String, filter: TVSeriesSearchFilter? = nil, @@ -152,6 +203,23 @@ extension SearchService { try await searchTVSeries(query: query, filter: filter, page: page, language: language) } + /// + /// Returns search results for people. + /// + /// [TMDb API - Search: Person](https://developer.themoviedb.org/reference/search-person) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - query: A text query to search for. + /// - filter: Search filter. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: People matching the query. + /// public func searchPeople( query: String, filter: PersonSearchFilter? = nil, diff --git a/Sources/TMDb/Domain/Services/TVEpisodes/TVEpisodeService.swift b/Sources/TMDb/Domain/Services/TVEpisodes/TVEpisodeService.swift index 6f0758b4..429d81cb 100644 --- a/Sources/TMDb/Domain/Services/TVEpisodes/TVEpisodeService.swift +++ b/Sources/TMDb/Domain/Services/TVEpisodes/TVEpisodeService.swift @@ -95,6 +95,21 @@ public protocol TVEpisodeService: Sendable { extension TVEpisodeService { + /// + /// Returns the primary information about a TV episode. + /// + /// [TMDb API - TV Episodes: Details](https://developer.themoviedb.org/reference/tv-episode-details) + /// + /// - Parameters: + /// - episodeNumber: The episode number of a TV series. + /// - seasonNumber: The season number of a TV series. + /// - tvSeriesID: The identifier of the TV series. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A episode of the matching TV series. + /// public func details( forEpisode episodeNumber: Int, inSeason seasonNumber: Int, @@ -109,6 +124,21 @@ extension TVEpisodeService { ) } + /// + /// Returns the images that belong to a TV episode. + /// + /// [TMDb API - TV Episode: Images](https://developer.themoviedb.org/reference/tv-episode-images) + /// + /// - Parameters: + /// - episodeNumber: The episode number of a TV. + /// - seasonNumber: The season number of a TV. + /// - tvSeriesID: The identifier of the TV. + /// - filter: Image filter. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A collection of images for the matching TV's episode. + /// public func images( forEpisode episodeNumber: Int, inSeason seasonNumber: Int, @@ -123,6 +153,21 @@ extension TVEpisodeService { ) } + /// + /// Returns the videos that belong to a TV series episode. + /// + /// [TMDb API - TV Episode: Videos](https://developer.themoviedb.org/reference/tv-episode-videos) + /// + /// - Parameters: + /// - episodeNumber: The episode number of a TV. + /// - seasonNumber: The season number of a TV. + /// - tvSeriesID: The identifier of the TV series. + /// - filter: Video filter. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A collection of videos for the matching TV's episode. + /// public func videos( forEpisode episodeNumber: Int, inSeason seasonNumber: Int, diff --git a/Sources/TMDb/Domain/Services/TVSeasons/TVSeasonService.swift b/Sources/TMDb/Domain/Services/TVSeasons/TVSeasonService.swift index 718c0206..209e43b8 100644 --- a/Sources/TMDb/Domain/Services/TVSeasons/TVSeasonService.swift +++ b/Sources/TMDb/Domain/Services/TVSeasons/TVSeasonService.swift @@ -113,6 +113,20 @@ public protocol TVSeasonService: Sendable { extension TVSeasonService { + /// + /// Returns the primary information about a TV season. + /// + /// [TMDb API - TV Seasons: Details](https://developer.themoviedb.org/reference/tv-season-details) + /// + /// - Parameters: + /// - seasonNumber: The season number of a TV series. + /// - tvSeriesID: The identifier of the TV series. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A season of the matching TV series. + /// public func details( forSeason seasonNumber: Int, inTVSeries tvSeriesID: TVSeries.ID, @@ -121,6 +135,24 @@ extension TVSeasonService { try await details(forSeason: seasonNumber, inTVSeries: tvSeriesID, language: language) } + /// + /// Returns the aggregate cast and crew of a TV season. + /// + /// This call differs from the main credits call in that it does not return + /// the newest season. Instead, it is a view of all the entire cast & crew + /// for all episodes belonging to a TV season. + /// + /// [TMDb API - TV Season: Aggregate Credits](https://developer.themoviedb.org/reference/tv-season-aggregate-credits) + /// + /// - Parameters: + /// - seasonNumber: The season number of a TV series. + /// - tvSeriesID: The identifier of the TV series. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Show credits for the matching TV season. + /// public func aggregateCredits( forSeason seasonNumber: Int, inTVSeries tvSeriesID: TVSeries.ID, @@ -130,6 +162,20 @@ extension TVSeasonService { forSeason: seasonNumber, inTVSeries: tvSeriesID, language: language) } + /// + /// Returns the images that belong to a TV season. + /// + /// [TMDb API - TV Seasons: Images](https://developer.themoviedb.org/reference/tv-season-images) + /// + /// - Parameters: + /// - seasonNumber: The season number of a TV series. + /// - tvSeriesID: The identifier of the TV series. + /// - filter: Image filter. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A collection of images for the matching TV's season. + /// public func images( forSeason seasonNumber: Int, inTVSeries tvSeriesID: TVSeries.ID, @@ -138,6 +184,20 @@ extension TVSeasonService { try await images(forSeason: seasonNumber, inTVSeries: tvSeriesID, filter: filter) } + /// + /// Returns the videos that belong to a TV season. + /// + /// [TMDb API - TV Seasons: Videos](https://developer.themoviedb.org/reference/tv-season-videos) + /// + /// - Parameters: + /// - seasonNumber: The season number of a TV series. + /// - tvSeriesID: The identifier of the TV series. + /// - filter: Video filter. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A collection of videos for the matching TV series season. + /// public func videos( forSeason seasonNumber: Int, inTVSeries tvSeriesID: TVSeries.ID, diff --git a/Sources/TMDb/Domain/Services/TVSeries/TVSeriesService.swift b/Sources/TMDb/Domain/Services/TVSeries/TVSeriesService.swift index d339c999..851e8a23 100644 --- a/Sources/TMDb/Domain/Services/TVSeries/TVSeriesService.swift +++ b/Sources/TMDb/Domain/Services/TVSeries/TVSeriesService.swift @@ -206,7 +206,10 @@ public protocol TVSeriesService: Sendable { /// /// - Returns: Watch providers for TV series in current region. /// - func watchProviders(forTVSeries tvSeriesID: TVSeries.ID, country: String) async throws + func watchProviders( + forTVSeries tvSeriesID: TVSeries.ID, + country: String + ) async throws -> ShowWatchProvider? /// @@ -214,12 +217,15 @@ public protocol TVSeriesService: Sendable { /// /// [TMDb API - TVSeries: External IDs](https://developer.themoviedb.org/reference/tv-series-external-ids) /// - /// - Parameters: - /// - tvSeriesID: The identifier of the TV series. + /// - Parameters tvSeriesID: The identifier of the TV series. + /// + /// - Throws: TMDb error ``TMDbError``. /// /// - Returns: A collection of external links for the specificed TV series. /// - func externalLinks(forTVSeries tvSeriesID: TVSeries.ID) async throws + func externalLinks( + forTVSeries tvSeriesID: TVSeries.ID + ) async throws -> TVSeriesExternalLinksCollection /// @@ -231,6 +237,8 @@ public protocol TVSeriesService: Sendable { /// - tvSeriesID: The identifier of the TV series. /// - country: ISO-3166-1 country code to fetch results for. Defaults to `US`. /// + /// - Throws: TMDb error ``TMDbError``. + /// /// - Returns: A content rating for the specificed TV series. /// func contentRatings(forTVSeries tvSeriesID: TVSeries.ID, country: String) async throws @@ -239,18 +247,62 @@ public protocol TVSeriesService: Sendable { extension TVSeriesService { + /// + /// Returns the primary information about a TV series. + /// + /// [TMDb API - TV Series: Details](https://developer.themoviedb.org/reference/tv-series-details) + /// + /// - Parameters: + /// - id: The identifier of the TV series. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: The matching TV series. + /// public func details(forTVSeries id: TVSeries.ID, language: String? = nil) async throws -> TVSeries { try await details(forTVSeries: id, language: language) } - public func credits(forTVSeries tvSeriesID: TVSeries.ID, language: String? = nil) async throws - -> ShowCredits - { + /// + /// Returns the cast and crew of a TV series. + /// + /// [TMDb API - TV Series: Credits](https://developer.themoviedb.org/reference/tv-series-credits) + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Show credits for the matching TV series. + /// + public func credits( + forTVSeries tvSeriesID: TVSeries.ID, + language: String? = nil + ) async throws -> ShowCredits { try await credits(forTVSeries: tvSeriesID, language: language) } + /// + /// Returns the aggregate cast and crew of a TV series. + /// + /// This call differs from the main credits call in that it does not return + /// the newest season. Instead, it is a view of all the entire cast & crew + /// for all episodes belonging to a TV series. + /// + /// [TMDb API - TV Series: Aggregate Credits](https://developer.themoviedb.org/reference/tv-series-aggregate-credits) + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Show credits for the matching TV series. + /// public func aggregateCredits( forTVSeries tvSeriesID: TVSeries.ID, language: String? = nil @@ -258,6 +310,22 @@ extension TVSeriesService { try await aggregateCredits(forTVSeries: tvSeriesID, language: language) } + /// + /// Returns the user reviews for a TV series. + /// + /// [TMDb API - TV Series: Reviews](https://developer.themoviedb.org/reference/tv-series-reviews) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Reviews for the matching TV series as a pageable list. + /// public func reviews( forTVSeries tvSeriesID: TVSeries.ID, page: Int? = nil, @@ -266,6 +334,19 @@ extension TVSeriesService { try await reviews(forTVSeries: tvSeriesID, page: page, language: language) } + /// + /// Returns the images that belong to a TV series. + /// + /// [TMDb API - TV Series: Images](https://developer.themoviedb.org/reference/tv-series-images) + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series. + /// - filter: Image filter. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A collection of images for the matching TV series. + /// public func images( forTVSeries tvSeriesID: TVSeries.ID, filter: TVSeriesImageFilter? = nil @@ -273,6 +354,19 @@ extension TVSeriesService { try await images(forTVSeries: tvSeriesID, filter: filter) } + /// + /// Returns the videos that belong to a TV series. + /// + /// [TMDb API - TV Series: Videos](https://developer.themoviedb.org/reference/tv-series-videos) + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series. + /// - filter: Video filter. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: A collection of videos for the matching TV series. + /// public func videos( forTVSeries tvSeriesID: TVSeries.ID, filter: TVSeriesVideoFilter? = nil @@ -280,6 +374,22 @@ extension TVSeriesService { try await videos(forTVSeries: tvSeriesID, filter: filter) } + /// + /// Returns a list of recommended TV series for a TV series. + /// + /// [TMDb API - TV Series: Recommendations](https://developer.themoviedb.org/reference/tv-series-recommendations) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Recommended TV series for the matching TV series as a pageable list. + /// public func recommendations( forTVSeries tvSeriesID: TVSeries.ID, page: Int? = nil, @@ -288,6 +398,24 @@ extension TVSeriesService { try await recommendations(forTVSeries: tvSeriesID, page: page, language: language) } + /// + /// Returns a list of similar TV series for a TV series. + /// + /// This is not the same as the *Recommendations*. + /// + /// [TMDb API - TV Series: Similar](https://developer.themoviedb.org/reference/tv-series-similar) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series for get similar TV series for. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Similar TV series for the matching TV series as a pageable list. + /// public func similar( toTVSeries tvSeriesID: TVSeries.ID, page: Int? = nil, @@ -296,12 +424,43 @@ extension TVSeriesService { try await similar(toTVSeries: tvSeriesID, page: page, language: language) } - public func popular(page: Int? = nil, language: String? = nil) async throws - -> TVSeriesPageableList - { + /// + /// Returns a list current popular TV series. + /// + /// [TMDb API - TV Series Lists: Popular](https://developer.themoviedb.org/reference/tv-series-popular-list) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Current popular TV series as a pageable list. + /// + public func popular( + page: Int? = nil, + language: String? = nil + ) async throws -> TVSeriesPageableList { try await popular(page: page, language: language) } + /// + /// Returns watch providers for a TV series. + /// + /// [TMDb API - TVSeries: Watch providers](https://developer.themoviedb.org/reference/tv-series-watch-providers) + /// + /// Data provided by [JustWatch](https://www.justwatch.com). + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series. + /// - country: ISO-3166-1 country code to fetch results for. Defaults to `US`. + /// + /// - Throws: TMDb data error ``TMDbError``. + /// + /// - Returns: Watch providers for TV series in current region. + /// public func watchProviders( forTVSeries tvSeriesID: TVSeries.ID, country: String = "US" @@ -309,10 +468,24 @@ extension TVSeriesService { try await watchProviders(forTVSeries: tvSeriesID, country: country) } + /// + /// Returns the content rating of a TV series. + /// + /// [TMDb API - TVSeries: Content ratings](https://developer.themoviedb.org/reference/tv-series-content-ratings) + /// + /// - Parameters: + /// - tvSeriesID: The identifier of the TV series. + /// - country: ISO-3166-1 country code to fetch results for. Defaults to `US`. + /// + /// - Throws: TMDb data error ``TMDbError``. + /// + /// - Returns: A content rating for the specificed TV series. + /// public func contentRatings( forTVSeries tvSeriesID: TVSeries.ID, country: String = "US" ) async throws -> ContentRating? { try await contentRatings(forTVSeries: tvSeriesID, country: country) } + } diff --git a/Sources/TMDb/Domain/Services/Trending/TrendingService.swift b/Sources/TMDb/Domain/Services/Trending/TrendingService.swift index bb091c2d..5261f35d 100644 --- a/Sources/TMDb/Domain/Services/Trending/TrendingService.swift +++ b/Sources/TMDb/Domain/Services/Trending/TrendingService.swift @@ -104,6 +104,25 @@ public protocol TrendingService: Sendable { extension TrendingService { + /// + /// Returns a list of the daily or weekly trending movies. + /// + /// The daily trending list tracks movies over the period of a day while movies have a 24 hour half life. The + /// weekly list tracks movies over a 7 day period, with a 7 day half life. + /// + /// [TMDb API - Trending: Movies](https://developer.themoviedb.org/reference/trending-all) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - timeWindow: Daily or weekly time window. Defaults to daily. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Trending movies in a time window as a pageable list. + /// public func movies( inTimeWindow timeWindow: TrendingTimeWindowFilterType = .day, page: Int? = nil, @@ -112,6 +131,25 @@ extension TrendingService { try await movies(inTimeWindow: timeWindow, page: page, language: language) } + /// + /// Returns a list of the daily or weekly trending TV series. + /// + /// The daily trending list tracks TV series over the period of a day while TV series have a 24 hour half life. The + /// weekly list tracks TV series over a 7 day period, with a 7 day half life. + /// + /// [TMDb API - Trending: TV](https://developer.themoviedb.org/reference/trending-tv) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - timeWindow: Daily or weekly time window. Defaults to daily. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Trending TV series in a time window as a pageable list. + /// public func tvSeries( inTimeWindow timeWindow: TrendingTimeWindowFilterType = .day, page: Int? = nil, @@ -120,6 +158,25 @@ extension TrendingService { try await tvSeries(inTimeWindow: timeWindow, page: page, language: language) } + /// + /// Returns a list of the daily or weekly trending people. + /// + /// The daily trending list tracks people over the period of a day while people shows have a 24 hour half life. The + /// weekly list tracks people over a 7 day period, with a 7 day half life. + /// + /// [TMDb API - Trending: People](https://developer.themoviedb.org/reference/trending-people) + /// + /// - Precondition: `page` can be between `1` and `1000`. + /// + /// - Parameters: + /// - timeWindow: Daily or weekly time window. Defaults to daily. + /// - page: The page of results to return. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Trending people in a time window as a pageable list. + /// public func people( inTimeWindow timeWindow: TrendingTimeWindowFilterType = .day, page: Int? = nil, diff --git a/Sources/TMDb/Domain/Services/WatchProviders/WatchProviderService.swift b/Sources/TMDb/Domain/Services/WatchProviders/WatchProviderService.swift index 133c7e0c..eacf7ea9 100644 --- a/Sources/TMDb/Domain/Services/WatchProviders/WatchProviderService.swift +++ b/Sources/TMDb/Domain/Services/WatchProviders/WatchProviderService.swift @@ -30,8 +30,7 @@ public protocol WatchProviderService: Sendable { /// /// [TMDb API - Watch Providers: Available Regions](https://developer.themoviedb.org/reference/watch-providers-available-regions) /// - /// - Parameters: - /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// - Parameter language: ISO 639-1 language code to display results in. Defaults to `en`. /// /// - Throws: TMDb error ``TMDbError``. /// @@ -52,8 +51,10 @@ public protocol WatchProviderService: Sendable { /// /// - Returns: Watch providers for movies. /// - func movieWatchProviders(filter: WatchProviderFilter?, language: String?) async throws - -> [WatchProvider] + func movieWatchProviders( + filter: WatchProviderFilter?, + language: String? + ) async throws -> [WatchProvider] /// /// Returns a list of the watch provider (OTT/streaming) data TMDb have available for TV series. @@ -68,17 +69,43 @@ public protocol WatchProviderService: Sendable { /// /// - Returns: Watch providers for TV series. /// - func tvSeriesWatchProviders(filter: WatchProviderFilter?, language: String?) async throws - -> [WatchProvider] + func tvSeriesWatchProviders( + filter: WatchProviderFilter?, + language: String? + ) async throws -> [WatchProvider] } extension WatchProviderService { + /// + /// Returns a list of all of the countries TMDb have watch provider (OTT/streaming) data for. + /// + /// [TMDb API - Watch Providers: Available Regions](https://developer.themoviedb.org/reference/watch-providers-available-regions) + /// + /// - Parameter language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Countries TMDb have watch provider data for. + /// public func countries(language: String? = nil) async throws -> [Country] { try await countries(language: language) } + /// + /// Returns a list of the watch provider (OTT/streaming) data TMDb have available for movies. + /// + /// [TMDb API - Watch Providers: Movie Providers](https://developer.themoviedb.org/reference/watch-providers-movie-list) + /// + /// - Parameters: + /// - filter: Watch provider filter. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Watch providers for movies. + /// public func movieWatchProviders( filter: WatchProviderFilter? = nil, language: String? = nil @@ -86,6 +113,19 @@ extension WatchProviderService { try await movieWatchProviders(filter: filter, language: language) } + /// + /// Returns a list of the watch provider (OTT/streaming) data TMDb have available for TV series. + /// + /// [TMDb API - Watch Providers: TV Providers](https://developer.themoviedb.org/reference/watch-provider-tv-list) + /// + /// - Parameters: + /// - filter: Watch provider filter. + /// - language: ISO 639-1 language code to display results in. Defaults to `en`. + /// + /// - Throws: TMDb error ``TMDbError``. + /// + /// - Returns: Watch providers for TV series. + /// public func tvSeriesWatchProviders( filter: WatchProviderFilter? = nil, language: String? = nil diff --git a/Sources/TMDb/Extensions/URL+TMDb.swift b/Sources/TMDb/Extensions/URL+TMDb.swift index e96a5fbc..dc8f49de 100644 --- a/Sources/TMDb/Extensions/URL+TMDb.swift +++ b/Sources/TMDb/Extensions/URL+TMDb.swift @@ -22,10 +22,12 @@ import Foundation extension URL { static var tmdbAPIBase: URL { + // swift-format-ignore: NeverForceUnwrap URL(string: "https://api.themoviedb.org/3")! } static var tmdbWebSite: URL { + // swift-format-ignore: NeverForceUnwrap URL(string: "https://www.themoviedb.org")! } diff --git a/Sources/TMDb/Networking/HTTPClient/HTTPClient.swift b/Sources/TMDb/Networking/HTTPClient/HTTPClient.swift index 65ab0ee2..d5fa20df 100644 --- a/Sources/TMDb/Networking/HTTPClient/HTTPClient.swift +++ b/Sources/TMDb/Networking/HTTPClient/HTTPClient.swift @@ -27,8 +27,9 @@ public protocol HTTPClient: Sendable { /// /// Performs an HTTP request. /// - /// - Parameters: - /// - request: The HTTP request. + /// - Parameter request: The HTTP request. + /// + /// - Throws: `Error`. /// /// - Returns: An HTTP response object. /// diff --git a/Sources/TMDb/Networking/TMDbAPIClient.swift b/Sources/TMDb/Networking/TMDbAPIClient.swift index ea7cfd64..66475bfd 100644 --- a/Sources/TMDb/Networking/TMDbAPIClient.swift +++ b/Sources/TMDb/Networking/TMDbAPIClient.swift @@ -119,7 +119,7 @@ extension TMDbAPIClient { urlComponents.queryItems = queryItems - return urlComponents.url! + return urlComponents.url ?? path } private static func method(from apiMethod: APIRequestMethod) -> HTTPRequest.Method { diff --git a/Sources/TMDb/TMDBClient.swift b/Sources/TMDb/TMDBClient.swift index ca68f0f7..678afeba 100644 --- a/Sources/TMDb/TMDBClient.swift +++ b/Sources/TMDb/TMDBClient.swift @@ -102,8 +102,7 @@ public final class TMDbClient: Sendable { /// /// Creates a TMDb client using `URLSession` as the `HTTPClient`. /// - /// - Parameters: - /// - apiKey: The TMDb API key to use. + /// - Parameter apiKey: The TMDb API key to use. /// public convenience init(apiKey: String) { self.init( diff --git a/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift b/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift index dd6da7b3..b1ac879d 100644 --- a/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift +++ b/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift @@ -145,7 +145,7 @@ final class URLSessionHTTPClientAdapterTests { let header2Value = "text/html" let headers = [ header1Name: header1Value, - header2Name: header2Value, + header2Name: header2Value ] let request = HTTPRequest(url: url, headers: headers) diff --git a/Tests/TMDbTests/Domain/Models/APIConfigurationTests.swift b/Tests/TMDbTests/Domain/Models/APIConfigurationTests.swift index 304d798c..a3a7d2ca 100644 --- a/Tests/TMDbTests/Domain/Models/APIConfigurationTests.swift +++ b/Tests/TMDbTests/Domain/Models/APIConfigurationTests.swift @@ -27,6 +27,8 @@ struct APIConfigurationTests { @Test("JSON decoding of APIConfiguration", .tags(.decoding)) func decodeAPIConfiguration() throws { + let apiConfiguration = try apiConfiguration() + let result = try JSONDecoder.theMovieDatabase.decode( APIConfiguration.self, fromResource: "api-configuration") @@ -34,71 +36,73 @@ struct APIConfigurationTests { #expect(result.changeKeys == apiConfiguration.changeKeys) } - private let apiConfiguration = APIConfiguration( - images: ImagesConfiguration( - baseURL: URL(string: "http://image.tmdb.org/t/p/")!, - secureBaseURL: URL(string: "https://image.tmdb.org/t/p/")!, - backdropSizes: ["w300", "w780", "w1280", "original"], - logoSizes: ["w45", "w92", "w154", "w185", "w300", "w500", "original"], - posterSizes: ["w92", "w154", "w185", "w342", "w500", "w780", "original"], - profileSizes: ["w45", "w185", "h632", "original"], - stillSizes: ["w92", "w185", "w300", "original"] - ), - changeKeys: [ - "adult", - "air_date", - "also_known_as", - "alternative_titles", - "biography", - "birthday", - "budget", - "cast", - "certifications", - "character_names", - "created_by", - "crew", - "deathday", - "episode", - "episode_number", - "episode_run_time", - "freebase_id", - "freebase_mid", - "general", - "genres", - "guest_stars", - "homepage", - "images", - "imdb_id", - "languages", - "name", - "network", - "origin_country", - "original_name", - "original_title", - "overview", - "parts", - "place_of_birth", - "plot_keywords", - "production_code", - "production_companies", - "production_countries", - "releases", - "revenue", - "runtime", - "season", - "season_number", - "season_regular", - "spoken_languages", - "status", - "tagline", - "title", - "translations", - "tvdb_id", - "tvrage_id", - "type", - "video", - "videos", - ] - ) + private func apiConfiguration() throws -> APIConfiguration { + try APIConfiguration( + images: ImagesConfiguration( + baseURL: #require(URL(string: "http://image.tmdb.org/t/p/")), + secureBaseURL: #require(URL(string: "https://image.tmdb.org/t/p/")), + backdropSizes: ["w300", "w780", "w1280", "original"], + logoSizes: ["w45", "w92", "w154", "w185", "w300", "w500", "original"], + posterSizes: ["w92", "w154", "w185", "w342", "w500", "w780", "original"], + profileSizes: ["w45", "w185", "h632", "original"], + stillSizes: ["w92", "w185", "w300", "original"] + ), + changeKeys: [ + "adult", + "air_date", + "also_known_as", + "alternative_titles", + "biography", + "birthday", + "budget", + "cast", + "certifications", + "character_names", + "created_by", + "crew", + "deathday", + "episode", + "episode_number", + "episode_run_time", + "freebase_id", + "freebase_mid", + "general", + "genres", + "guest_stars", + "homepage", + "images", + "imdb_id", + "languages", + "name", + "network", + "origin_country", + "original_name", + "original_title", + "overview", + "parts", + "place_of_birth", + "plot_keywords", + "production_code", + "production_companies", + "production_countries", + "releases", + "revenue", + "runtime", + "season", + "season_number", + "season_regular", + "spoken_languages", + "status", + "tagline", + "title", + "translations", + "tvdb_id", + "tvrage_id", + "type", + "video", + "videos" + ] + ) + } } diff --git a/Tests/TMDbTests/Domain/Models/CertificationTests.swift b/Tests/TMDbTests/Domain/Models/CertificationTests.swift index 8988ed03..f6d5d364 100644 --- a/Tests/TMDbTests/Domain/Models/CertificationTests.swift +++ b/Tests/TMDbTests/Domain/Models/CertificationTests.swift @@ -40,13 +40,11 @@ struct CertificationTests { #expect(result.order == certification.order) } - // swiftlint:disable line_length private let certification = Certification( code: "15", meaning: "Only those over 15 years are admitted. Nobody younger than 15 can rent or buy a 15-rated VHS, DVD, Blu-ray Disc, UMD or game, or watch a film in the cinema with this rating. Films under this category can contain adult themes, hard drugs, frequent strong language and limited use of very strong language, strong violence and strong sex references, and nudity without graphic detail. Sexual activity may be portrayed but without any strong detail. Sexual violence may be shown if discreet and justified by context.", order: 5 ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/CertificationsTests.swift b/Tests/TMDbTests/Domain/Models/CertificationsTests.swift index cbe85bdf..546830f4 100644 --- a/Tests/TMDbTests/Domain/Models/CertificationsTests.swift +++ b/Tests/TMDbTests/Domain/Models/CertificationsTests.swift @@ -33,7 +33,6 @@ struct CertificationsTests { #expect(result == certifications) } - // swiftlint:disable line_length private let certifications = Certifications( certifications: [ "US": [ @@ -71,7 +70,7 @@ struct CertificationsTests { meaning: "Some material may not be suitable for children under 10. These films may contain some mild language, crude/suggestive humor, scary moments and/or violence. No drug content is present. There are a few exceptions to this rule. A few racial insults may also be heard.", order: 2 - ), + ) ], "GB": [ Certification( @@ -114,10 +113,9 @@ struct CertificationsTests { meaning: "Only adults are admitted. Nobody younger than 18 can rent or buy an 18-rated VHS, DVD, Blu-ray Disc, UMD or game, or watch a film in the cinema with this rating. Films under this category do not have limitation on the bad language that is used. Hard drugs are generally allowed, and explicit sex references along with detailed sexual activity are also allowed. Scenes of strong real sex may be permitted if justified by the context. Very strong, gory, and/or sadistic violence is usually permitted. Strong sexual violence is permitted unless it is eroticised or excessively graphic.", order: 6 - ), - ], + ) + ] ] ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/CompanyTests.swift b/Tests/TMDbTests/Domain/Models/CompanyTests.swift index a0ca837f..757d4937 100644 --- a/Tests/TMDbTests/Domain/Models/CompanyTests.swift +++ b/Tests/TMDbTests/Domain/Models/CompanyTests.swift @@ -27,6 +27,21 @@ struct CompanyTests { @Test("JSON decoding of Company", .tags(.decoding)) func decodeCompany() throws { + let company = try Company( + id: 3, + name: "Pixar", + description: "", + headquarters: "Emeryville, California", + homepageURL: #require(URL(string: "http://www.pixar.com")), + logoPath: #require(URL(string: "/1TjvGVDMYsj6JBxOAkUHpPEwLf7.png")), + originCountry: "US", + parentCompany: Company.Parent( + id: 2, + name: "Walt Disney Pictures", + logoPath: #require(URL(string: "/wdrCwmRnLFJhEoH8GSfymY85KHT.png")) + ) + ) + let result = try JSONDecoder.theMovieDatabase.decode(Company.self, fromResource: "company") #expect(result.id == company.id) @@ -42,19 +57,4 @@ struct CompanyTests { #expect(parentCompany.logoPath == company.parentCompany?.logoPath) } - private let company = Company( - id: 3, - name: "Pixar", - description: "", - headquarters: "Emeryville, California", - homepageURL: URL(string: "http://www.pixar.com")!, - logoPath: URL(string: "/1TjvGVDMYsj6JBxOAkUHpPEwLf7.png")!, - originCountry: "US", - parentCompany: Company.Parent( - id: 2, - name: "Walt Disney Pictures", - logoPath: URL(string: "/wdrCwmRnLFJhEoH8GSfymY85KHT.png")! - ) - ) - } diff --git a/Tests/TMDbTests/Domain/Models/ContentRatingsTests.swift b/Tests/TMDbTests/Domain/Models/ContentRatingsTests.swift index 191014f5..6044b120 100644 --- a/Tests/TMDbTests/Domain/Models/ContentRatingsTests.swift +++ b/Tests/TMDbTests/Domain/Models/ContentRatingsTests.swift @@ -149,7 +149,7 @@ struct ContentRatingsTests { descriptors: [], countryCode: "RO", rating: "15" - ), + ) ], id: 8592 ) diff --git a/Tests/TMDbTests/Domain/Models/DepartmentTests.swift b/Tests/TMDbTests/Domain/Models/DepartmentTests.swift index 71a8b7ea..c60ce8c8 100644 --- a/Tests/TMDbTests/Domain/Models/DepartmentTests.swift +++ b/Tests/TMDbTests/Domain/Models/DepartmentTests.swift @@ -34,7 +34,7 @@ struct DepartmentTests { "Actor", "Voice", "Special Guest", - "Stunt Double", + "Stunt Double" ] ) diff --git a/Tests/TMDbTests/Domain/Models/ImageCollectionTests.swift b/Tests/TMDbTests/Domain/Models/ImageCollectionTests.swift index d405ce24..90054d13 100644 --- a/Tests/TMDbTests/Domain/Models/ImageCollectionTests.swift +++ b/Tests/TMDbTests/Domain/Models/ImageCollectionTests.swift @@ -27,6 +27,8 @@ struct ImageCollectionTests { @Test("JSON decoding of ImageCollection", .tags(.decoding)) func decodeImageCollection() throws { + let imageCollection = try imageCollection() + let result = try JSONDecoder.theMovieDatabase.decode( ImageCollection.self, fromResource: "image-collection") @@ -36,41 +38,44 @@ struct ImageCollectionTests { #expect(result.posters == imageCollection.posters) } - private let imageCollection = ImageCollection( - id: 550, - posters: [ - ImageMetadata( - filePath: URL(string: "/fpemzjF623QVTe98pCVlwwtFC5N.jpg")!, - width: 1200, - height: 1800, - aspectRatio: 0.666666666666667, - voteAverage: 5.21, - voteCount: 3, - languageCode: "en" - ) - ], - logos: [ - ImageMetadata( - filePath: URL(string: "/fasasakfRaCRCTh8GqN30f8oyQF.jpg")!, - width: 100, - height: 400, - aspectRatio: 2.5, - voteAverage: 5.31, - voteCount: 345, - languageCode: nil - ) - ], - backdrops: [ - ImageMetadata( - filePath: URL(string: "/fCayJrkfRaCRCTh8GqN30f8oyQF.jpg")!, - width: 1280, - height: 720, - aspectRatio: 1.77777777777778, - voteAverage: 1.21, - voteCount: 435, - languageCode: nil - ) - ] - ) + // swift-format-ignore: NeverForceUnwrap + private func imageCollection() throws -> ImageCollection { + try ImageCollection( + id: 550, + posters: [ + ImageMetadata( + filePath: #require(URL(string: "/fpemzjF623QVTe98pCVlwwtFC5N.jpg")), + width: 1200, + height: 1800, + aspectRatio: 0.666666666666667, + voteAverage: 5.21, + voteCount: 3, + languageCode: "en" + ) + ], + logos: [ + ImageMetadata( + filePath: #require(URL(string: "/fasasakfRaCRCTh8GqN30f8oyQF.jpg")), + width: 100, + height: 400, + aspectRatio: 2.5, + voteAverage: 5.31, + voteCount: 345, + languageCode: nil + ) + ], + backdrops: [ + ImageMetadata( + filePath: #require(URL(string: "/fCayJrkfRaCRCTh8GqN30f8oyQF.jpg")), + width: 1280, + height: 720, + aspectRatio: 1.77777777777778, + voteAverage: 1.21, + voteCount: 435, + languageCode: nil + ) + ] + ) + } } diff --git a/Tests/TMDbTests/Domain/Models/ImageMetadataTests.swift b/Tests/TMDbTests/Domain/Models/ImageMetadataTests.swift index c53b15e6..f8fbf846 100644 --- a/Tests/TMDbTests/Domain/Models/ImageMetadataTests.swift +++ b/Tests/TMDbTests/Domain/Models/ImageMetadataTests.swift @@ -25,6 +25,20 @@ import Testing @Suite(.tags(.models)) struct ImageMetadataTests { + var imageMetadata: ImageMetadata! + + init() throws { + self.imageMetadata = try ImageMetadata( + filePath: #require(URL(string: "/fCayJrkfRaCRCTh8GqN30f8oyQF.jpg")), + width: 1280, + height: 720, + aspectRatio: 1.77777777777778, + voteAverage: 5.7, + voteCount: 957, + languageCode: "en" + ) + } + @Test("ID and filePath matches") func testIDReturnsFilePath() { #expect(imageMetadata.id == imageMetadata.filePath) @@ -44,14 +58,4 @@ struct ImageMetadataTests { #expect(result.languageCode == imageMetadata.languageCode) } - private let imageMetadata = ImageMetadata( - filePath: URL(string: "/fCayJrkfRaCRCTh8GqN30f8oyQF.jpg")!, - width: 1280, - height: 720, - aspectRatio: 1.77777777777778, - voteAverage: 5.7, - voteCount: 957, - languageCode: "en" - ) - } diff --git a/Tests/TMDbTests/Domain/Models/ImagesConfiguration+URLsTests.swift b/Tests/TMDbTests/Domain/Models/ImagesConfiguration+URLsTests.swift index af132bfa..741581dd 100644 --- a/Tests/TMDbTests/Domain/Models/ImagesConfiguration+URLsTests.swift +++ b/Tests/TMDbTests/Domain/Models/ImagesConfiguration+URLsTests.swift @@ -28,19 +28,19 @@ struct ImagesConfigurationURLsTests { var configuration: ImagesConfiguration! var emptyConfiguration: ImagesConfiguration! - init() { - self.configuration = ImagesConfiguration( - baseURL: URL(string: "http://image.tmdb.org/t/p/")!, - secureBaseURL: URL(string: "https://image.tmdb.org/t/p/")!, + init() throws { + self.configuration = try ImagesConfiguration( + baseURL: #require(URL(string: "http://image.tmdb.org/t/p/")), + secureBaseURL: #require(URL(string: "https://image.tmdb.org/t/p/")), backdropSizes: ["w300", "w780", "w1280", "original"], logoSizes: ["w45", "w92", "w154", "w185", "w300", "w500", "original"], posterSizes: ["w92", "w154", "w185", "w342", "w500", "w780", "original"], profileSizes: ["w45", "w185", "h632", "original"], stillSizes: ["w92", "w185", "w300", "original"] ) - self.emptyConfiguration = ImagesConfiguration( - baseURL: URL(string: "http://image.tmdb.org/t/p/")!, - secureBaseURL: URL(string: "https://image.tmdb.org/t/p/")!, + self.emptyConfiguration = try ImagesConfiguration( + baseURL: #require(URL(string: "http://image.tmdb.org/t/p/")), + secureBaseURL: #require(URL(string: "https://image.tmdb.org/t/p/")), backdropSizes: [], logoSizes: [], posterSizes: [], diff --git a/Tests/TMDbTests/Domain/Models/ImagesConfigurationTests.swift b/Tests/TMDbTests/Domain/Models/ImagesConfigurationTests.swift index 432c7e4f..e69514f9 100644 --- a/Tests/TMDbTests/Domain/Models/ImagesConfigurationTests.swift +++ b/Tests/TMDbTests/Domain/Models/ImagesConfigurationTests.swift @@ -27,6 +27,16 @@ struct ImagesConfigurationTests { @Test("JSON decoding of ImageMetadata", .tags(.decoding)) func decodeReturnsImagesConfiguration() throws { + let imagesConfiguration = try ImagesConfiguration( + baseURL: #require(URL(string: "http://image.tmdb.org/t/p/")), + secureBaseURL: #require(URL(string: "https://image.tmdb.org/t/p/")), + backdropSizes: ["w300", "w780", "w1280", "original"], + logoSizes: ["w45", "w92", "w154", "w185", "w300", "w500", "original"], + posterSizes: ["w92", "w154", "w185", "w342", "w500", "w780", "original"], + profileSizes: ["w45", "w185", "h632", "original"], + stillSizes: ["w92", "w185", "w300", "original"] + ) + let result = try JSONDecoder.theMovieDatabase .decode(ImagesConfiguration.self, fromResource: "images-configuration") @@ -39,45 +49,4 @@ struct ImagesConfigurationTests { #expect(result.stillSizes == imagesConfiguration.stillSizes) } - private let imagesConfiguration = ImagesConfiguration( - baseURL: URL(string: "http://image.tmdb.org/t/p/")!, - secureBaseURL: URL(string: "https://image.tmdb.org/t/p/")!, - backdropSizes: [ - "w300", - "w780", - "w1280", - "original", - ], - logoSizes: [ - "w45", - "w92", - "w154", - "w185", - "w300", - "w500", - "original", - ], - posterSizes: [ - "w92", - "w154", - "w185", - "w342", - "w500", - "w780", - "original", - ], - profileSizes: [ - "w45", - "w185", - "h632", - "original", - ], - stillSizes: [ - "w92", - "w185", - "w300", - "original", - ] - ) - } diff --git a/Tests/TMDbTests/Domain/Models/MediaPageableListTests.swift b/Tests/TMDbTests/Domain/Models/MediaPageableListTests.swift index ae451a90..0cb4f8d9 100644 --- a/Tests/TMDbTests/Domain/Models/MediaPageableListTests.swift +++ b/Tests/TMDbTests/Domain/Models/MediaPageableListTests.swift @@ -41,7 +41,7 @@ struct MediaPageableListTests { results: [ .movie(.theFirstOmen), .tvSeries(.bigBrother), - .person(Person(id: 51329, name: "Bradley Cooper", gender: .unknown)), + .person(Person(id: 51329, name: "Bradley Cooper", gender: .unknown)) ], totalResults: 3, totalPages: 1 diff --git a/Tests/TMDbTests/Domain/Models/MediaTests.swift b/Tests/TMDbTests/Domain/Models/MediaTests.swift index 1a5e78f2..f8aa576e 100644 --- a/Tests/TMDbTests/Domain/Models/MediaTests.swift +++ b/Tests/TMDbTests/Domain/Models/MediaTests.swift @@ -50,7 +50,7 @@ struct MediaTests { private let media: [Media] = [ .movie(.theFirstOmen), .tvSeries(.bigBrother), - .person(Person(id: 51329, name: "Bradley Cooper", gender: .unknown)), + .person(Person(id: 51329, name: "Bradley Cooper", gender: .unknown)) ] } diff --git a/Tests/TMDbTests/Domain/Models/MovieListItemTests.swift b/Tests/TMDbTests/Domain/Models/MovieListItemTests.swift index ddddbb4b..b22d06d6 100644 --- a/Tests/TMDbTests/Domain/Models/MovieListItemTests.swift +++ b/Tests/TMDbTests/Domain/Models/MovieListItemTests.swift @@ -37,7 +37,6 @@ struct MovieListItemTests { extension MovieListItemTests { - // swiftlint:disable line_length private var movie: MovieListItem { .init( id: 437_342, @@ -57,6 +56,5 @@ extension MovieListItemTests { isAdultOnly: false ) } - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/MoviePageableListTests.swift b/Tests/TMDbTests/Domain/Models/MoviePageableListTests.swift index a0418f76..be0b49bd 100644 --- a/Tests/TMDbTests/Domain/Models/MoviePageableListTests.swift +++ b/Tests/TMDbTests/Domain/Models/MoviePageableListTests.swift @@ -62,7 +62,7 @@ struct MoviePageableListTests { originalLanguage: "en", overview: "Overview 3", genreIDs: [7, 8, 9] - ), + ) ], totalResults: 3, totalPages: 1 diff --git a/Tests/TMDbTests/Domain/Models/MovieTests.swift b/Tests/TMDbTests/Domain/Models/MovieTests.swift index 28d9c063..a98b16c9 100644 --- a/Tests/TMDbTests/Domain/Models/MovieTests.swift +++ b/Tests/TMDbTests/Domain/Models/MovieTests.swift @@ -47,9 +47,8 @@ struct MovieTests { extension MovieTests { - // swiftlint:disable line_length private var movie: Movie { - .init( + Movie( id: 550, title: "Fight Club", tagline: "How much can you know about yourself if you've never been in a fight?", @@ -96,6 +95,5 @@ extension MovieTests { isAdultOnly: false ) } - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/PageableListResultTests.swift b/Tests/TMDbTests/Domain/Models/PageableListResultTests.swift index 6857a399..4d8cc94e 100644 --- a/Tests/TMDbTests/Domain/Models/PageableListResultTests.swift +++ b/Tests/TMDbTests/Domain/Models/PageableListResultTests.swift @@ -42,7 +42,7 @@ struct PageableListResultTests { SomeListItem(id: 1), SomeListItem(id: 2), SomeListItem(id: 3), - SomeListItem(id: 4), + SomeListItem(id: 4) ], totalResults: 4, totalPages: 1 diff --git a/Tests/TMDbTests/Domain/Models/PersonCombinedCreditsTests.swift b/Tests/TMDbTests/Domain/Models/PersonCombinedCreditsTests.swift index 9bdf471f..901e3a74 100644 --- a/Tests/TMDbTests/Domain/Models/PersonCombinedCreditsTests.swift +++ b/Tests/TMDbTests/Domain/Models/PersonCombinedCreditsTests.swift @@ -35,7 +35,6 @@ struct PersonCombinedCreditsTests { #expect(result.crew == personCombinedCredits.crew) } - // swiftlint:disable line_length private let personCombinedCredits = PersonCombinedCredits( id: 287, cast: [ @@ -73,7 +72,7 @@ struct PersonCombinedCreditsTests { voteCount: 661, hasVideo: false, isAdultOnly: false - )), + )) ], crew: [ .tvSeries( @@ -110,9 +109,8 @@ struct PersonCombinedCreditsTests { voteCount: 7, hasVideo: false, isAdultOnly: false - )), + )) ] ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/PersonImageCollectionTests.swift b/Tests/TMDbTests/Domain/Models/PersonImageCollectionTests.swift index 262437f2..5905fc42 100644 --- a/Tests/TMDbTests/Domain/Models/PersonImageCollectionTests.swift +++ b/Tests/TMDbTests/Domain/Models/PersonImageCollectionTests.swift @@ -27,6 +27,28 @@ struct PersonImageCollectionTests { @Test("JSON decoding of PersonImageCollection", .tags(.decoding)) func decodeReturnsPersonImageCollection() throws { + let personImageCollection = try PersonImageCollection( + id: 66633, + profiles: [ + ImageMetadata( + filePath: #require(URL(string: "/rLSUjr725ez1cK7SKVxC9udO03Y.jpg")), + width: 546, + height: 819, + aspectRatio: 0.666666666666667, + voteAverage: 7.21, + voteCount: 345 + ), + ImageMetadata( + filePath: #require(URL(string: "/lYqC8Amj4owX05xQg5Yo7uUHgah.jpg")), + width: 2000, + height: 3000, + aspectRatio: 0.666666666666667, + voteAverage: 4.21, + voteCount: 3 + ) + ] + ) + let result = try JSONDecoder.theMovieDatabase .decode(PersonImageCollection.self, fromResource: "person-image-collection") @@ -34,26 +56,4 @@ struct PersonImageCollectionTests { #expect(result.profiles == personImageCollection.profiles) } - private let personImageCollection = PersonImageCollection( - id: 66633, - profiles: [ - ImageMetadata( - filePath: URL(string: "/rLSUjr725ez1cK7SKVxC9udO03Y.jpg")!, - width: 546, - height: 819, - aspectRatio: 0.666666666666667, - voteAverage: 7.21, - voteCount: 345 - ), - ImageMetadata( - filePath: URL(string: "/lYqC8Amj4owX05xQg5Yo7uUHgah.jpg")!, - width: 2000, - height: 3000, - aspectRatio: 0.666666666666667, - voteAverage: 4.21, - voteCount: 3 - ), - ] - ) - } diff --git a/Tests/TMDbTests/Domain/Models/PersonMovieCreditsTests.swift b/Tests/TMDbTests/Domain/Models/PersonMovieCreditsTests.swift index 57515deb..7f4a5d8e 100644 --- a/Tests/TMDbTests/Domain/Models/PersonMovieCreditsTests.swift +++ b/Tests/TMDbTests/Domain/Models/PersonMovieCreditsTests.swift @@ -48,7 +48,6 @@ struct PersonMovieCreditsTests { #expect(result == expectedResult) } - // swiftlint:disable line_length private let personMovieCredits = PersonMovieCredits( id: 287, cast: [ @@ -88,6 +87,5 @@ struct PersonMovieCreditsTests { ) ] ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/PersonPageableListTests.swift b/Tests/TMDbTests/Domain/Models/PersonPageableListTests.swift index 2c5024c6..4fcee7b1 100644 --- a/Tests/TMDbTests/Domain/Models/PersonPageableListTests.swift +++ b/Tests/TMDbTests/Domain/Models/PersonPageableListTests.swift @@ -36,7 +36,6 @@ struct PersonPageableListTests { #expect(result.totalPages == list.totalPages) } - // swiftlint:disable line_length private let list = PersonPageableList( page: 1, results: [ @@ -86,7 +85,7 @@ struct PersonPageableListTests { hasVideo: false, isAdultOnly: false ) - ), + ) ], isAdultOnly: false ) @@ -94,6 +93,5 @@ struct PersonPageableListTests { totalResults: 1, totalPages: 1 ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/PersonTVSeriesCreditsTests.swift b/Tests/TMDbTests/Domain/Models/PersonTVSeriesCreditsTests.swift index 66282776..f4ce4546 100644 --- a/Tests/TMDbTests/Domain/Models/PersonTVSeriesCreditsTests.swift +++ b/Tests/TMDbTests/Domain/Models/PersonTVSeriesCreditsTests.swift @@ -49,7 +49,6 @@ struct PersonTVSeriesCreditsTests { #expect(result == expectedResult) } - // swiftlint:disable line_length private let personTVSeriesCredits = PersonTVSeriesCredits( id: 287, cast: [ @@ -87,6 +86,5 @@ struct PersonTVSeriesCreditsTests { ) ] ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/PersonTests.swift b/Tests/TMDbTests/Domain/Models/PersonTests.swift index b2eeb663..4b9eb966 100644 --- a/Tests/TMDbTests/Domain/Models/PersonTests.swift +++ b/Tests/TMDbTests/Domain/Models/PersonTests.swift @@ -56,7 +56,6 @@ struct PersonTests { extension PersonTests { - // swiftlint:disable line_length private var person: Person { .init( id: 287, @@ -65,7 +64,7 @@ extension PersonTests { "Бред Питт", "Бред Пітт", "Buratto Pitto", - "Брэд Питт", + "Брэд Питт" ], knownForDepartment: "Acting", biography: @@ -80,6 +79,5 @@ extension PersonTests { homepageURL: nil ) } - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/ReviewPageableListTests.swift b/Tests/TMDbTests/Domain/Models/ReviewPageableListTests.swift index f9b6d7b0..ea93c791 100644 --- a/Tests/TMDbTests/Domain/Models/ReviewPageableListTests.swift +++ b/Tests/TMDbTests/Domain/Models/ReviewPageableListTests.swift @@ -36,7 +36,6 @@ struct ReviewPageableListTests { #expect(result.totalPages == list.totalPages) } - // swiftlint:disable line_length private let list = ReviewPageableList( page: 1, results: [ @@ -50,6 +49,5 @@ struct ReviewPageableListTests { totalResults: 1, totalPages: 1 ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/ReviewTests.swift b/Tests/TMDbTests/Domain/Models/ReviewTests.swift index d636eb9e..5e4de111 100644 --- a/Tests/TMDbTests/Domain/Models/ReviewTests.swift +++ b/Tests/TMDbTests/Domain/Models/ReviewTests.swift @@ -34,13 +34,11 @@ struct ReviewTests { #expect(result.content == review.content) } - // swiftlint:disable line_length private let review = Review( id: "5488c29bc3a3686f4a00004a", author: "Travis Bell", content: "Like most of the reviews here, I agree that Guardians of the Galaxy was an absolute hoot. Guardians never takes itself too seriously which makes this movie a whole lot of fun. The cast was perfectly chosen and even though two of the main five were CG, knowing who voiced and acted alongside them completely filled out these characters. Guardians of the Galaxy is one of those rare complete audience pleasers. Good fun for everyone!" ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/ShowCreditsTests.swift b/Tests/TMDbTests/Domain/Models/ShowCreditsTests.swift index 85a99e61..0f7c62e3 100644 --- a/Tests/TMDbTests/Domain/Models/ShowCreditsTests.swift +++ b/Tests/TMDbTests/Domain/Models/ShowCreditsTests.swift @@ -67,7 +67,7 @@ struct ShowCreditsTests { gender: .male, profilePath: URL(string: "/43nyfW3TxD3PxDqYB8tyqaKpDBH.jpg"), order: 2 - ), + ) ], crew: [ CrewMember( @@ -87,7 +87,7 @@ struct ShowCreditsTests { department: "Production", gender: .unknown, profilePath: nil - ), + ) ] ) diff --git a/Tests/TMDbTests/Domain/Models/ShowTests.swift b/Tests/TMDbTests/Domain/Models/ShowTests.swift index 7590d3b1..25d4a9af 100644 --- a/Tests/TMDbTests/Domain/Models/ShowTests.swift +++ b/Tests/TMDbTests/Domain/Models/ShowTests.swift @@ -78,7 +78,6 @@ struct ShowTests { extension ShowTests { - // swiftlint:disable line_length private var movieShow: Show { .movie( .init( @@ -121,6 +120,5 @@ extension ShowTests { ) ) } - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/TVEpisodeImageCollectionTests.swift b/Tests/TMDbTests/Domain/Models/TVEpisodeImageCollectionTests.swift index 8cfa7ac7..2fdf2d42 100644 --- a/Tests/TMDbTests/Domain/Models/TVEpisodeImageCollectionTests.swift +++ b/Tests/TMDbTests/Domain/Models/TVEpisodeImageCollectionTests.swift @@ -27,6 +27,21 @@ struct TVEpisodeImageCollectionTests { @Test("JSON decoding of TVEpisodeImageCollection", .tags(.decoding)) func decodeReturnsImageCollection() throws { + let episodeImageCollection = try TVEpisodeImageCollection( + id: 66633, + stills: [ + ImageMetadata( + filePath: #require(URL(string: "/rLSUjr725ez1cK7SKVxC9udO03Y.jpg")), + width: 1920, + height: 1080, + aspectRatio: 1.77778, + voteAverage: 5.3125, + voteCount: 1, + languageCode: nil + ) + ] + ) + let result = try JSONDecoder.theMovieDatabase.decode( TVEpisodeImageCollection.self, fromResource: "tv-episode-image-collection" @@ -36,19 +51,4 @@ struct TVEpisodeImageCollectionTests { #expect(result.stills == episodeImageCollection.stills) } - private let episodeImageCollection = TVEpisodeImageCollection( - id: 66633, - stills: [ - ImageMetadata( - filePath: URL(string: "/rLSUjr725ez1cK7SKVxC9udO03Y.jpg")!, - width: 1920, - height: 1080, - aspectRatio: 1.77778, - voteAverage: 5.3125, - voteCount: 1, - languageCode: nil - ) - ] - ) - } diff --git a/Tests/TMDbTests/Domain/Models/TVEpisodeTests.swift b/Tests/TMDbTests/Domain/Models/TVEpisodeTests.swift index 8ffdd250..e8d52fb3 100644 --- a/Tests/TMDbTests/Domain/Models/TVEpisodeTests.swift +++ b/Tests/TMDbTests/Domain/Models/TVEpisodeTests.swift @@ -44,7 +44,6 @@ struct TVEpisodeTests { #expect(result.voteCount == tvEpisode.voteCount) } - // swiftlint:disable line_length private let tvEpisode = TVEpisode( id: 63056, name: "Winter Is Coming", @@ -78,6 +77,5 @@ struct TVEpisodeTests { voteAverage: 7.11904761904762, voteCount: 21 ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/TVSeasonTests.swift b/Tests/TMDbTests/Domain/Models/TVSeasonTests.swift index 2f46473b..e1c3e0ac 100644 --- a/Tests/TMDbTests/Domain/Models/TVSeasonTests.swift +++ b/Tests/TMDbTests/Domain/Models/TVSeasonTests.swift @@ -39,7 +39,6 @@ struct TVSeasonTests { #expect(result.episodes == tvSeason.episodes) } - // swiftlint:disable line_length private let tvSeason = TVSeason( id: 3624, name: "Season 1", @@ -50,6 +49,5 @@ struct TVSeasonTests { posterPath: URL(string: "/zwaj4egrhnXOBIit1tyb4Sbt3KP.jpg"), episodes: nil ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/TVSeriesListItemTests.swift b/Tests/TMDbTests/Domain/Models/TVSeriesListItemTests.swift index 2999b3ab..ef5a02e9 100644 --- a/Tests/TMDbTests/Domain/Models/TVSeriesListItemTests.swift +++ b/Tests/TMDbTests/Domain/Models/TVSeriesListItemTests.swift @@ -37,7 +37,6 @@ struct TVSeriesListItemTests { extension TVSeriesListItemTests { - // swiftlint:disable line_length private var tvSeries: TVSeriesListItem { TVSeriesListItem( id: 11366, @@ -57,6 +56,5 @@ extension TVSeriesListItemTests { isAdultOnly: false ) } - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/TVSeriesPageableListTests.swift b/Tests/TMDbTests/Domain/Models/TVSeriesPageableListTests.swift index a254485e..c6b79840 100644 --- a/Tests/TMDbTests/Domain/Models/TVSeriesPageableListTests.swift +++ b/Tests/TMDbTests/Domain/Models/TVSeriesPageableListTests.swift @@ -36,7 +36,6 @@ struct TVSeriesPageableListTests { #expect(result.totalPages == list.totalPages) } - // swiftlint:disable line_length private let list = TVSeriesPageableList( page: 1, results: [ @@ -73,11 +72,10 @@ struct TVSeriesPageableListTests { voteAverage: 7.619, voteCount: 1178, isAdultOnly: false - ), + ) ], totalResults: 2, totalPages: 1 ) - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/TVSeriesTests.swift b/Tests/TMDbTests/Domain/Models/TVSeriesTests.swift index c17de70b..db9028b6 100644 --- a/Tests/TMDbTests/Domain/Models/TVSeriesTests.swift +++ b/Tests/TMDbTests/Domain/Models/TVSeriesTests.swift @@ -48,7 +48,6 @@ struct TVSeriesTests { extension TVSeriesTests { - // swiftlint:disable line_length private var tvSeries: TVSeries { .init( id: 1399, @@ -75,7 +74,7 @@ extension TVSeriesTests { genres: [ Genre(id: 10765, name: "Sci-Fi & Fantasy"), Genre(id: 18, name: "Drama"), - Genre(id: 10759, name: "Action & Adventure"), + Genre(id: 10759, name: "Action & Adventure") ], firstAirDate: DateFormatter.theMovieDatabase.date(from: "2011-04-17"), originCountry: ["US"], @@ -109,6 +108,5 @@ extension TVSeriesTests { isAdultOnly: false ) } - // swiftlint:enable line_length } diff --git a/Tests/TMDbTests/Domain/Models/WatchProviderRegionsTests.swift b/Tests/TMDbTests/Domain/Models/WatchProviderRegionsTests.swift index 533bcec2..8370c2e4 100644 --- a/Tests/TMDbTests/Domain/Models/WatchProviderRegionsTests.swift +++ b/Tests/TMDbTests/Domain/Models/WatchProviderRegionsTests.swift @@ -40,7 +40,7 @@ struct WatchProviderRegionsTests { Country(countryCode: "AR", name: "Argentina", englishName: "Argentina"), Country(countryCode: "AT", name: "Austria", englishName: "Austria"), Country( - countryCode: "US", name: "United States", englishName: "United States of America"), + countryCode: "US", name: "United States", englishName: "United States of America") ] ) diff --git a/Tests/TMDbTests/Domain/Models/WatchProviderResultTests.swift b/Tests/TMDbTests/Domain/Models/WatchProviderResultTests.swift index abb512cb..bfcbed53 100644 --- a/Tests/TMDbTests/Domain/Models/WatchProviderResultTests.swift +++ b/Tests/TMDbTests/Domain/Models/WatchProviderResultTests.swift @@ -27,6 +27,21 @@ struct WatchProviderResultTests { @Test("JSON decoding of WatchProviderRegions", .tags(.decoding)) func decodeReturnsWatchProviderResult() throws { + let watchProviderResult = try WatchProviderResult( + results: [ + .init( + id: 8, + name: "Netflix", + logoPath: #require(URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")) + ), + .init( + id: 9, + name: "Amazon Prime Video", + logoPath: #require(URL(string: "/emthp39XA2YScoYL1p0sdbAH2WA.jpg")) + ) + ] + ) + let result = try JSONDecoder.theMovieDatabase.decode( WatchProviderResult.self, fromResource: "watch-provider-result" @@ -35,19 +50,4 @@ struct WatchProviderResultTests { #expect(result == watchProviderResult) } - private let watchProviderResult = WatchProviderResult( - results: [ - .init( - id: 8, - name: "Netflix", - logoPath: URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! - ), - .init( - id: 9, - name: "Amazon Prime Video", - logoPath: URL(string: "/emthp39XA2YScoYL1p0sdbAH2WA.jpg")! - ), - ] - ) - } diff --git a/Tests/TMDbTests/Domain/Models/WatchProviderTests.swift b/Tests/TMDbTests/Domain/Models/WatchProviderTests.swift index 43432c0d..70b19216 100644 --- a/Tests/TMDbTests/Domain/Models/WatchProviderTests.swift +++ b/Tests/TMDbTests/Domain/Models/WatchProviderTests.swift @@ -27,16 +27,16 @@ struct WatchProviderTests { @Test("JSON decoding of WatchProvider", .tags(.decoding)) func decodeReturnsWatchProvider() throws { + let watchProvider = try WatchProvider( + id: 8, + name: "Netflix", + logoPath: #require(URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")) + ) + let result = try JSONDecoder.theMovieDatabase.decode( WatchProvider.self, fromResource: "watch-provider") #expect(result == watchProvider) } - private let watchProvider = WatchProvider( - id: 8, - name: "Netflix", - logoPath: URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! - ) - } diff --git a/Tests/TMDbTests/Domain/Services/Authentication/AuthenticateURLMockBuilder.swift b/Tests/TMDbTests/Domain/Services/Authentication/AuthenticateURLMockBuilder.swift index 10e771df..faccb20c 100644 --- a/Tests/TMDbTests/Domain/Services/Authentication/AuthenticateURLMockBuilder.swift +++ b/Tests/TMDbTests/Domain/Services/Authentication/AuthenticateURLMockBuilder.swift @@ -23,11 +23,19 @@ import Foundation final class AuthenticateURLMockBuilder: AuthenticateURLBuilding, @unchecked Sendable { - var authenticateURLResult: URL = .init(string: "https://some.domain.com/authenticate")! + var authenticateURLResult: URL private(set) var lastRequestToken: String? private(set) var lastRedirectURL: URL? - init() {} + init() { + self.authenticateURLResult = { + guard let url = URL(string: "https://some.domain.com/authenticate") else { + fatalError() + } + + return url + }() + } func authenticateURL(with requestToken: String) -> URL { authenticateURL(with: requestToken, redirectURL: nil) diff --git a/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverMoviesRequestTests.swift b/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverMoviesRequestTests.swift index f2f10a9b..043bff70 100644 --- a/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverMoviesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverMoviesRequestTests.swift @@ -81,7 +81,7 @@ struct DiscoverMoviesRequestTests { "sort_by": "original_title.asc", "with_people": "1,2,3", "page": "2", - "language": "en", + "language": "en" ]) } diff --git a/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverTVSeriesRequestTests.swift b/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverTVSeriesRequestTests.swift index 440900c8..169314f6 100644 --- a/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverTVSeriesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverTVSeriesRequestTests.swift @@ -72,7 +72,7 @@ struct DiscoverTVSeriesRequestTests { request.queryItems == [ "sort_by": "first_air_date.asc", "page": "2", - "language": "en", + "language": "en" ]) } diff --git a/Tests/TMDbTests/Domain/Services/Search/Requests/MovieSearchRequestTests.swift b/Tests/TMDbTests/Domain/Services/Search/Requests/MovieSearchRequestTests.swift index b9b3500f..b329c8da 100644 --- a/Tests/TMDbTests/Domain/Services/Search/Requests/MovieSearchRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/Search/Requests/MovieSearchRequestTests.swift @@ -90,7 +90,7 @@ struct MovieSearchRequestTests { "primary_release_year": "2024", "include_adult": "false", "page": "2", - "language": "en", + "language": "en" ]) } diff --git a/Tests/TMDbTests/Domain/Services/Search/Requests/MultiSearchRequestTests.swift b/Tests/TMDbTests/Domain/Services/Search/Requests/MultiSearchRequestTests.swift index b5820a09..9f763bee 100644 --- a/Tests/TMDbTests/Domain/Services/Search/Requests/MultiSearchRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/Search/Requests/MultiSearchRequestTests.swift @@ -74,7 +74,7 @@ struct MultiSearchRequestTests { "query": "fight club", "page": "2", "include_adult": "false", - "language": "en", + "language": "en" ]) } diff --git a/Tests/TMDbTests/Domain/Services/Search/Requests/PersonSearchRequestTests.swift b/Tests/TMDbTests/Domain/Services/Search/Requests/PersonSearchRequestTests.swift index 9d416982..8fbed85d 100644 --- a/Tests/TMDbTests/Domain/Services/Search/Requests/PersonSearchRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/Search/Requests/PersonSearchRequestTests.swift @@ -70,7 +70,7 @@ struct PersonSearchRequestTests { "query": "edward norton", "include_adult": "false", "page": "2", - "language": "en", + "language": "en" ]) } diff --git a/Tests/TMDbTests/Domain/Services/Search/Requests/TVSeriesSearchRequestTests.swift b/Tests/TMDbTests/Domain/Services/Search/Requests/TVSeriesSearchRequestTests.swift index 8816c79f..83cbe2d9 100644 --- a/Tests/TMDbTests/Domain/Services/Search/Requests/TVSeriesSearchRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/Search/Requests/TVSeriesSearchRequestTests.swift @@ -92,7 +92,7 @@ struct TVSeriesSearchRequestTests { "year": "2022", "include_adult": "false", "page": "3", - "language": "en", + "language": "en" ]) } diff --git a/Tests/TMDbTests/Extensions/JSONDecoder+TMDbTests.swift b/Tests/TMDbTests/Extensions/JSONDecoder+TMDbTests.swift index df884521..79d9e26b 100644 --- a/Tests/TMDbTests/Extensions/JSONDecoder+TMDbTests.swift +++ b/Tests/TMDbTests/Extensions/JSONDecoder+TMDbTests.swift @@ -25,18 +25,21 @@ import Testing @Suite struct JSONDecoderTMDbTests { - private static var dateFormatter: DateFormatter { - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "yyyy-MM-ddd" - return dateFormatter + var jsonDecoder: JSONDecoder! + var dateFormatter: DateFormatter! + + init() { + self.dateFormatter = DateFormatter() + self.dateFormatter.dateFormat = "yyyy-MM-ddd" + self.jsonDecoder = JSONDecoder.theMovieDatabase } @Test("decodes object from JSON") func theMovieDatabaseDecoderDecodesObject() throws { - let expectedResult = SomeThing( + let expectedResult = try SomeThing( id: "abc123", firstName: "Adam", - dateOfBirth: Self.dateFormatter.date(from: "1990-01-02")! + dateOfBirth: #require(dateFormatter.date(from: "1990-01-02")) ) let jsonString = """ @@ -48,7 +51,7 @@ struct JSONDecoderTMDbTests { """ let data = Data(jsonString.utf8) - let result = try JSONDecoder.theMovieDatabase.decode(SomeThing.self, from: data) + let result = try jsonDecoder.decode(SomeThing.self, from: data) #expect(result == expectedResult) } diff --git a/Tests/TMDbTests/Extensions/JSONEncoder+TMDbTests.swift b/Tests/TMDbTests/Extensions/JSONEncoder+TMDbTests.swift index 5433ef83..69d420cb 100644 --- a/Tests/TMDbTests/Extensions/JSONEncoder+TMDbTests.swift +++ b/Tests/TMDbTests/Extensions/JSONEncoder+TMDbTests.swift @@ -30,16 +30,16 @@ struct JSONEncoderTMDbTests { init() { self.dateFormatter = DateFormatter() - dateFormatter.dateFormat = "yyyy-MM-ddd" + self.dateFormatter.dateFormat = "yyyy-MM-ddd" self.jsonEncoder = JSONEncoder.theMovieDatabase } @Test("encoder encodes object") func theMovieDatabaseEncoderEncodesObject() throws { - let value = SomeThing( + let value = try SomeThing( id: "abc123", firstName: "Adam", - dateOfBirth: dateFormatter.date(from: "1990-01-02")! + dateOfBirth: #require(dateFormatter.date(from: "1990-01-02")) ) let expectedIDResult = "\"id\":\"abc123\"" diff --git a/Tests/TMDbTests/Extensions/Sequence+UniquedTests.swift b/Tests/TMDbTests/Extensions/Sequence+UniquedTests.swift index c02c574d..1c784fe2 100644 --- a/Tests/TMDbTests/Extensions/Sequence+UniquedTests.swift +++ b/Tests/TMDbTests/Extensions/Sequence+UniquedTests.swift @@ -28,7 +28,7 @@ struct SequenceUniquedTests { @Test("uniqued with all distinct IDs returns original") func uniquedWithAllDistinctIDsReturnsOriginal() { let items: [Item] = [ - .init(), .init(), .init(), .init(), .init(), .init(), + .init(), .init(), .init(), .init(), .init(), .init() ] let result = items.uniqued() diff --git a/Tests/TMDbTests/Mocks/Models/APIConfiguration+Mocks.swift b/Tests/TMDbTests/Mocks/Models/APIConfiguration+Mocks.swift index 4f939286..1fe4aae3 100644 --- a/Tests/TMDbTests/Mocks/Models/APIConfiguration+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/APIConfiguration+Mocks.swift @@ -25,8 +25,8 @@ extension APIConfiguration { static func mock( images: ImagesConfiguration = .mock(), changeKeys: [String] = ["air_date", "also_known_as"] - ) -> Self { - .init( + ) -> APIConfiguration { + APIConfiguration( images: images, changeKeys: changeKeys ) diff --git a/Tests/TMDbTests/Mocks/Models/CastMember+Mocks.swift b/Tests/TMDbTests/Mocks/Models/CastMember+Mocks.swift index bf4df3ab..9d27eed8 100644 --- a/Tests/TMDbTests/Mocks/Models/CastMember+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/CastMember+Mocks.swift @@ -29,10 +29,10 @@ extension CastMember { name: String = "Actor Name", character: String = "Character Name", gender: Gender? = .male, - profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), order: Int = 1 - ) -> Self { - .init( + ) -> CastMember { + CastMember( id: id, castID: castID, creditID: creditID, @@ -44,28 +44,28 @@ extension CastMember { ) } - static var chrisHemsworth: Self { - .mock( + static var chrisHemsworth: CastMember { + CastMember.mock( id: 74568, castID: 85, creditID: "62c8c25290b87e00f53973fb", name: "Chris Hemsworth", character: "Thor Odinson", gender: Gender.male, - profilePath: URL(string: "/jpurJ9jAcLCYjgHHfYF32m3zJYm.jpg")!, + profilePath: URL(string: "/jpurJ9jAcLCYjgHHfYF32m3zJYm.jpg"), order: 0 ) } - static var christianBale: Self { - .mock( + static var christianBale: CastMember { + CastMember.mock( id: 3894, castID: 87, creditID: "62c8c27f3d4d96004c9f1996", name: "Christian Bale", character: "Gorr", gender: Gender.male, - profilePath: URL(string: "/qCpZn2e3dimwbryLnqxZuI88PTi.jpg")!, + profilePath: URL(string: "/qCpZn2e3dimwbryLnqxZuI88PTi.jpg"), order: 1 ) } @@ -77,7 +77,7 @@ extension [CastMember] { static var mocks: [Element] { [ .chrisHemsworth, - .christianBale, + .christianBale ] } diff --git a/Tests/TMDbTests/Mocks/Models/Certification+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Certification+Mocks.swift index 3a712ac1..b3c38d3e 100644 --- a/Tests/TMDbTests/Mocks/Models/Certification+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Certification+Mocks.swift @@ -26,24 +26,24 @@ extension Certification { code: String = "U", meaning: String = "All ages admitted, there is nothing unsuitable for children.", order: Int = 1 - ) -> Self { - .init( + ) -> Certification { + Certification( code: code, meaning: meaning, order: order ) } - static var gbU: Self { - .mock( + static var gbU: Certification { + Certification.mock( code: "U", meaning: "All ages admitted, there is nothing unsuitable for children.", order: 1 ) } - static var gbPG: Self { - .mock( + static var gbPG: Certification { + Certification.mock( code: "PG", meaning: """ All ages admitted, but certain scenes may be unsuitable for young children. May contain mild \ @@ -54,8 +54,8 @@ extension Certification { ) } - static var gb12A: Self { - .mock( + static var gb12A: Certification { + Certification.mock( code: "12A", meaning: """ Films under this category are considered to be unsuitable for very young people. Those aged \ @@ -70,8 +70,8 @@ extension Certification { ) } - static var usG: Self { - .mock( + static var usG: Certification { + Certification.mock( code: "G", meaning: """ All ages admitted. There is no content that would be objectionable to most parents. This is one \ @@ -81,8 +81,8 @@ extension Certification { ) } - static var usPG13: Self { - .mock( + static var usPG13: Certification { + Certification.mock( code: "PG-13", meaning: """ Some material may be inappropriate for children under 13. Films given this rating may contain \ diff --git a/Tests/TMDbTests/Mocks/Models/Certifications+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Certifications+Mocks.swift index 02e0ab4b..9bf72860 100644 --- a/Tests/TMDbTests/Mocks/Models/Certifications+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Certifications+Mocks.swift @@ -25,17 +25,17 @@ extension Certifications { static func mock( certifications: [String: [Certification]] = ["GB": [.gbU, .gbPG]] - ) -> Self { - .init( + ) -> Certifications { + Certifications( certifications: certifications ) } - static var gbAndUS: Self { - .mock( + static var gbAndUS: Certifications { + Certifications.mock( certifications: [ "GB": [.gbU, .gbPG, .gb12A], - "US": [.usG, .usPG13], + "US": [.usG, .usPG13] ] ) } diff --git a/Tests/TMDbTests/Mocks/Models/Company+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Company+Mocks.swift index 95db1be9..ecaec2eb 100644 --- a/Tests/TMDbTests/Mocks/Models/Company+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Company+Mocks.swift @@ -22,17 +22,18 @@ import TMDb extension Company { + // swift-format-ignore: NeverForceUnwrap static func mock( id: Int = 1, name: String = "Lucasfilm Ltd.", description: String = "Some description", headquarters: String = "San Francisco, California", - homepageURL: URL = URL(string: "https://www.lucasfilm.com")!, + homepageURL: URL? = URL(string: "https://www.lucasfilm.com"), logoPath: URL = URL(string: "/o86DbpburjxrqAzEDhXZcyE8pDb.png")!, originCountry: String = "US", parentCompany: Company.Parent? = nil - ) -> Self { - .init( + ) -> Company { + Company( id: id, name: name, description: description, @@ -44,13 +45,14 @@ extension Company { ) } - static var lucasfilm: Self { - .mock( + // swift-format-ignore: NeverForceUnwrap + static var lucasfilm: Company { + Company.mock( id: 1, name: "Lucasfilm Ltd.", description: "Some description", headquarters: "San Francisco, California", - homepageURL: URL(string: "https://www.lucasfilm.com")!, + homepageURL: URL(string: "https://www.lucasfilm.com"), logoPath: URL(string: "/o86DbpburjxrqAzEDhXZcyE8pDb.png")!, originCountry: "US" ) diff --git a/Tests/TMDbTests/Mocks/Models/ContentRating+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ContentRating+Mocks.swift index d8c7e062..e34b27d1 100644 --- a/Tests/TMDbTests/Mocks/Models/ContentRating+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ContentRating+Mocks.swift @@ -21,24 +21,33 @@ import Foundation import TMDb extension ContentRating { + static func mock( descriptors: [String], countryCode: String, rating: String - ) -> Self { - .init( + ) -> ContentRating { + ContentRating( descriptors: descriptors, countryCode: countryCode, rating: rating ) } - static var parksAndRecreationGB: Self { - .mock(descriptors: [], countryCode: "GB", rating: "15") + static var parksAndRecreationGB: ContentRating { + ContentRating.mock( + descriptors: [], + countryCode: "GB", + rating: "15" + ) } - static var parksAndRecreationUS: Self { - .mock(descriptors: [], countryCode: "GB", rating: "TV-14") + static var parksAndRecreationUS: ContentRating { + ContentRating.mock( + descriptors: [], + countryCode: "GB", + rating: "TV-14" + ) } } @@ -47,7 +56,7 @@ extension [ContentRating] { static var mocks: [Element] { [ .parksAndRecreationGB, - .parksAndRecreationUS, + .parksAndRecreationUS ] } diff --git a/Tests/TMDbTests/Mocks/Models/Country+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Country+Mocks.swift index f366c65e..2e69258c 100644 --- a/Tests/TMDbTests/Mocks/Models/Country+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Country+Mocks.swift @@ -26,20 +26,28 @@ extension Country { countryCode: String = "US", name: String = "United States", englishName: String = "United States of America" - ) -> Self { - .init( + ) -> Country { + Country( countryCode: countryCode, name: name, englishName: englishName ) } - static var unitedKingdom: Self { - .mock(countryCode: "GB", name: "United Kingdom", englishName: "United Kingdom") + static var unitedKingdom: Country { + Country.mock( + countryCode: "GB", + name: "United Kingdom", + englishName: "United Kingdom" + ) } - static var unitedStates: Self { - .mock(countryCode: "US", name: "United States", englishName: "United States of America") + static var unitedStates: Country { + Country.mock( + countryCode: "US", + name: "United States", + englishName: "United States of America" + ) } } diff --git a/Tests/TMDbTests/Mocks/Models/CrewMember+Mocks.swift b/Tests/TMDbTests/Mocks/Models/CrewMember+Mocks.swift index 8aa69949..ab68f83c 100644 --- a/Tests/TMDbTests/Mocks/Models/CrewMember+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/CrewMember+Mocks.swift @@ -29,9 +29,9 @@ extension CrewMember { job: String = "Job Name", department: String = "Department Name", gender: Gender? = Gender.male, - profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! - ) -> Self { - .init( + profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg") + ) -> CrewMember { + CrewMember( id: id, creditID: creditID, name: name, diff --git a/Tests/TMDbTests/Mocks/Models/Department+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Department+Mocks.swift index 26fd63b3..6ace9dc6 100644 --- a/Tests/TMDbTests/Mocks/Models/Department+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Department+Mocks.swift @@ -25,30 +25,30 @@ extension Department { static func mock( name: String = "Costume & Make-Up", jobs: [String] = ["Set Costumer", "Co-Costume Designer"] - ) -> Self { - .init( + ) -> Department { + Department( name: name, jobs: jobs ) } - static var costumeAndMakeUp: Self { - .mock( + static var costumeAndMakeUp: Department { + Department.mock( name: "Costume & Make-Up", jobs: [ "Set Costumer", - "Co-Costume Designer", + "Co-Costume Designer" ] ) } - static var production: Self { - .mock( + static var production: Department { + Department.mock( name: "Production", jobs: [ "Casting", "ADR Voice Casting", - "Production Accountant", + "Production Accountant" ] ) } diff --git a/Tests/TMDbTests/Mocks/Models/Genre+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Genre+Mocks.swift index b95ea4fb..d6e3de77 100644 --- a/Tests/TMDbTests/Mocks/Models/Genre+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Genre+Mocks.swift @@ -26,23 +26,23 @@ extension Genre { static func mock( id: Int = 1, name: String = "Action" - ) -> Self { - .init( + ) -> Genre { + Genre( id: id, name: name ) } - static var action: Self { - .mock(id: 1, name: "Action") + static var action: Genre { + Genre.mock(id: 1, name: "Action") } - static var drama: Self { - .mock(id: 1, name: "Drama") + static var drama: Genre { + Genre.mock(id: 1, name: "Drama") } - static var sciFi: Self { - .mock(id: 3, name: "Sci-Fi") + static var sciFi: Genre { + Genre.mock(id: 3, name: "Sci-Fi") } } diff --git a/Tests/TMDbTests/Mocks/Models/GenreList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/GenreList+Mocks.swift index c9815886..328f82c5 100644 --- a/Tests/TMDbTests/Mocks/Models/GenreList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/GenreList+Mocks.swift @@ -23,12 +23,8 @@ import Foundation extension GenreList { - static func mock( - genres: [Genre] = .mocks - ) -> Self { - .init( - genres: genres - ) + static func mock(genres: [Genre] = .mocks) -> GenreList { + GenreList(genres: genres) } } diff --git a/Tests/TMDbTests/Mocks/Models/ImageCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ImageCollection+Mocks.swift index 616df5bf..127a9523 100644 --- a/Tests/TMDbTests/Mocks/Models/ImageCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ImageCollection+Mocks.swift @@ -27,8 +27,8 @@ extension ImageCollection { posters: [ImageMetadata] = .mocks, logos: [ImageMetadata] = .mocks, backdrops: [ImageMetadata] = .mocks - ) -> Self { - .init( + ) -> ImageCollection { + ImageCollection( id: id, posters: posters, logos: logos, diff --git a/Tests/TMDbTests/Mocks/Models/ImageMetadata+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ImageMetadata+Mocks.swift index bf235b87..fbab5e08 100644 --- a/Tests/TMDbTests/Mocks/Models/ImageMetadata+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ImageMetadata+Mocks.swift @@ -22,6 +22,7 @@ import TMDb extension ImageMetadata { + // swift-format-ignore: NeverForceUnwrap static func mock( filePath: URL = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, width: Int = 100, @@ -30,8 +31,8 @@ extension ImageMetadata { voteAverage: Float = 5, voteCount: Int = 100, languageCode: String = "en" - ) -> Self { - .init( + ) -> ImageMetadata { + ImageMetadata( filePath: filePath, width: width, height: height, diff --git a/Tests/TMDbTests/Mocks/Models/ImagesConfiguration+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ImagesConfiguration+Mocks.swift index ac5e21f4..62a6a5ae 100644 --- a/Tests/TMDbTests/Mocks/Models/ImagesConfiguration+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ImagesConfiguration+Mocks.swift @@ -22,6 +22,7 @@ import TMDb extension ImagesConfiguration { + // swift-format-ignore: NeverForceUnwrap static func mock( baseURL: URL = URL(string: "http://api.domain.com/v1/")!, secureBaseURL: URL = URL(string: "https://api.domain.com/v1/")!, @@ -30,8 +31,8 @@ extension ImagesConfiguration { posterSizes: [String] = ["w92"], profileSizes: [String] = ["w45"], stillSizes: [String] = ["w92"] - ) -> Self { - .init( + ) -> ImagesConfiguration { + ImagesConfiguration( baseURL: baseURL, secureBaseURL: secureBaseURL, backdropSizes: backdropSizes, diff --git a/Tests/TMDbTests/Mocks/Models/Language+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Language+Mocks.swift index 6415880d..a0980e2f 100644 --- a/Tests/TMDbTests/Mocks/Models/Language+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Language+Mocks.swift @@ -26,28 +26,28 @@ extension Language { code: String = "en", name: String = "English", englishName: String = "English" - ) -> Self { - .init( + ) -> Language { + Language( code: code, name: name, englishName: englishName ) } - static var african: Self { - .mock(code: "af", name: "Afrikaans", englishName: "Afrikaans") + static var african: Language { + Language.mock(code: "af", name: "Afrikaans", englishName: "Afrikaans") } - static var hungarian: Self { - .mock(code: "hu", name: "Magyar", englishName: "Hungarian") + static var hungarian: Language { + Language.mock(code: "hu", name: "Magyar", englishName: "Hungarian") } - static var irish: Self { - .mock(code: "ga", name: "Gaeilge", englishName: "Irish") + static var irish: Language { + Language.mock(code: "ga", name: "Gaeilge", englishName: "Irish") } - static var english: Self { - .mock(code: "en", name: "English", englishName: "English") + static var english: Language { + Language.mock(code: "en", name: "English", englishName: "English") } } diff --git a/Tests/TMDbTests/Mocks/Models/Media+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Media+Mocks.swift index bc4b6867..749fa958 100644 --- a/Tests/TMDbTests/Mocks/Models/Media+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Media+Mocks.swift @@ -22,8 +22,8 @@ import TMDb extension Media { - static func mock() -> Self { - .movie(.topGunMaverick) + static func mock() -> Media { + Media.movie(.topGunMaverick) } } @@ -36,7 +36,7 @@ extension [Media] { .movie(.topGunMaverick), .tvSeries(.bigBrother), .tvSeries(.csi), - .movie(.jurassicWorldDominion), + .movie(.jurassicWorldDominion) ] } diff --git a/Tests/TMDbTests/Mocks/Models/MediaPageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/MediaPageableList+Mocks.swift index 6151ca82..2ea02af0 100644 --- a/Tests/TMDbTests/Mocks/Models/MediaPageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/MediaPageableList+Mocks.swift @@ -27,8 +27,8 @@ extension MediaPageableList { results: [Media] = .mocks, totalResults: Int? = 10, totalPages: Int? = 2 - ) -> Self { - .init( + ) -> MediaPageableList { + MediaPageableList( page: page, results: results, totalResults: totalResults, diff --git a/Tests/TMDbTests/Mocks/Models/Movie+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Movie+Mocks.swift index 1a6b7771..230dbd68 100644 --- a/Tests/TMDbTests/Mocks/Models/Movie+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Movie+Mocks.swift @@ -33,11 +33,11 @@ extension Movie { runtime: Int? = 120, genres: [Genre]? = [.action, .drama], releaseDate: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), - posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, - backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), + backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), budget: Double? = 1_000_000, revenue: Double? = 5_000_000, - homepageURL: URL? = URL(string: "https://www.movie.com")!, + homepageURL: URL? = URL(string: "https://www.movie.com"), imdbID: String? = "12345", status: Status? = .released, productionCompanies: [ProductionCompany]? = .mocks, @@ -48,8 +48,8 @@ extension Movie { voteCount: Int? = 120, hasVideo: Bool? = false, isAdultOnly: Bool? = false - ) -> Self { - .init( + ) -> Movie { + Movie( id: id, title: title, tagline: tagline, @@ -77,8 +77,8 @@ extension Movie { ) } - static var bulletTrain: Self { - .mock( + static var bulletTrain: Movie { + Movie.mock( id: 718_930, title: "Bullet Train", overview: """ @@ -91,8 +91,8 @@ extension Movie { ) } - static var thorLoveAndThunder: Self { - .mock( + static var thorLoveAndThunder: Movie { + Movie.mock( id: 616_037, title: "Thor: Love and Thunder", overview: """ @@ -106,8 +106,8 @@ extension Movie { ) } - static var jurassicWorldDominion: Self { - .mock( + static var jurassicWorldDominion: Movie { + Movie.mock( id: 507_086, title: "Jurassic World Dominion", overview: """ @@ -120,8 +120,8 @@ extension Movie { ) } - static var topGunMaverick: Self { - .mock( + static var topGunMaverick: Movie { + Movie.mock( id: 361_743, title: "Top Gun: Maverick", overview: """ @@ -137,12 +137,12 @@ extension Movie { extension [Movie] { - static var mocks: [Element] { + static var mocks: [Movie] { [ .bulletTrain, .thorLoveAndThunder, .jurassicWorldDominion, - .topGunMaverick, + .topGunMaverick ] } diff --git a/Tests/TMDbTests/Mocks/Models/MovieListItem+Mocks.swift b/Tests/TMDbTests/Mocks/Models/MovieListItem+Mocks.swift index 93b427b3..a58d4e95 100644 --- a/Tests/TMDbTests/Mocks/Models/MovieListItem+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/MovieListItem+Mocks.swift @@ -31,15 +31,15 @@ extension MovieListItem { overview: String = "Movie Overview", genreIDs: [Genre.ID] = [Genre].mocks.map(\.id), releaseDate: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), - posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, - backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), + backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), popularity: Double? = 5.6, voteAverage: Double? = 7.3, voteCount: Int? = 321, hasVideo: Bool? = false, isAdultOnly: Bool? = false - ) -> Self { - .init( + ) -> MovieListItem { + MovieListItem( id: id, title: title, originalTitle: originalTitle, @@ -57,8 +57,8 @@ extension MovieListItem { ) } - static var bulletTrain: Self { - .mock( + static var bulletTrain: MovieListItem { + MovieListItem.mock( id: 718_930, title: "Bullet Train", overview: """ @@ -71,8 +71,8 @@ extension MovieListItem { ) } - static var thorLoveAndThunder: Self { - .mock( + static var thorLoveAndThunder: MovieListItem { + MovieListItem.mock( id: 616_037, title: "Thor: Love and Thunder", overview: """ @@ -86,8 +86,8 @@ extension MovieListItem { ) } - static var jurassicWorldDominion: Self { - .mock( + static var jurassicWorldDominion: MovieListItem { + MovieListItem.mock( id: 507_086, title: "Jurassic World Dominion", overview: """ @@ -100,8 +100,8 @@ extension MovieListItem { ) } - static var topGunMaverick: Self { - .mock( + static var topGunMaverick: MovieListItem { + MovieListItem.mock( id: 361_743, title: "Top Gun: Maverick", overview: """ @@ -113,7 +113,6 @@ extension MovieListItem { ) } - // swiftlint:disable line_length static var theFirstOmen: MovieListItem { MovieListItem( id: 437_342, @@ -133,18 +132,17 @@ extension MovieListItem { isAdultOnly: false ) } - // swiftlint:enable line_length } extension [MovieListItem] { - static var mocks: [Element] { + static var mocks: [MovieListItem] { [ .bulletTrain, .thorLoveAndThunder, .jurassicWorldDominion, - .topGunMaverick, + .topGunMaverick ] } diff --git a/Tests/TMDbTests/Mocks/Models/MoviePageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/MoviePageableList+Mocks.swift index 290a7307..95a61d43 100644 --- a/Tests/TMDbTests/Mocks/Models/MoviePageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/MoviePageableList+Mocks.swift @@ -27,8 +27,8 @@ extension MoviePageableList { results: [MovieListItem] = .mocks, totalResults: Int = 10, totalPages: Int = 2 - ) -> Self { - .init( + ) -> MoviePageableList { + MoviePageableList( page: page, results: results, totalResults: totalResults, diff --git a/Tests/TMDbTests/Mocks/Models/Person+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Person+Mocks.swift index 14558f79..e913fc29 100644 --- a/Tests/TMDbTests/Mocks/Models/Person+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Person+Mocks.swift @@ -32,12 +32,12 @@ extension Person { deathday: Date? = nil, gender: Gender = .unknown, placeOfBirth: String? = nil, - profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), popularity: Double? = 6.8, imdbID: String? = nil, - homepageURL: URL? = URL(string: "https://www.person.com")! - ) -> Self { - .init( + homepageURL: URL? = URL(string: "https://www.person.com") + ) -> Person { + Person( id: id, name: name, alsoKnownAs: alsoKnownAs, @@ -54,20 +54,20 @@ extension Person { ) } - static var tomCruise: Self { - .mock(id: 500, name: "Tom Cruise") + static var tomCruise: Person { + Person.mock(id: 500, name: "Tom Cruise") } - static var bradPitt: Self { - .mock(id: 287, name: "Brad Pitt") + static var bradPitt: Person { + Person.mock(id: 287, name: "Brad Pitt") } - static var johnnyDepp: Self { - .mock(id: 85, name: "Johnny Depp") + static var johnnyDepp: Person { + Person.mock(id: 85, name: "Johnny Depp") } - static var quentinTarantino: Self { - .mock(id: 138, name: "Quentin Tarantino") + static var quentinTarantino: Person { + Person.mock(id: 138, name: "Quentin Tarantino") } } @@ -79,7 +79,7 @@ extension [Person] { .tomCruise, .bradPitt, .johnnyDepp, - .quentinTarantino, + .quentinTarantino ] } diff --git a/Tests/TMDbTests/Mocks/Models/PersonCombinedCredits+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonCombinedCredits+Mocks.swift index 31821389..ef22deb8 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonCombinedCredits+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonCombinedCredits+Mocks.swift @@ -28,15 +28,15 @@ extension PersonCombinedCredits { .movie(.jurassicWorldDominion), .tvSeries(.bigBrother), .movie(.topGunMaverick), - .tvSeries(.csi), + .tvSeries(.csi) ], crew: [Show] = [ .movie(.bulletTrain), .tvSeries(.bigBrother), - .movie(.thorLoveAndThunder), + .movie(.thorLoveAndThunder) ] - ) -> Self { - .init( + ) -> PersonCombinedCredits { + PersonCombinedCredits( id: id, cast: cast, crew: crew diff --git a/Tests/TMDbTests/Mocks/Models/PersonImageCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonImageCollection+Mocks.swift index ce05fb88..5ec728a9 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonImageCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonImageCollection+Mocks.swift @@ -25,8 +25,8 @@ extension PersonImageCollection { static func mock( id: Int = 1, profiles: [ImageMetadata] = [.mock(), .mock()] - ) -> Self { - .init( + ) -> PersonImageCollection { + PersonImageCollection( id: id, profiles: profiles ) diff --git a/Tests/TMDbTests/Mocks/Models/PersonListItem+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonListItem+Mocks.swift index eb362378..d6798701 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonListItem+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonListItem+Mocks.swift @@ -28,10 +28,10 @@ extension PersonListItem { originalName: String, knownForDepartment: String? = nil, gender: Gender = .unknown, - profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), popularity: Double? = 5 - ) -> Self { - .init( + ) -> PersonListItem { + PersonListItem( id: id, name: name, originalName: originalName, @@ -42,32 +42,32 @@ extension PersonListItem { ) } - static var tomCruise: Self { - .mock(id: 500, name: "Tom Cruise", originalName: "Tom Cruise") + static var tomCruise: PersonListItem { + PersonListItem.mock(id: 500, name: "Tom Cruise", originalName: "Tom Cruise") } - static var bradPitt: Self { - .mock(id: 287, name: "Brad Pitt", originalName: "Brad Pitt") + static var bradPitt: PersonListItem { + PersonListItem.mock(id: 287, name: "Brad Pitt", originalName: "Brad Pitt") } - static var johnnyDepp: Self { - .mock(id: 85, name: "Johnny Depp", originalName: "Johnny Depp") + static var johnnyDepp: PersonListItem { + PersonListItem.mock(id: 85, name: "Johnny Depp", originalName: "Johnny Depp") } - static var quentinTarantino: Self { - .mock(id: 138, name: "Quentin Tarantino", originalName: "Quentin Tarantino") + static var quentinTarantino: PersonListItem { + PersonListItem.mock(id: 138, name: "Quentin Tarantino", originalName: "Quentin Tarantino") } } extension [PersonListItem] { - static var mocks: [Element] { + static var mocks: [PersonListItem] { [ .tomCruise, .bradPitt, .johnnyDepp, - .quentinTarantino, + .quentinTarantino ] } diff --git a/Tests/TMDbTests/Mocks/Models/PersonMovieCredits+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonMovieCredits+Mocks.swift index c68cc457..ff9dd2f8 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonMovieCredits+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonMovieCredits+Mocks.swift @@ -26,8 +26,8 @@ extension PersonMovieCredits { id: Int = 1, cast: [Movie] = .mocks, crew: [Movie] = .mocks - ) -> Self { - .init( + ) -> PersonMovieCredits { + PersonMovieCredits( id: id, cast: cast, crew: crew diff --git a/Tests/TMDbTests/Mocks/Models/PersonPageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonPageableList+Mocks.swift index e9dd6afc..e8609765 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonPageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonPageableList+Mocks.swift @@ -27,8 +27,8 @@ extension PersonPageableList { results: [PersonListItem] = .mocks, totalResults: Int = 10, totalPages: Int = 2 - ) -> Self { - .init( + ) -> PersonPageableList { + PersonPageableList( page: page, results: results, totalResults: totalResults, diff --git a/Tests/TMDbTests/Mocks/Models/PersonTVSeriesCredits+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonTVSeriesCredits+Mocks.swift index 2d7ca080..9c4a70fd 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonTVSeriesCredits+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonTVSeriesCredits+Mocks.swift @@ -26,8 +26,8 @@ extension PersonTVSeriesCredits { id: Int = 1, cast: [TVSeries] = .mocks, crew: [TVSeries] = .mocks - ) -> Self { - .init( + ) -> PersonTVSeriesCredits { + PersonTVSeriesCredits( id: id, cast: cast, crew: crew diff --git a/Tests/TMDbTests/Mocks/Models/ProductionCompany+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ProductionCompany+Mocks.swift index 1c37327e..e760b91e 100644 --- a/Tests/TMDbTests/Mocks/Models/ProductionCompany+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ProductionCompany+Mocks.swift @@ -26,9 +26,9 @@ extension ProductionCompany { id: Int = 1, name: String = "Production Company Name", originCountry: String = "Production Origin Country", - logoPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! - ) -> Self { - .init( + logoPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg") + ) -> ProductionCompany { + ProductionCompany( id: id, name: name, originCountry: originCountry, @@ -40,7 +40,7 @@ extension ProductionCompany { extension [ProductionCompany] { - static var mocks: [Element] { + static var mocks: [ProductionCompany] { [.mock(), .mock(), .mock()] } diff --git a/Tests/TMDbTests/Mocks/Models/ProductionCountry+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ProductionCountry+Mocks.swift index 641de5f3..35b6bbf2 100644 --- a/Tests/TMDbTests/Mocks/Models/ProductionCountry+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ProductionCountry+Mocks.swift @@ -25,8 +25,8 @@ extension ProductionCountry { static func mock( countryCode: String = "US", name: String = "United States of America" - ) -> Self { - .init( + ) -> ProductionCountry { + ProductionCountry( countryCode: countryCode, name: name ) @@ -36,7 +36,7 @@ extension ProductionCountry { extension [ProductionCountry] { - static var mocks: [Element] { + static var mocks: [ProductionCountry] { [.mock(), .mock(), .mock()] } diff --git a/Tests/TMDbTests/Mocks/Models/Review+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Review+Mocks.swift index 9a358944..edcf8548 100644 --- a/Tests/TMDbTests/Mocks/Models/Review+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Review+Mocks.swift @@ -26,8 +26,8 @@ extension Review { id: String = "1", author: String = "Author Name", content: String = "Some review content" - ) -> Self { - .init( + ) -> Review { + Review( id: id, author: author, content: content @@ -38,7 +38,7 @@ extension Review { extension [Review] { - static var mocks: [Element] { + static var mocks: [Review] { [.mock(), .mock(), .mock()] } diff --git a/Tests/TMDbTests/Mocks/Models/ReviewPageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ReviewPageableList+Mocks.swift index 92ddd8a8..914728a0 100644 --- a/Tests/TMDbTests/Mocks/Models/ReviewPageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ReviewPageableList+Mocks.swift @@ -27,8 +27,8 @@ extension ReviewPageableList { results: [Review] = .mocks, totalResults: Int = 10, totalPages: Int = 2 - ) -> Self { - .init( + ) -> ReviewPageableList { + ReviewPageableList( page: page, results: results, totalResults: totalResults, diff --git a/Tests/TMDbTests/Mocks/Models/ShowCredits+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ShowCredits+Mocks.swift index 4b292f24..20c27917 100644 --- a/Tests/TMDbTests/Mocks/Models/ShowCredits+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ShowCredits+Mocks.swift @@ -26,8 +26,8 @@ extension ShowCredits { id: Int = 1, cast: [CastMember] = .mocks, crew: [CrewMember] = .mocks - ) -> Self { - .init( + ) -> ShowCredits { + ShowCredits( id: id, cast: cast, crew: crew diff --git a/Tests/TMDbTests/Mocks/Models/ShowWatchProvider+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ShowWatchProvider+Mocks.swift index edaf6c0c..13f822c2 100644 --- a/Tests/TMDbTests/Mocks/Models/ShowWatchProvider+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ShowWatchProvider+Mocks.swift @@ -29,8 +29,8 @@ extension ShowWatchProvider { flatRate: [WatchProvider]? = [.netflix], buy: [WatchProvider]? = [.netflix], rent: [WatchProvider]? = [.netflix] - ) -> Self { - .init( + ) -> ShowWatchProvider { + ShowWatchProvider( link: link, free: free, flatRate: flatRate, diff --git a/Tests/TMDbTests/Mocks/Models/ShowWatchProviderResult+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ShowWatchProviderResult+Mocks.swift index e49d5e88..98a14b3e 100644 --- a/Tests/TMDbTests/Mocks/Models/ShowWatchProviderResult+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ShowWatchProviderResult+Mocks.swift @@ -26,10 +26,11 @@ extension ShowWatchProviderResult { static func mock( id: Int = 1, regionCode: String = "GB" - ) -> Self { - .init( + ) -> ShowWatchProviderResult { + ShowWatchProviderResult( id: id, results: [regionCode: .mock()] ) } + } diff --git a/Tests/TMDbTests/Mocks/Models/SpokenLanguage+Mocks.swift b/Tests/TMDbTests/Mocks/Models/SpokenLanguage+Mocks.swift index ca9b6ec9..7e5d4a25 100644 --- a/Tests/TMDbTests/Mocks/Models/SpokenLanguage+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/SpokenLanguage+Mocks.swift @@ -22,11 +22,11 @@ import TMDb extension SpokenLanguage { - static func mocks( + static func mock( languageCode: String = "en", name: String = "English" - ) -> Self { - .init( + ) -> SpokenLanguage { + SpokenLanguage( languageCode: languageCode, name: name ) @@ -36,8 +36,8 @@ extension SpokenLanguage { extension [SpokenLanguage] { - static var mocks: [Element] { - [.mocks(), .mocks(), .mocks()] + static var mocks: [SpokenLanguage] { + [.mock(), .mock(), .mock()] } } diff --git a/Tests/TMDbTests/Mocks/Models/TVEpisode+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVEpisode+Mocks.swift index 9faaa26d..4fde63ec 100644 --- a/Tests/TMDbTests/Mocks/Models/TVEpisode+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVEpisode+Mocks.swift @@ -35,8 +35,8 @@ extension TVEpisode { guestStars: [CastMember]? = nil, voteAverage: Double? = nil, voteCount: Int? = nil - ) -> Self { - .init( + ) -> TVEpisode { + TVEpisode( id: id, name: name, episodeNumber: episodeNumber, @@ -56,7 +56,7 @@ extension TVEpisode { extension [TVEpisode] { - static var mocks: [Element] { + static var mocks: [TVEpisode] { [.mock(), .mock(), .mock(), .mock()] } diff --git a/Tests/TMDbTests/Mocks/Models/TVEpisodeImageCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVEpisodeImageCollection+Mocks.swift index 6a111251..173b9224 100644 --- a/Tests/TMDbTests/Mocks/Models/TVEpisodeImageCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVEpisodeImageCollection+Mocks.swift @@ -25,8 +25,8 @@ extension TVEpisodeImageCollection { static func mock( id: Int = 1, stills: [ImageMetadata] = .mocks - ) -> Self { - .init( + ) -> TVEpisodeImageCollection { + TVEpisodeImageCollection( id: id, stills: stills ) diff --git a/Tests/TMDbTests/Mocks/Models/TVSeason+Mock.swift b/Tests/TMDbTests/Mocks/Models/TVSeason+Mock.swift index f063b8fb..37d49a5b 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeason+Mock.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeason+Mock.swift @@ -24,16 +24,16 @@ extension TVSeason { static func mock( id: Int = 1, - name: String? = nil, + name: String = "TV Season", seasonNumber: Int = 2, overview: String? = "TV Season Overview", airDate: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), posterPath: URL? = nil, episodes: [TVEpisode]? = .mocks - ) -> Self { - .init( + ) -> TVSeason { + TVSeason( id: id, - name: name ?? "TV Season \(id)", + name: name, seasonNumber: seasonNumber, overview: overview, airDate: airDate, diff --git a/Tests/TMDbTests/Mocks/Models/TVSeasonImageCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVSeasonImageCollection+Mocks.swift index bceb7fb3..b9580da4 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeasonImageCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeasonImageCollection+Mocks.swift @@ -25,8 +25,8 @@ extension TVSeasonImageCollection { static func mock( id: Int = 1, posters: [ImageMetadata] = .mocks - ) -> Self { - .init( + ) -> TVSeasonImageCollection { + TVSeasonImageCollection( id: id, posters: posters ) diff --git a/Tests/TMDbTests/Mocks/Models/TVSeries+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVSeries+Mocks.swift index 3e70d979..e1ec9129 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeries+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeries+Mocks.swift @@ -49,8 +49,8 @@ extension TVSeries { popularity: Double? = nil, voteAverage: Double? = nil, voteCount: Int? = nil - ) -> Self { - .init( + ) -> TVSeries { + TVSeries( id: id, name: name ?? "TV Series \(id)", originalName: originalName, @@ -79,30 +79,30 @@ extension TVSeries { ) } - static var sheHulk: Self { - .mock( + static var sheHulk: TVSeries { + TVSeries.mock( id: 92783, name: "She-Hulk: Attorney at Law", firstAirDate: DateFormatter.theMovieDatabase.date(from: "2022-08-18"), - posterPath: URL(string: "/hJfI6AGrmr4uSHRccfJuSsapvOb.jpg")! + posterPath: URL(string: "/hJfI6AGrmr4uSHRccfJuSsapvOb.jpg") ) } - static var theSandman: Self { - .mock( + static var theSandman: TVSeries { + TVSeries.mock( id: 90802, name: "The Sandman", firstAirDate: DateFormatter.theMovieDatabase.date(from: "2022-08-05"), - posterPath: URL(string: "/q54qEgagGOYCq5D1903eBVMNkbo.jpg")! + posterPath: URL(string: "/q54qEgagGOYCq5D1903eBVMNkbo.jpg") ) } - static var strangerThings: Self { - .mock( + static var strangerThings: TVSeries { + TVSeries.mock( id: 66732, name: "Stranger Things", firstAirDate: DateFormatter.theMovieDatabase.date(from: "2016-07-15"), - posterPath: URL(string: "/49WJfeN0moxb9IPfGn8AIqMGskD.jpg")! + posterPath: URL(string: "/49WJfeN0moxb9IPfGn8AIqMGskD.jpg") ) } @@ -110,7 +110,7 @@ extension TVSeries { extension [TVSeries] { - static var mocks: [Element] { + static var mocks: [TVSeries] { [.sheHulk, .theSandman, .strangerThings] } diff --git a/Tests/TMDbTests/Mocks/Models/TVSeriesListItem+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVSeriesListItem+Mocks.swift index 71848dee..f14e9efa 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeriesListItem+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeriesListItem+Mocks.swift @@ -32,8 +32,8 @@ extension TVSeriesListItem { genreIDs: [Genre.ID] = [1], firstAirDate: Date? = nil, originCountries: [String] = ["GB"], - posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, - backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), + backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg"), popularity: Double? = 5, voteAverage: Double? = 5, voteCount: Int? = 100, @@ -57,7 +57,7 @@ extension TVSeriesListItem { ) } - // swiftlint:disable line_length + // swift-format-ignore: NeverForceUnwrap static var bigBrother: TVSeriesListItem { TVSeriesListItem( id: 11366, @@ -78,9 +78,6 @@ extension TVSeriesListItem { ) } - // swiftlint:enable line_length - - // swiftlint:disable line_length static var csi: TVSeriesListItem { TVSeriesListItem( id: 1431, @@ -100,16 +97,15 @@ extension TVSeriesListItem { isAdultOnly: false ) } - // swiftlint:enable line_length } extension [TVSeriesListItem] { - static var mocks: [Element] { + static var mocks: [TVSeriesListItem] { [ .bigBrother, - .csi, + .csi ] } diff --git a/Tests/TMDbTests/Mocks/Models/TVSeriesPageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVSeriesPageableList+Mocks.swift index 1d2d6ae2..d26cd5a8 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeriesPageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeriesPageableList+Mocks.swift @@ -27,8 +27,8 @@ extension TVSeriesPageableList { results: [TVSeriesListItem] = .mocks, totalResults: Int? = 10, totalPages: Int? = 2 - ) -> Self { - .init( + ) -> TVSeriesPageableList { + TVSeriesPageableList( page: page, results: results, totalResults: totalResults, diff --git a/Tests/TMDbTests/Mocks/Models/VideoCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/VideoCollection+Mocks.swift index b376b2e3..04b630ca 100644 --- a/Tests/TMDbTests/Mocks/Models/VideoCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/VideoCollection+Mocks.swift @@ -25,8 +25,8 @@ extension VideoCollection { static func mock( id: Int = 1, results: [VideoMetadata] = .mocks - ) -> Self { - .init( + ) -> VideoCollection { + VideoCollection( id: id, results: results ) diff --git a/Tests/TMDbTests/Mocks/Models/VideoMetadata+Mocks.swift b/Tests/TMDbTests/Mocks/Models/VideoMetadata+Mocks.swift index 57412912..36598ff8 100644 --- a/Tests/TMDbTests/Mocks/Models/VideoMetadata+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/VideoMetadata+Mocks.swift @@ -29,8 +29,8 @@ extension VideoMetadata { key: String = "abc123", type: VideoType = .trailer, size: VideoSize = .s1080 - ) -> Self { - .init( + ) -> VideoMetadata { + VideoMetadata( id: id, name: name, site: site, diff --git a/Tests/TMDbTests/Mocks/Models/WatchProvider+Mocks.swift b/Tests/TMDbTests/Mocks/Models/WatchProvider+Mocks.swift index bc117b22..5962f12e 100644 --- a/Tests/TMDbTests/Mocks/Models/WatchProvider+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/WatchProvider+Mocks.swift @@ -25,20 +25,20 @@ extension WatchProvider { static func mock( id: Int = 1, name: String = "Netflix", - logoPath: URL = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! - ) -> Self { - .init( + logoPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg") + ) -> WatchProvider { + WatchProvider( id: id, name: name, logoPath: logoPath ) } - static var netflix: Self { - .mock( + static var netflix: WatchProvider { + WatchProvider.mock( id: 8, name: "Netflix", - logoPath: URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! + logoPath: URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg") ) } diff --git a/Tests/TMDbTests/Mocks/Models/WatchProviderRegions+Mocks.swift b/Tests/TMDbTests/Mocks/Models/WatchProviderRegions+Mocks.swift index bbde0c45..e445f7a5 100644 --- a/Tests/TMDbTests/Mocks/Models/WatchProviderRegions+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/WatchProviderRegions+Mocks.swift @@ -30,7 +30,7 @@ extension WatchProviderRegions { .init(countryCode: "AT", name: "Austria", englishName: "Austria"), .init( countryCode: "US", name: "United States", - englishName: "United States of America"), + englishName: "United States of America") ] ) } diff --git a/Tests/TMDbTests/Mocks/Models/WatchProviderResult+Mocks.swift b/Tests/TMDbTests/Mocks/Models/WatchProviderResult+Mocks.swift index f5375b08..d2258303 100644 --- a/Tests/TMDbTests/Mocks/Models/WatchProviderResult+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/WatchProviderResult+Mocks.swift @@ -28,10 +28,12 @@ extension WatchProviderResult { results: [ .init( id: 8, name: "Netflix", - logoPath: URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!), + logoPath: URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg") + ), .init( id: 9, name: "Amazon Prime Video", - logoPath: URL(string: "/emthp39XA2YScoYL1p0sdbAH2WA.jpg")!), + logoPath: URL(string: "/emthp39XA2YScoYL1p0sdbAH2WA.jpg") + ) ] ) } diff --git a/Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift b/Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift index 38a42550..8fa18944 100644 --- a/Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift +++ b/Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift @@ -59,12 +59,18 @@ final class MockURLProtocol: URLProtocol, @unchecked Sendable { client?.urlProtocol(self, didLoad: data) } - let response = await HTTPURLResponse( - url: url, - statusCode: Self.responseStatusCode ?? 200, - httpVersion: "2.0", - headerFields: nil - )! + guard + let response = await HTTPURLResponse( + url: url, + statusCode: Self.responseStatusCode ?? 200, + httpVersion: "2.0", + headerFields: nil + ) + else { + client?.urlProtocolDidFinishLoading(self) + return + } + client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed) client?.urlProtocolDidFinishLoading(self) } diff --git a/Tests/TMDbTests/Networking/Serialisers/TMDbAuthJSONSerialiserTests.swift b/Tests/TMDbTests/Networking/Serialisers/TMDbAuthJSONSerialiserTests.swift index 7a615753..70ad9218 100644 --- a/Tests/TMDbTests/Networking/Serialisers/TMDbAuthJSONSerialiserTests.swift +++ b/Tests/TMDbTests/Networking/Serialisers/TMDbAuthJSONSerialiserTests.swift @@ -43,7 +43,7 @@ struct TMDbAuthSerialiserTests { @Test("decode when data can be decoded returns decoded object") func decodeWhenDataCanBeDecodedReturnsDecodedObject() async throws { let expectedResult = MockObject() - let data = expectedResult.data + let data = try expectedResult.data() let result = try await serialiser.decode(MockObject.self, from: data) @@ -62,7 +62,7 @@ struct TMDbAuthSerialiserTests { @Test("encode when data can be encoded returns data") func encodeWhenDataCanBeEncodedReturnsData() async throws { let value = MockObject() - let expectedResult = value.data + let expectedResult = try value.data() let result = try await serialiser.encode(value) @@ -77,15 +77,14 @@ extension TMDbAuthSerialiserTests { let id: UUID - var data: Data { - // swiftlint:disable force_try - try! JSONEncoder().encode(self) - // swiftlint:enable force_try - } - init(id: UUID = .init()) { self.id = id } + + func data() throws -> Data { + try JSONEncoder().encode(self) + } + } } diff --git a/Tests/TMDbTests/Networking/Serialisers/TMDbJSONSerialiserTests.swift b/Tests/TMDbTests/Networking/Serialisers/TMDbJSONSerialiserTests.swift index 7d7e146a..1980e6fa 100644 --- a/Tests/TMDbTests/Networking/Serialisers/TMDbJSONSerialiserTests.swift +++ b/Tests/TMDbTests/Networking/Serialisers/TMDbJSONSerialiserTests.swift @@ -43,7 +43,7 @@ struct TMDbJSONSerialiserTests { @Test("decode when data can be decoded returns decoded object") func decodeWhenDataCanBeDecodedReturnsDecodedObject() async throws { let expectedResult = MockObject() - let data = expectedResult.data + let data = try expectedResult.data() let result = try await serialiser.decode(MockObject.self, from: data) @@ -62,7 +62,7 @@ struct TMDbJSONSerialiserTests { @Test("encode when data can be encoded returns data") func encodeWhenDataCanBeEncodedReturnsData() async throws { let value = MockObject() - let expectedResult = value.data + let expectedResult = try value.data() let result = try await serialiser.encode(value) @@ -77,15 +77,13 @@ extension TMDbJSONSerialiserTests { let id: UUID - var data: Data { - // swiftlint:disable force_try - try! JSONEncoder().encode(self) - // swiftlint:enable force_try - } - init(id: UUID = .init()) { self.id = id } + + func data() throws -> Data { + try JSONEncoder().encode(self) + } } } diff --git a/Tests/TMDbTests/Networking/TMDbAPIClientTests.swift b/Tests/TMDbTests/Networking/TMDbAPIClientTests.swift index 538da8da..02c2143e 100644 --- a/Tests/TMDbTests/Networking/TMDbAPIClientTests.swift +++ b/Tests/TMDbTests/Networking/TMDbAPIClientTests.swift @@ -125,22 +125,3 @@ struct TMDbAPIClientTests { } } - -extension TMDbAPIClientTests { - - private struct MockObject: Codable, Equatable { - - let id: UUID - - var data: Data { - // swiftlint:disable force_try - try! JSONEncoder().encode(self) - // swiftlint:enable force_try - } - - init(id: UUID = .init()) { - self.id = id - } - } - -}