frenzy-ios/Fervor/Token.swift

29 lines
820 B
Swift
Raw Normal View History

2021-12-08 02:58:02 +00:00
//
// 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"
}
}