<commit_before>//
//  CompresJSONObject.swift
//  CompresJSON
//
//  Created by <NAME> on 12/05/2015.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit

public class CompresJSONObject: JSONObject {
   
    public class func compresJsonWebApiGetObjectByID< T : JSONObject >(type: T.Type, id:Int, completion: (object:T) -> () ) {
        
        if let url = T.webApiUrls().getUrl(id) {
            
            CompresJsonRequest.create(url, parameters: nil, method: .GET).onDownloadSuccess { (json, request) -> () in
                
                completion(object: self.createObjectFromJson(json) as T)
            }
        }
    }
    
    // MARK: - Web Api Methods
    
    public func compresJSONWebApiInsert() -> CompresJsonRequest?{
        
        return compresJSONWebApiInsert(nil)<commit_msg>support for get multiple objects<commit_after>//
//  CompresJSONObject.swift
//  CompresJSON
//
//  Created by <NAME> on 12/05/2015.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import SwiftyJSON

public class CompresJSONObject: JSONObject {
   
    public class func compresJsonWebApiGetObjectByID< T : JSONObject >(type: T.Type, id:Int, completion: (object:T) -> () ) {
        
        if let url = T.webApiUrls().getUrl(id) {
            
            CompresJsonRequest.create(url, parameters: nil, method: .GET).onDownloadSuccess { (json, request) -> () in
                
                completion(object: self.createObjectFromJson(json) as T)
            }
        }
    }
    
    public class func compresJsonWebApiGetMultipleObjects< T : JSONObject >(type: T.Type, id:Int, completion: (objects:[T]) -> () ) {
        
        if let url = T.webApiUrls().getMultipleUrl() {
            
            CompresJsonRequest.create(url, parameters: nil, method: .GET).onDownloadSuccess { (json, request) -> () in
                
                var objects = [T]()
                
                for (index: String, objectJSON: JSON) in json {
                    
                    var object:T = self.createObjectFromJson(objectJSON)
                    objects.append(object)
                }
                
                completion(objects: objects)
            }
        }
    }
    
    // MARK: - Web Api Methods
    
    public func compresJSONWebApiInsert() -> CompresJsonRequest?{
        
        return compresJSONWebApiInsert(nil)
{'fraction_non_alphanumeric': 0.1095890410958904, 'fraction_numerical': 0.009962640099626401, 'mean_word_length': 1.8486997635933806, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '245851', 'n_tokens_mistral': 718, 'n_tokens_neox': 682, 'n_words': 160}