<commit_before>//
//  User.swift
//  MojioSDK
//
//  Created by <NAME> on 2016-02-10.
//  Copyright © 2016 Mojio. All rights reserved.
//

import UIKit
import ObjectMapper
import RealmSwift
import Realm

public class User : Object, Mappable {
    
    public dynamic var FirstName : String? = nil
    public dynamic var LastName : String? = nil
    public dynamic var UserName : String? = nil
    public dynamic var Jurisdiction : String? = nil
    public var Emails = List<Email>()
    public var PhoneNumbers = List<PhoneNumber>()
    public dynamic var Img : Image? = nil
    public var Tags = List<StringObject>()
    public dynamic var Id : String? = nil
    public dynamic var CreatedOn : String? = nil
    public dynamic var LastModified : String? = nil
    
    /* PUT & POST properties */
    public dynamic var email : String? = nil
    
    public required convenience init?(_ map: Map) {
        self.init()
    }
    
    public override static func primaryKey() -> String? {
        return "Id"
    }
    
    public func EmailsArray() -> NSArray {
        return self.Emails.toArray()
    }
    
    public func PhoneNumbersArray() -> NSArray {
        return self.PhoneNumbers.toArray()
    }
    
    public func TagsArray() -> NSArray {
        return self.Tags.toArray()
    }

    public func json () -> String? {
        let dictionary : NSMutableDictionary = NSMutableDictionary()
        
        if self.UserName != nil {
            dictionary.setObject(self.UserName!, forKey: "UserName")
        }
        if self.Emails.count > 0 {
            self.email = (self.Emails.first! as Email).Address
            dictionary.setObject(self.email!, forKey: "Email")
        }
        if self.FirstName != nil {
            dictionary.setObject(self.FirstName!, forKey: "FirstName")
        }
        if self.LastName != nil {
            dictionary.setObject(self.LastName!, forKey: "LastName")
        }
        if self.PhoneNumbers.count > 0 {
            dictionary.setObject(self.PhoneNumbers.toArray(), forKey: "PhoneNumbers")
        }
        
        let data = try! NSJSONSerialization.dataWithJSONObject(dictionary, options:  NSJSONWritingOptions.PrettyPrinted)
        return NSString(data: data, encoding: NSUTF8StringEncoding)! as String
    }
    
    public func mapping(map: Map) {
        
        var emails = Array<Email>()
        emails <- map["Emails"]
        
        for email in emails {
            self.Emails.append(email)
        }
        
        var tags = Array<String>()
        tags <- map["Tags"]
        
        for tag in tags {
            let string = StringObject()
            string.value = tag
            
            self.Tags.append(string)
        }
        
        var phoneNumbers = Array<PhoneNumber>()
        phoneNumbers <- map["PhoneNumbers"]
        
        for phoneNumber in phoneNumbers {
            self.PhoneNumbers.append(phoneNumber)
        }
        
        self.FirstName <- map["FirstName"];
        self.LastName <- map["LastName"];
        self.UserName <- map["UserName"];
        self.Jurisdiction <- map["Jurisdiction"];
        Img <- map["Image"];
        self.Id <- map["Id"];
        self.CreatedOn <- map["CreatedOn"];
        self.LastModified <- map["LastModified"];
    }
}<commit_msg>Made changes to the User model so that it supports updating the user record<commit_after>//
//  User.swift
//  MojioSDK
//
//  Created by <NAME> on 2016-02-10.
//  Copyright © 2016 Mojio. All rights reserved.
//

import UIKit
import ObjectMapper
import RealmSwift
import Realm

public class User : Object, Mappable {
    
    public dynamic var FirstName : String? = nil
    public dynamic var LastName : String? = nil
    public dynamic var UserName : String? = nil
    public dynamic var Jurisdiction : String? = nil
    public var Emails = List<Email>()
    public var PhoneNumbers = List<PhoneNumber>()
    public dynamic var Img : Image? = nil
    public var Tags = List<StringObject>()
    public dynamic var Id : String? = nil
    public dynamic var CreatedOn : String? = nil
    public dynamic var LastModified : String? = nil
    
    /* PUT & POST properties */
    public dynamic var email : String? = nil
    
    public required convenience init?(_ map: Map) {
        self.init()
    }
    
    public override static func primaryKey() -> String? {
        return "Id"
    }
    
    public func EmailsArray() -> NSArray {
        return self.Emails.toArray()
    }
    
    public func PhoneNumbersArray() -> NSArray {
        return self.PhoneNumbers.toArray()
    }
    
    public func TagsArray() -> NSArray {
        return self.Tags.toArray()
    }

    public func jsonDict () -> NSDictionary {
        let dictionary : NSMutableDictionary = NSMutableDictionary()
        
        if self.UserName != nil {
            dictionary.setObject(self.UserName!, forKey: "UserName")
        }
        if self.email != nil {
            dictionary.setObject(self.email!, forKey: "Email")
        }
        if self.FirstName != nil {
            dictionary.setObject(self.FirstName!, forKey: "FirstName")
        }
        if self.LastName != nil {
            dictionary.setObject(self.LastName!, forKey: "LastName")
        }
        if self.PhoneNumbers.count > 0 {
            dictionary.setObject(self.PhoneNumbers.toArray(), forKey: "PhoneNumbers")
        }
        
        return dictionary
    }
    
    public func mapping(map: Map) {
        
        var emails = Array<Email>()
        emails <- map["Emails"]
        
        for email in emails {
            self.Emails.append(email)
        }
        
        var tags = Array<String>()
        tags <- map["Tags"]
        
        for tag in tags {
            let string = StringObject()
            string.value = tag
            
            self.Tags.append(string)
        }
        
        var phoneNumbers = Array<PhoneNumber>()
        phoneNumbers <- map["PhoneNumbers"]
        
        for phoneNumber in phoneNumbers {
            self.PhoneNumbers.append(phoneNumber)
        }
        
        self.FirstName <- map["FirstName"];
        self.LastName <- map["LastName"];
        self.UserName <- map["UserName"];
        self.Jurisdiction <- map["Jurisdiction"];
        Img <- map["Image"];
        self.Id <- map["Id"];
        self.CreatedOn <- map["CreatedOn"];
        self.LastModified <- map["LastModified"];
    }
}
{'fraction_non_alphanumeric': 0.10683094198378042, 'fraction_numerical': 0.004366812227074236, 'mean_word_length': 1.951219512195122, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 30, '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': '1329262', 'n_tokens_mistral': 1845, 'n_tokens_neox': 1735, 'n_words': 478}