Skip to content

Instantly share code, notes, and snippets.

@RinniSwift
Last active April 18, 2019 21:16
Show Gist options
  • Save RinniSwift/04807d1de1e728f66942a602ebefbd21 to your computer and use it in GitHub Desktop.
Save RinniSwift/04807d1de1e728f66942a602ebefbd21 to your computer and use it in GitHub Desktop.
enum Router {
// ...
// 2.
var scheme: String {
switch self {
case .getSources, .getProductIds, .getProductInfo:
return "https"
}
}
// 3.
var host: String {
switch self {
case .getSources, .getProductIds, .getProductInfo:
return "shopicruit.myshopify.com"
}
}
// 4.
var path: String {
switch self {
case .getSources:
return "/admin/custom_collections.json"
case .getProductIds:
return "/admin/collects.json"
case .getProductInfo:
return "/admin/products.json"
}
}
// 5.
var parameters: [URLQueryItem] {
let accessToken = "c32313df0d0ef512ca64d5b336a0d7c6"
switch self {
case .getSources:
// 6.
return [URLQueryItem(name: "page", value: "1"),
URLQueryItem(name: "access_token", value: accessToken)]
case .getProductIds:
return [URLQueryItem(name: "page", value: "1"),
URLQueryItem(name: "collection_id", value: "68424466488"),
URLQueryItem(name: "access_token", value: accessToken)]
case .getProductInfo:
return [URLQueryItem(name: "ids", value: "2759162243,2759143811"),
URLQueryItem(name: "page", value: "1"),
URLQueryItem(name: "access_token", value: accessToken)]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment