-
Notifications
You must be signed in to change notification settings - Fork 0
/
TokenProvidable.swift
25 lines (22 loc) · 796 Bytes
/
TokenProvidable.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
// TokenProvidable.swift
// Networking
//
// Created by Viktor Gidlöf.
//
import Foundation
/// An error enum for the token provider
public enum TokenProvidableError: Error {
case missing
}
// MARK: -
/// A protocol for creating token providable objects. It can be tokens for basic request authentication or bearer tokens.
public protocol TokenProvidable: AnyObject {
/// A result object containing a token used in HTTP Authorization request headers
var token: Result<String, TokenProvidableError> { get }
/// Persist the given token to any persistant storage on device. E.g `UserDefaults`, `CoreData`, `Keychain`.
/// - parameter token: The token to persist
func setToken(_ token: String)
/// Remove the token from the persistant storage
func reset()
}