Skip to content

Instantly share code, notes, and snippets.

@jppsantos
jppsantos / PurchaseEndpoints.swift
Last active September 26, 2020 23:38
Purchase Endpoints Enum
enum PurchaseEndpoint: String {
case product = "/product"
case user = "/user"
case store = "/store"
case payment = "/payment"
}
var baseURL = URL(string: "https://www.purchase.com")
baseURL?.appendPathComponent(PurchaseEndpoints.product.rawValue)
//output: = https://www.purchase.com/product
enum PurchaseEndpoint: String {
private var baseURL: String { return "https://www.purchase.com" }
case product = "/product"
case user = "/user"
case store = "/store"
case payment = "/payment"
var url: URL {
guard let url = URL(string: baseURL) else {
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
enum PurchaseEndpoint {
private var baseURL: String { return "https://www.purchase.com" }
case product
case user
case shop
case payment
case productWith(UUID)
case userWith(UUID)
case shopWith(UUID)