<commit_before>//
//  FSSession.swift
//  Quadrat
//
//  Created by <NAME> on 26/10/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation

public typealias AuthorizationHandler = (Bool, NSError?) -> Void

public let UserSelf = "self"

public typealias Parameters = [String:String]

private var _sharedSession : Session?

public class Session {
    let configuration       : Configuration
    let URLSession          : NSURLSession
    var authorizer          : Authorizer?
    
    public lazy var users : Users = {
        return Users(configuration: self.configuration, session: self)
        }()
    
    public lazy var venues : Venues = {
        return Venues(configuration: self.configuration, session: self)
        }()
    
    public lazy var venueGroups : VenueGroups = {
        return VenueGroups(configuration: self.configuration, session: self)
        }()
    
    public lazy var checkins : Checkins = {
        return Checkins(configuration: self.configuration, session: self)
        }()
    
    public lazy var tips : Tips = {
        return Tips(configuration: self.configuration, session: self)
        }()
    
    public lazy var lists : Lists = {
        return Lists(configuration: self.configuration, session: self)
        }()
    
    public lazy var updates : Updates = {
        return Updates(configuration: self.configuration, session: self)
        }()
    
    public lazy var photos : Photos = {
        return Photos(configuration: self.configuration, session: self)
        }()
    
    public lazy var settings : Settings = {
        return Settings(configuration: self.configuration, session: self)
        }()
    
    public lazy var specials : Specials = {
        return Specials(configuration: self.configuration, session: self)
        }()
    
    public lazy var events : Events = {
        return Events(configuration: self.configuration, session: self)
        }()
    
    public lazy var pages : Pages = {
        return Pages(configuration: self.configuration, session: self)
        }()
    
    public lazy var pageUpdates : PageUpdates = {
        return PageUpdates(configuration: self.configuration, session: self)
        }()
    
    public lazy var multi : Multi = {
        return Multi(configuration: self.configuration, session: self)
        }()
    
    public init(configuration: Configuration, completionQueue: NSOperationQueue) {
        self.configuration = configuration
        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        self.URLSession = NSURLSession(configuration: configuration, delegate: nil, delegateQueue: completionQueue)
    }
    
    public convenience init(configuration: Configuration) {
        self.init(configuration:configuration, completionQueue: NSOperationQueue.mainQueue())
    }
    
    public class func setupSharedSessionWithConfiguration(configuration: Configuration) {
        if _sharedSession == nil {
            _sharedSession = Session(configuration: configuration)
        } else {
            fatalError("You shouldn't call call setupSharedSessionWithConfiguration twice!")
        }
    }
    
    public class func sharedSession() -> Session {
        if _sharedSession == nil {
            fatalError("You must call setupSharedInstanceWithConfiguration before!")
        }
        return _sharedSession!
    }
    
    public func isAuthorized() -> Bool {
        let keychain = Keychain(configuration: self.configuration)
        return keychain.accessToken() != nil
    }
    
    <commit_msg>Add method for deauthorization<commit_after>//
//  FSSession.swift
//  Quadrat
//
//  Created by <NAME> on 26/10/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation

public typealias AuthorizationHandler = (Bool, NSError?) -> Void

public let UserSelf = "self"

public typealias Parameters = [String:String]

private var _sharedSession : Session?

public class Session {
    let configuration       : Configuration
    let URLSession          : NSURLSession
    var authorizer          : Authorizer?
    
    public lazy var users : Users = {
        return Users(configuration: self.configuration, session: self)
        }()
    
    public lazy var venues : Venues = {
        return Venues(configuration: self.configuration, session: self)
        }()
    
    public lazy var venueGroups : VenueGroups = {
        return VenueGroups(configuration: self.configuration, session: self)
        }()
    
    public lazy var checkins : Checkins = {
        return Checkins(configuration: self.configuration, session: self)
        }()
    
    public lazy var tips : Tips = {
        return Tips(configuration: self.configuration, session: self)
        }()
    
    public lazy var lists : Lists = {
        return Lists(configuration: self.configuration, session: self)
        }()
    
    public lazy var updates : Updates = {
        return Updates(configuration: self.configuration, session: self)
        }()
    
    public lazy var photos : Photos = {
        return Photos(configuration: self.configuration, session: self)
        }()
    
    public lazy var settings : Settings = {
        return Settings(configuration: self.configuration, session: self)
        }()
    
    public lazy var specials : Specials = {
        return Specials(configuration: self.configuration, session: self)
        }()
    
    public lazy var events : Events = {
        return Events(configuration: self.configuration, session: self)
        }()
    
    public lazy var pages : Pages = {
        return Pages(configuration: self.configuration, session: self)
        }()
    
    public lazy var pageUpdates : PageUpdates = {
        return PageUpdates(configuration: self.configuration, session: self)
        }()
    
    public lazy var multi : Multi = {
        return Multi(configuration: self.configuration, session: self)
        }()
    
    public init(configuration: Configuration, completionQueue: NSOperationQueue) {
        self.configuration = configuration
        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        self.URLSession = NSURLSession(configuration: configuration, delegate: nil, delegateQueue: completionQueue)
    }
    
    public convenience init(configuration: Configuration) {
        self.init(configuration:configuration, completionQueue: NSOperationQueue.mainQueue())
    }
    
    public class func setupSharedSessionWithConfiguration(configuration: Configuration) {
        if _sharedSession == nil {
            _sharedSession = Session(configuration: configuration)
        } else {
            fatalError("You shouldn't call call setupSharedSessionWithConfiguration twice!")
        }
    }
    
    public class func sharedSession() -> Session {
        if _sharedSession == nil {
            fatalError("You must call setupSharedInstanceWithConfiguration before!")
        }
        return _sharedSession!
    }
    
    public func isAuthorized() -> Bool {
        let keychain = Keychain(configuration: self.configuration)
        return keychain.accessToken() != nil
    }
    
    public func deauthorize() {
        let keychain = Keychain(configuration: self.configuration)
        keychain.deleteAccessToken()
    }
    
{'fraction_non_alphanumeric': 0.08578868027956695, 'fraction_numerical': 0.0027408524050979853, 'mean_word_length': 2.5827196858124695, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2854928', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1789, 'n_words': 521}