Created
March 15, 2022 19:28
-
-
Save malcommac/53aa6da8ef24f20f0d38acdef6b41ed3 to your computer and use it in GitHub Desktop.
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
extension Rankings { | |
struct List: APIResourceConvertible { | |
public typealias Result = MoviesPage | |
public enum Category: String, CaseIterable { | |
case upcoming, popular | |
case topRated = "top_rated" | |
} | |
public enum Region: String { | |
case Italy = "IT" | |
case USA = "US" | |
} | |
public var category: Category | |
public var region: Region | |
public var page = 1 | |
func request() -> HTTPRequest { | |
HTTPRequest { | |
$0.method = .get | |
$0.path = "/movie/\(category.rawValue)" | |
$0.addQueryParameter(name: "region", value: region.rawValue) | |
$0.addQueryParameter(name: "page", value: String(page)) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment