Skip to content

Instantly share code, notes, and snippets.

@jppsantos
Last active September 26, 2020 23:53
Show Gist options
  • Save jppsantos/a69aa2520a765a56324b6e23edc70817 to your computer and use it in GitHub Desktop.
Save jppsantos/a69aa2520a765a56324b6e23edc70817 to your computer and use it in GitHub Desktop.
enum PurchaseEndpoint: String {
private var baseURL: String { return "https://www.purchase.com" }
case product = "/product"
case user = "/user"
case store = "/store"
case payment = "/payment"
private var fullPath: String {
return baseURL + self.rawValue
}
var url: URL {
guard let url = URL(string: fullPath) else {
preconditionFailure("The url used in \(PurchaseEndpoint.self) is not valid")
}
return url
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment