 import Foundation
 
 extension Trakt {
+  
+  // MARK: Properties
   
   public var authorized: Bool {
     guard let token = token?.accessToken else { return false }

    return components.url
  }
  
  public func open(url: URL, completion: @escaping (Result<Bool, Error>) -> Void) -> Bool {
    
    guard let query = url.query else { return false }
    guard let code = query.components(separatedBy: "=").last else { return false }
    
    exchangeToken(with: code, completion: completion)
    
    return true
  }
  
  @discardableResult private func exchangeToken(with code: String, completion: @escaping (Result<Bool, Error>) -> Void) -> URLSessionTask? {
    let params = [
      "client_id": credentials.clientID,
      "client_secret": credentials.clientSecret,

    return exchangeToken(with: params, completion: completion)
  }
  
}

// MARK: - Private Functions

fileprivate extension Trakt {
  
  func exchangeToken(with params: [String : Any], completion: @escaping (Result<Bool, Error>) -> Void) -> URLSessionTask? {
    let res = resource(for: "/oauth/token", params: params, method: .post, parse: parseToken)
    return load(resource: res, authenticated: true) { [weak self] result in
      switch result {
