Skip to content

Instantly share code, notes, and snippets.

@malcommac
Created March 15, 2022 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malcommac/53aa6da8ef24f20f0d38acdef6b41ed3 to your computer and use it in GitHub Desktop.
Save malcommac/53aa6da8ef24f20f0d38acdef6b41ed3 to your computer and use it in GitHub Desktop.
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