<commit_before>import Foundation
import SwiftyVK


final class APIWorker {
    
    class func action(_ tag: Int) {
        switch tag {
        case 1:
            authorize()
        case 2:
            logout()
        case 3:
            captcha()
        case 4:
            usersGet()
        case 5:
            friendsGet()
        case 6:
            uploadPhoto()
        case 7:
            validation()
        default:
            print("Unrecognized action!")
        }
    }
    
    class func authorize() {
        VK.sessions?.default.logIn(
            onSuccess: { info in
                print("SwiftyVK: success authorize with", info)
            },
            onError: { error in
                print("SwiftyVK: authorize failed with", error)
            }
        )
    }
    
    class func logout() {
        VK.sessions?.default.logOut()
        print("SwiftyVK: LogOut")
    }
    
    class func captcha() {
        PrivateVKAPI.Custom.method(name: "captcha.force")
            .onSuccess { print("SwiftyVK: captcha.force success \n \($0)") }
            .onError { print("SwiftyVK: captcha.force fail \n \($0)") }
            .send()
    }
    
    class func validation() {
        PrivateVKAPI.Custom.method(name: "account.testValidation")
            .onSuccess { print("SwiftyVK: account.testValidation success \n \($0)") }
            .onError { print("SwiftyVK: account.testValidation fail \n \($0)") }
            .send()
    }
    
    class func usersGet() {
        PrivateVKAPI.Users.get([VK.Arg.userId : "1"])
            .onSuccess { print("SwiftyVK: users.get success \n \($0)") }
            .onError { print("SwiftyVK: friends.get fail \n \($0)") }
            .send()
    }
    
    class func friendsGet() {
        PrivateVKAPI.Friends.get([.count : "1", .fields : "city,domain"])
            .onSuccess { print("SwiftyVK: friends.get success \n \($0)") }
            .onError { print("SwiftyVK: friends.get fail \n \($0)") }
            .send()
    }
    
    class func uploadPhoto() {
        let data = try! Data(contentsOf: URL(fileURLWithPath: Bundle.main.path(forResource: "testImage", ofType: "jpg")!))
        let media = Media.image(data: data, type: .jpg)
        
        PrivateVKAPI.Upload.Photo.toWall(media, to: .user(id: "4680178"))<commit_msg>Fix PrivateVKAPI usage in demo<commit_after>import Foundation
import SwiftyVK


final class APIWorker {
    
    class func action(_ tag: Int) {
        switch tag {
        case 1:
            authorize()
        case 2:
            logout()
        case 3:
            captcha()
        case 4:
            usersGet()
        case 5:
            friendsGet()
        case 6:
            uploadPhoto()
        case 7:
            validation()
        default:
            print("Unrecognized action!")
        }
    }
    
    class func authorize() {
        VK.sessions?.default.logIn(
            onSuccess: { info in
                print("SwiftyVK: success authorize with", info)
            },
            onError: { error in
                print("SwiftyVK: authorize failed with", error)
            }
        )
    }
    
    class func logout() {
        VK.sessions?.default.logOut()
        print("SwiftyVK: LogOut")
    }
    
    class func captcha() {
        VK.API.Custom.method(name: "captcha.force")
            .onSuccess { print("SwiftyVK: captcha.force success \n \($0)") }
            .onError { print("SwiftyVK: captcha.force fail \n \($0)") }
            .send()
    }
    
    class func validation() {
        VK.API.Custom.method(name: "account.testValidation")
            .onSuccess { print("SwiftyVK: account.testValidation success \n \($0)") }
            .onError { print("SwiftyVK: account.testValidation fail \n \($0)") }
            .send()
    }
    
    class func usersGet() {
        VK.API.Users.get([VK.Arg.userId : "1"])
            .onSuccess { print("SwiftyVK: users.get success \n \($0)") }
            .onError { print("SwiftyVK: friends.get fail \n \($0)") }
            .send()
    }
    
    class func friendsGet() {
        VK.API.Friends.get([.count : "1", .fields : "city,domain"])
            .onSuccess { print("SwiftyVK: friends.get success \n \($0)") }
            .onError { print("SwiftyVK: friends.get fail \n \($0)") }
            .send()
    }
    
    class func uploadPhoto() {
        let data = try! Data(contentsOf: URL(fileURLWithPath: Bundle.main.path(forResource: "testImage", ofType: "jpg")!))
        let media = Media.image(data: data, type: .jpg)
        
        VK.API.Upload.Photo.toWall(media, to: .user(id: "4680178"))
{'fraction_non_alphanumeric': 0.1351116894382997, 'fraction_numerical': 0.01040988939492518, 'mean_word_length': 1.6475315729047073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1322201', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1443, 'n_words': 323}