5 // Created by Pawel Dabrowski on 14/07/2018.
6 // Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved.
11 class Credentials: NSObject, NSCoding{
13 let credentialOAuthTokenSecretKey = "credentialOAuthTokenSecretKey"
14 let credentialOAuthTokenKey = "credentialOAuthTokenKey"
16 var oauthTokenModel: OAuthTokenModel?
22 required init?(coder decoder: NSCoder) {
24 if let token = decoder.decodeObject(forKey: credentialOAuthTokenKey) as? String, let secret = decoder.decodeObject(forKey: credentialOAuthTokenSecretKey) as? String {
25 self.oauthTokenModel = OAuthTokenModel(token: token, tokenSecret: secret)
29 func encode(with encoder: NSCoder) {
31 if let tokenModel = oauthTokenModel{
32 encoder.encode(tokenModel.token, forKey: credentialOAuthTokenKey)
33 encoder.encode(tokenModel.tokenSecret, forKey: credentialOAuthTokenSecretKey)
37 func isLoggedIn() -> Bool {
38 guard let tokenModel = oauthTokenModel, tokenModel.isValid() else {