-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ef1ac7
commit acd4f11
Showing
36 changed files
with
1,821 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// TMDBSwift_iOS.h | ||
// TMDBSwift-iOS | ||
// | ||
// Created by Pietro Caselani on 15/05/19. | ||
// Copyright © 2019 Pietro Caselani. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
//! Project version number for TMDBSwift_iOS. | ||
FOUNDATION_EXPORT double TMDBSwift_iOSVersionNumber; | ||
|
||
//! Project version string for TMDBSwift_iOS. | ||
FOUNDATION_EXPORT const unsigned char TMDBSwift_iOSVersionString[]; | ||
|
||
// In this header, you should import all the public headers of your framework using statements like #import <TMDBSwift_iOS/PublicHeader.h> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
|
||
extension Bundle { | ||
static var testable: Bundle { | ||
// swiftlint:disable force_unwrapping | ||
return Bundle(identifier: "io.github.pietrocaselani.TMDBSwiftTestable")! | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Moya | ||
|
||
public enum ConfigurationService { | ||
case configuration | ||
} | ||
|
||
extension ConfigurationService: TMDBType { | ||
public var path: String { | ||
return "configuration" | ||
} | ||
|
||
public var task: Task { | ||
return .requestPlain | ||
} | ||
|
||
public var sampleData: Data { | ||
return stubbedResponse("tmdb_configuration") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Moya | ||
|
||
public enum Episodes { | ||
case images(showId: Int, season: Int, episode: Int) | ||
} | ||
|
||
extension Episodes: TMDBType { | ||
public var path: String { | ||
switch self { | ||
case let .images(showId, season, episode): | ||
return "tv/\(showId)/season/\(season)/episode/\(episode)/images" | ||
} | ||
} | ||
|
||
public var task: Task { | ||
return .requestPlain | ||
} | ||
|
||
public var sampleData: Data { | ||
switch self { | ||
case .images: | ||
return stubbedResponse("tmdb_episode_images") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Moya | ||
|
||
public enum Movies { | ||
case images(movieId: Int) | ||
} | ||
|
||
extension Movies: TMDBType { | ||
public var path: String { | ||
switch self { | ||
case let .images(movieId): | ||
return "movie/\(movieId)/images" | ||
} | ||
} | ||
|
||
public var task: Task { | ||
return .requestPlain | ||
} | ||
|
||
public var sampleData: Data { | ||
switch self { | ||
case let .images(movieId): | ||
guard movieId == 20526 else { | ||
return stubbedResponse("tmdb_movie_images") | ||
} | ||
return stubbedResponse("tmdb_movie_images_20526") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Moya | ||
|
||
public enum Shows { | ||
case images(showId: Int) | ||
} | ||
|
||
extension Shows: TMDBType { | ||
public var path: String { | ||
switch self { | ||
case let .images(showId): | ||
return "tv/\(showId)/images" | ||
} | ||
} | ||
|
||
public var task: Task { | ||
return .requestPlain | ||
} | ||
|
||
public var sampleData: Data { | ||
switch self { | ||
case .images: | ||
return stubbedResponse("tmdb_show_images") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2019 Pietro Caselani. All rights reserved.</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
public final class Configuration: Hashable, Codable { | ||
public let images: ImagesConfiguration | ||
|
||
public func hash(into hasher: inout Hasher) { | ||
hasher.combine(images) | ||
} | ||
|
||
public static func == (lhs: Configuration, rhs: Configuration) -> Bool { | ||
return lhs.hashValue == rhs.hashValue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
public final class Image: Codable { | ||
public let filePath: String | ||
public let width: Int | ||
public let height: Int | ||
public let iso6391: String? | ||
public let aspectRatio: Float | ||
public let voteAverage: Float | ||
public let voteCount: Int | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case width, height | ||
case filePath = "file_path" | ||
case iso6391 = "iso_639_1" | ||
case aspectRatio = "aspect_ratio" | ||
case voteAverage = "vote_average" | ||
case voteCount = "vote_count" | ||
} | ||
|
||
public required init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
filePath = try container.decode(String.self, forKey: .filePath) | ||
width = try container.decode(Int.self, forKey: .width) | ||
height = try container.decode(Int.self, forKey: .height) | ||
iso6391 = try container.decodeIfPresent(String.self, forKey: .iso6391) | ||
aspectRatio = try container.decode(Float.self, forKey: .aspectRatio) | ||
voteAverage = try container.decode(Float.self, forKey: .voteAverage) | ||
voteCount = try container.decode(Int.self, forKey: .voteCount) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
public final class Images: Codable { | ||
public let identifier: Int | ||
public let backdrops: [Image] | ||
public let posters: [Image] | ||
public let stills: [Image] | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case identifier = "id" | ||
case backdrops, posters, stills | ||
} | ||
|
||
public required init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
identifier = try container.decode(Int.self, forKey: .identifier) | ||
backdrops = try container.decodeIfPresent([Image].self, forKey: .backdrops) ?? [Image]() | ||
posters = try container.decodeIfPresent([Image].self, forKey: .posters) ?? [Image]() | ||
stills = try container.decodeIfPresent([Image].self, forKey: .stills) ?? [Image]() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
public final class ImagesConfiguration: Hashable, Codable { | ||
public let secureBaseURL: String | ||
public let backdropSizes: [String] | ||
public let posterSizes: [String] | ||
public let stillSizes: [String] | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case secureBaseURL = "secure_base_url" | ||
case backdropSizes = "backdrop_sizes" | ||
case posterSizes = "poster_sizes" | ||
case stillSizes = "still_sizes" | ||
} | ||
|
||
public required init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
secureBaseURL = try container.decode(String.self, forKey: .secureBaseURL) | ||
backdropSizes = try container.decode([String].self, forKey: .backdropSizes) | ||
posterSizes = try container.decode([String].self, forKey: .posterSizes) | ||
stillSizes = try container.decode([String].self, forKey: .backdropSizes) | ||
} | ||
|
||
public func hash(into hasher: inout Hasher) { | ||
hasher.combine(secureBaseURL) | ||
hasher.combine(backdropSizes) | ||
hasher.combine(posterSizes) | ||
hasher.combine(stillSizes) | ||
} | ||
|
||
public static func == (lhs: ImagesConfiguration, rhs: ImagesConfiguration) -> Bool { | ||
return lhs.hashValue == rhs.hashValue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public enum TMDBError: Int, Error { | ||
case toManyRequests = 429 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Foundation | ||
|
||
extension String { | ||
public var urlEscaped: String { | ||
return addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? self | ||
} | ||
|
||
public var utf8Encoded: Data { | ||
return data(using: .utf8) ?? Data() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
extension TMDB { | ||
// swiftlint:disable force_unwrapping | ||
public static let baseURL = URL(string: "https://\(TMDB.apiHost)/\(TMDB.apiVersion)")! | ||
|
||
static let apiHost = "api.themoviedb.org" | ||
static let apiVersion = "3" | ||
static let defaultSecureImageURL = "https://image.tmdb.org/t/p/" | ||
static let defaultBackdropSizes = ["w300", "w780", "w1280", "original"] | ||
static let defaultPosterSizes = ["w92", "w154", "w185", "w342", "w500", "w780", "original"] | ||
static let defaultStillSizes = ["w92", "w185", "w300", "original"] | ||
} |
Oops, something went wrong.