<commit_before>//
//  Post.swift
//  TypetalkKit
//
//  Created by <NAME> on 2014/09/24.
//  Copyright (c) 2014年 Safx Developers. All rights reserved.
//

import Foundation
import JSONHelper

public class Post : Deserializable, ObjcBase {
    public let id: PostID = 0
    public let topicId: TopicID = 0
    public let topic: Topic? = nil
    public let replyTo: Int? = nil
    public let message: String = ""
    public let account: Account = Account()
    public let mention: String? = nil // FIXME
    public let attachments: [URLAttachment] = []
    public let likes: [Like] = []
    public let talks: [Talk] = []
    public let links: [Link] = []
    public let createdAt: NSDate = NSDate()
    public let updatedAt: NSDate = NSDate()
    
    public required init() {}
    
    required public init(data: [String: AnyObject]) {
        id          <<<   data["id"]
        topicId     <<<   data["topicId"]
        topic       <<<<  data["topic"]
        replyTo     <<<   data["replyTo"]
        message     <<<   data["message"]
        account     <<<<  data["account"]
        mention     <<<   data["mention"]
        attachments <<<<* data["attachments"]
        likes       <<<<* data["likes"]
        talks       <<<<* data["talks"]
        links       <<<<* data["links"]
        createdAt   <<<   (value: data["createdAt"], format: "yyyy-MM-dd'T'HH:mm:ssZ")<commit_msg>add init function in Post<commit_after>//
//  Post.swift
//  TypetalkKit
//
//  Created by <NAME> on 2014/09/24.
//  Copyright (c) 2014年 Safx Developers. All rights reserved.
//

import Foundation
import JSONHelper

public class Post : Deserializable, ObjcBase {
    public let id: PostID = 0
    public let topicId: TopicID = 0
    public let topic: Topic? = nil
    public let replyTo: Int? = nil
    public let message: String = ""
    public let account: Account = Account()
    public let mention: String? = nil // FIXME
    public let attachments: [URLAttachment] = []
    public let likes: [Like] = []
    public let talks: [Talk] = []
    public let links: [Link] = []
    public let createdAt: NSDate = NSDate()
    public let updatedAt: NSDate = NSDate()

    public required init() {}

    public init(id: PostID, topicId: TopicID, topic: Topic? = nil, replyTo: Int?, message: String = "", account: Account = Account(), mention: String? = nil, attachments: [URLAttachment] = [], likes: [Like] = [], talks: [Talk] = [], links: [Link] = [], createdAt: NSDate = NSDate(), updatedAt: NSDate = NSDate()) {
        self.id = id
        self.topicId = topicId
        self.topic = topic
        self.replyTo = replyTo
        self.message = message
        self.account = account
        self.mention = mention
        self.attachments = attachments
        self.likes = likes
        self.talks = talks
        self.links = links
        self.createdAt = createdAt
        self.updatedAt = updatedAt
    }

    required public init(data: [String: AnyObject]) {
        id          <<<   data["id"]
        topicId     <<<   data["topicId"]
        topic       <<<<  data["topic"]
        replyTo     <<<   data["replyTo"]
        message     <<<   data["message"]
        account     <<<<  data["account"]
        mention     <<<   data["mention"]
        attachments <<<<* data["attachments"]
        likes       <<<<* data["likes"]
        talks       <<<<* data["talks"]
        links       <<<<* data["links"]
        createdAt   <<<   (value: data["createdAt"], format: "yyyy-MM-dd'T'HH:mm:ssZ")
{'fraction_non_alphanumeric': 0.142652535090232, 'fraction_numerical': 0.008020624462904613, 'mean_word_length': 2.2850423330197556, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7355100', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1060, 'n_words': 303}