29 lines
820 B
Swift
29 lines
820 B
Swift
|
//
|
||
|
// Token.swift
|
||
|
// Fervor
|
||
|
//
|
||
|
// Created by Shadowfacts on 11/25/21.
|
||
|
//
|
||
|
|
||
|
import Foundation
|
||
|
|
||
|
public struct Token: Decodable {
|
||
|
public let accessToken: String
|
||
|
public let expiresIn: Int?
|
||
|
public let refreshToken: String?
|
||
|
|
||
|
public init(from decoder: Decoder) throws {
|
||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||
|
|
||
|
self.accessToken = try container.decode(String.self, forKey: .accessToken)
|
||
|
self.expiresIn = try container.decodeIfPresent(Int.self, forKey: .expiresIn)
|
||
|
self.refreshToken = try container.decodeIfPresent(String.self, forKey: .refreshToken)
|
||
|
}
|
||
|
|
||
|
private enum CodingKeys: String, CodingKey {
|
||
|
case accessToken = "access_token"
|
||
|
case expiresIn = "expires_in"
|
||
|
case refreshToken = "refresh_token"
|
||
|
}
|
||
|
}
|