     
     public func domain() -> String {
         #if DEBUG || STAGING
-            if let value = UserDefaults.standard.value(forKey: BaseUrlKeys.domain) as? String {
+            if let value = defaults.value(forKey: BaseUrlKeys.domain) as? String {
                 return value
             }
         #endif

public class BaseUrl
{
    fileprivate weak var delegate: BaseUrlDelegate!
    
    required public init(delegate: BaseUrlDelegate) {
        self.delegate = delegate
    }
    
    public var url: String { get { return urlProtocol() + domain() } }
    
    public func urlProtocol() -> String {
        #if DEBUG || STAGING
            if let value = UserDefaults.standard.value(forKey: BaseUrlKeys.urlProtocol) as? String {
                return value
            }
        #endif

    
    internal func retreivePrevious() -> (domain: String?, urlProtocol: String?) {
        return (
            domain: defaults.string(forKey: BaseUrlKeys.previousDomain),
            urlProtocol: defaults.string(forKey: BaseUrlKeys.previousUrlProtocol)
        )
    }
    
    private func set(value: String?, forKey key: String) {
        if value?.isEmpty ?? true {
            defaults.removeObject(forKey: key)
        } else {
            defaults.setValue(value, forKey: key)
        }
    }
    
    internal func reset() {
        defaults.removeObject(forKey: BaseUrlKeys.domain)
        defaults.removeObject(forKey: BaseUrlKeys.urlProtocol)
        defaults.removeObject(forKey: BaseUrlKeys.previousDomain)
        defaults.removeObject(forKey: BaseUrlKeys.previousUrlProtocol)
    }
    #endif
}
