<commit_before>//
//  Subscription.swift
//  MusicFav
//
//  Created by <NAME> on 12/21/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import SwiftyJSON

public final class Subscription: Stream,
                                 ResponseObjectSerializable, ResponseCollectionSerializable,
                                 ParameterEncodable {
    public let id:         String
    public let title:      String
    public let categories: [Category]
    public let website:    String?
    public let visualUrl:  String?
    public let sortId:     String?
    public let updated:    Int64?
    public let added:      Int64?

    public override var streamId: String {
        return id
    }
    public override var streamTitle: String {
        return title
    }

    public class func collection(#response: NSHTTPURLResponse, representation: AnyObject) -> [Subscription] {
        let json = JSON(representation)
        return json.arrayValue.map({ Subscription(json: $0) })
    }

    required public convenience init?(response: NSHTTPURLResponse, representation: AnyObject) {
        let json = JSON(representation)
        self.init(json: json)
    }

    public init(json: JSON) {
        self.id         = json["id"].stringValue
        self.title      = json["title"].stringValue
        self.website    = json["website"].stringValue
        self.categories = json["categories"].arrayValue.map({Category(json: $0)})
        self.visualUrl  = json["visualUrl"].string
        self.sortId     = json["sortid"].string
        self.updated    = json["updated"].int64
        self.added      = json["added"].int64
    }

    public init(feed: Feed, categories: [Category]) {
        self.id         = feed.id
        self.title      = feed.title
        self.categories = categories
    }

    func toParameters() -> [String : AnyObject] {
        return [
                 "title": title,
                    "id": id,
            "categories": categories.map( { $0.toParameters() })
            ]
    }
}<commit_msg>Add constructor of Subscription with plain values<commit_after>//
//  Subscription.swift
//  MusicFav
//
//  Created by <NAME> on 12/21/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import SwiftyJSON

public final class Subscription: Stream,
                                 ResponseObjectSerializable, ResponseCollectionSerializable,
                                 ParameterEncodable {
    public let id:         String
    public let title:      String
    public let categories: [Category]
    public let website:    String?
    public let visualUrl:  String?
    public let sortId:     String?
    public let updated:    Int64?
    public let added:      Int64?

    public override var streamId: String {
        return id
    }
    public override var streamTitle: String {
        return title
    }

    public class func collection(#response: NSHTTPURLResponse, representation: AnyObject) -> [Subscription] {
        let json = JSON(representation)
        return json.arrayValue.map({ Subscription(json: $0) })
    }

    required public convenience init?(response: NSHTTPURLResponse, representation: AnyObject) {
        let json = JSON(representation)
        self.init(json: json)
    }

    public init(json: JSON) {
        self.id         = json["id"].stringValue
        self.title      = json["title"].stringValue
        self.website    = json["website"].stringValue
        self.categories = json["categories"].arrayValue.map({Category(json: $0)})
        self.visualUrl  = json["visualUrl"].string
        self.sortId     = json["sortid"].string
        self.updated    = json["updated"].int64
        self.added      = json["added"].int64
    }

    public init(feed: Feed, categories: [Category]) {
        self.id         = feed.id
        self.title      = feed.title
        self.categories = categories
    }

    public init(id: String, title: String, categories: [Category]) {
        self.id         = id
        self.title      = title
        self.categories = categories
    }

    func toParameters() -> [String : AnyObject] {
        return [
                 "title": title,
                    "id": id,
            "categories": categories.map( { $0.toParameters() })
            ]
    }
}
{'fraction_non_alphanumeric': 0.10406922357343311, 'fraction_numerical': 0.009822263797942002, 'mean_word_length': 2.007735583684951, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1747635', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1117, 'n_words': 301}