<commit_before>//
//  TeslaSwift+Combine.swift
//  TeslaSwift
//
//  Created by <NAME> on 08/07/2019.
//  Copyright © 2019 <NAME>. All rights reserved.
//

#if swift(>=5.1)
import Combine
#if COCOAPODS
#else // SPM
import TeslaSwift
#endif

@available(iOS 13.0, macOS 10.15, watchOS 6, tvOS 13, *)
extension TeslaSwift {
    
    func resultify<Value: Decodable>(subscriber: @escaping (Result<Value, Error>) -> Void) -> ((Result<Value, Error>) -> ()) {
        
        return { (result: Result<Value, Error>) in
            
            switch result {
            case .success(let value):
                subscriber(.success(value))
            case .failure(let error):
                subscriber(.failure(error))
            }
        }
        
    }
    
    public func authenticate(email: String, password: String) -> Future<AuthToken, Error> {
       
        let future = Future<AuthToken,Error> { (subscriber: @escaping (Result<AuthToken, Error>) -> Void) in
            
            self.authenticate(email: email, password: password, completion: self.resultify(subscriber: subscriber))
            
        }
    
        return future
    }
    
    public func revoke() -> Future<Bool, Error> {
        
        let future = Future<Bool,Error> { (subscriber: @escaping (Result<Bool, Error>) -> Void) in
            
            self.revoke(completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicles() -> Future<[Vehicle], Error> {
        
        let future = Future<[Vehicle],Error> { (subscriber: @escaping (Result<[Vehicle], Error>) -> Void) in
            
            self.getVehicles(completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicle(_ vehicleID: String) -> Future<Vehicle, Error> {
           
           let future = Future<Vehicle,Error> { (subscriber: @escaping (Result<Vehicle, Error>) -> Void) in
               
               self.getVehicle(vehicleID, completion: self.resultify(subscriber: subscriber))
               
           }
           
           return future
       }
    
    public func getVehicle(_ vehicle: Vehicle) -> Future<Vehicle, Error> {
        
        let future = Future<Vehicle,Error> { (subscriber: @escaping (Result<Vehicle, Error>) -> Void) in
            
            self.getVehicle(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getAllData(_ vehicle: Vehicle) -> Future<VehicleExtended, Error> {
        
        let future = Future<VehicleExtended,Error> { (subscriber: @escaping (Result<VehicleExtended, Error>) -> Void) in
            
            self.getAllData(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicleMobileAccessState(_ vehicle: Vehicle) -> Future<Bool, Error> {
        
        let future = Future<Bool,Error> { (subscriber: @escaping (Result<Bool, Error>) -> Void) in
            
            self.getVehicleMobileAccessState(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicleChargeState(_ vehicle: Vehicle) -> Future<ChargeState, Error> {
        
        let future = Future<ChargeState,Error> { (subscriber: @escaping (Result<ChargeState, Error>) -> Void) in
            
            self.getVehicleChargeState(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicleChargeState(_ vehicle: Vehicle) -> Future<ClimateState, Error> {
        
        let future = Future<ClimateState,Error> { (subscriber: @escaping (Result<ClimateState, Error>) -> Void) in
            
            self.getVehicleClimateState(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicleDriveState(_ vehicle: Vehicle) -> Future<DriveState, Error> {
        
        let future = Future<DriveState,Error> { (subscriber: @escaping (Result<DriveState, Error>) -> Void) in
            
            self.getVehicleDriveState(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future<commit_msg>Incorrect function naming in TeslaSwift+Combine.<commit_after>//
//  TeslaSwift+Combine.swift
//  TeslaSwift
//
//  Created by <NAME> on 08/07/2019.
//  Copyright © 2019 <NAME>. All rights reserved.
//

#if swift(>=5.1)
import Combine
#if COCOAPODS
#else // SPM
import TeslaSwift
#endif

@available(iOS 13.0, macOS 10.15, watchOS 6, tvOS 13, *)
extension TeslaSwift {
    
    func resultify<Value: Decodable>(subscriber: @escaping (Result<Value, Error>) -> Void) -> ((Result<Value, Error>) -> ()) {
        
        return { (result: Result<Value, Error>) in
            
            switch result {
            case .success(let value):
                subscriber(.success(value))
            case .failure(let error):
                subscriber(.failure(error))
            }
        }
        
    }
    
    public func authenticate(email: String, password: String) -> Future<AuthToken, Error> {
       
        let future = Future<AuthToken,Error> { (subscriber: @escaping (Result<AuthToken, Error>) -> Void) in
            
            self.authenticate(email: email, password: password, completion: self.resultify(subscriber: subscriber))
            
        }
    
        return future
    }
    
    public func revoke() -> Future<Bool, Error> {
        
        let future = Future<Bool,Error> { (subscriber: @escaping (Result<Bool, Error>) -> Void) in
            
            self.revoke(completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicles() -> Future<[Vehicle], Error> {
        
        let future = Future<[Vehicle],Error> { (subscriber: @escaping (Result<[Vehicle], Error>) -> Void) in
            
            self.getVehicles(completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicle(_ vehicleID: String) -> Future<Vehicle, Error> {
           
           let future = Future<Vehicle,Error> { (subscriber: @escaping (Result<Vehicle, Error>) -> Void) in
               
               self.getVehicle(vehicleID, completion: self.resultify(subscriber: subscriber))
               
           }
           
           return future
       }
    
    public func getVehicle(_ vehicle: Vehicle) -> Future<Vehicle, Error> {
        
        let future = Future<Vehicle,Error> { (subscriber: @escaping (Result<Vehicle, Error>) -> Void) in
            
            self.getVehicle(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getAllData(_ vehicle: Vehicle) -> Future<VehicleExtended, Error> {
        
        let future = Future<VehicleExtended,Error> { (subscriber: @escaping (Result<VehicleExtended, Error>) -> Void) in
            
            self.getAllData(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicleMobileAccessState(_ vehicle: Vehicle) -> Future<Bool, Error> {
        
        let future = Future<Bool,Error> { (subscriber: @escaping (Result<Bool, Error>) -> Void) in
            
            self.getVehicleMobileAccessState(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicleChargeState(_ vehicle: Vehicle) -> Future<ChargeState, Error> {
        
        let future = Future<ChargeState,Error> { (subscriber: @escaping (Result<ChargeState, Error>) -> Void) in
            
            self.getVehicleChargeState(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicleClimateState(_ vehicle: Vehicle) -> Future<ClimateState, Error> {
        
        let future = Future<ClimateState,Error> { (subscriber: @escaping (Result<ClimateState, Error>) -> Void) in
            
            self.getVehicleClimateState(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
    }
    
    public func getVehicleDriveState(_ vehicle: Vehicle) -> Future<DriveState, Error> {
        
        let future = Future<DriveState,Error> { (subscriber: @escaping (Result<DriveState, Error>) -> Void) in
            
            self.getVehicleDriveState(vehicle, completion: self.resultify(subscriber: subscriber))
            
        }
        
        return future
{'fraction_non_alphanumeric': 0.10555555555555556, 'fraction_numerical': 0.005333333333333333, 'mean_word_length': 1.9338331160365059, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 123, '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': '3626254', 'n_tokens_mistral': 2609, 'n_tokens_neox': 2479, 'n_words': 559}