diff --git a/Sources/LemonSqueezy/LemonSqueezy+API.swift b/Sources/LemonSqueezy/LemonSqueezy+API.swift index bac810c..4d7f266 100644 --- a/Sources/LemonSqueezy/LemonSqueezy+API.swift +++ b/Sources/LemonSqueezy/LemonSqueezy+API.swift @@ -39,7 +39,7 @@ extension LemonSqueezy { var components = URLComponents() components.scheme = "https" - components.host = "api.lemonsqueezy.com" + components.host = self.baseHost components.path = "\(route.resolvedPath.path)" components.queryItems = combinedQueryItems diff --git a/Sources/LemonSqueezy/LemonSqueezy.swift b/Sources/LemonSqueezy/LemonSqueezy.swift index 88a5553..e588311 100644 --- a/Sources/LemonSqueezy/LemonSqueezy.swift +++ b/Sources/LemonSqueezy/LemonSqueezy.swift @@ -5,13 +5,18 @@ import Combine public class LemonSqueezy: NSObject, ObservableObject { public private(set) var apiKey: String + /// Base URL to API endpoint, without https prefix. + public private(set) var baseHost: String + internal let decoder: JSONDecoder internal let encoder: JSONEncoder - public init(_ apiKey: String) { + public init(_ apiKey: String, _ baseHost: String = "") { self.decoder = Self.initializeDecoder() self.encoder = Self.initializeEncoder() self.apiKey = apiKey + + self.baseHost = baseHost.isEmpty ? "api.lemonsqueezy.com" : baseHost } static internal func initializeDecoder() -> JSONDecoder {