daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Jan 13th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ....
  2.     public func asURLRequest() throws -> URLRequest {
  3.          let url = try Router.baseURLString.asURL()
  4.          var urlRequest = URLRequest(url: url.appendingPathComponent(path))
  5.             urlRequest.httpMethod = method.rawValue
  6.  
  7.          switch self {
  8.          case .getData():
  9.               urlRequest = try URLEncoding.default.encode(urlRequest, with: nil)  
  10.               let token = Account.sharedAccount.accessToken
  11.               urlRequest.addValue("Token " + token!, forHTTPHeaderField: Router.AuthorizationHeaderKey)
  12. }
  13.    
  14. public class Account: NSObject {
  15.         public static let sharedAccount = Account()
  16.         public var accessToken: String? {
  17.             get {
  18.                 let keychain = Keychain(service: AccountKeychainService)
  19.                 do {
  20.                     let token = try keychain.get(AccountAccessTokenKeychainKey)
  21.                     return token
  22.                 } catch {
  23.                     return nil
  24.                 }
  25.             }
  26.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top