<commit_before>//
//  PersonalData.swift
//  FlipConnectSDK
//
//  Created by <NAME> on 14/07/17.
//  Copyright © 2017 Flip Connect. All rights reserved.
//

import Foundation

public struct PersonalData {
    public private(set) var birthdate: Date? = nil
    public private(set) var genderType: GenderType? = nil
    public private(set) var genderTypeFriendlyName: String? = nil
    public private(set) var country: String? = nil
    public private(set) var dependentCount: Int? = nil
    
    init?(json: JSON) {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyy-MM-dd"
        
        self.country = json["country"] as? String
        self.genderTypeFriendlyName = json["genderTypeFriendlyName"] as? String
        self.dependentCount = json["dependentCount"] as? Int
        if let genderType = json["genderType"] as? String {
            self.genderType = GenderType(rawValue: genderType)
        }
        if let birthdate = json["birthdate"] as? String {
            let date = dateFormatter.date(from: birthdate)
            self.birthdate = date
        }
        
        if birthdate == nil, genderType == nil, genderTypeFriendlyName == nil, country == nil, dependentCount == nil {
            return nil
        }
    }
}

public enum GenderType: String {
    case masculine
    case feminine
    case unmentioned
}<commit_msg>➕  Add helper method to PersonalData that grabs country name<commit_after>//
//  PersonalData.swift
//  FlipConnectSDK
//
//  Created by <NAME> on 14/07/17.
//  Copyright © 2017 Flip Connect. All rights reserved.
//

import Foundation

public struct PersonalData {
    public private(set) var birthdate: Date? = nil
    public private(set) var genderType: GenderType? = nil
    public private(set) var genderTypeFriendlyName: String? = nil
    public private(set) var country: String? = nil
    public private(set) var dependentCount: Int? = nil
    
    init?(json: JSON) {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyy-MM-dd"
        
        self.country = json["country"] as? String
        self.genderTypeFriendlyName = json["genderTypeFriendlyName"] as? String
        self.dependentCount = json["dependentCount"] as? Int
        if let genderType = json["genderType"] as? String {
            self.genderType = GenderType(rawValue: genderType)
        }
        if let birthdate = json["birthdate"] as? String {
            let date = dateFormatter.date(from: birthdate)
            self.birthdate = date
        }
        
        if birthdate == nil, genderType == nil, genderTypeFriendlyName == nil, country == nil, dependentCount == nil {
            return nil
        }
    }
    
    static func getCountryName(countryCode: String?) -> String? {
        let countries = NSLocale.locales()
        let country = countries.first { $0.countryCode.uppercased() == countryCode?.uppercased() }
        return country?.countryName
    }
}

public enum GenderType: String {
    case masculine
    case feminine
    case unmentioned
}
{'fraction_non_alphanumeric': 0.09921414538310412, 'fraction_numerical': 0.0068762278978389, 'mean_word_length': 2.5941176470588236, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '7369889', 'n_tokens_mistral': 873, 'n_tokens_neox': 834, 'n_words': 252}