//
// Generated by SwagGen
// https://github.com/yonaskolb/SwagGen
//

import Foundation
import JSONUtilities

public class ProfileSummary: JSONDecodable, JSONEncodable, PrettyPrintable {

    /** The id of the profile. */
    public var id: String

    /** The unique name of the profile. */
    public var name: String

    /** Whether the profile is active or not.

**DEPRECATED** - Always true. Inactive profiles are no longer returned.
 */
    public var isActive: Bool

    /** Whether a pin is required to enter the profile. */
    public var pinEnabled: Bool

    /** Whether the profile can make purchases with the account payment options. */
    public var purchaseEnabled: Bool

    /** Whether the profile has opted in or out of marketing material.

**DEPRECATED** - Marketing material is no longer tied to profiles, only account. See `Account.marketingEnabled`.
 */
    public var marketingEnabled: Bool

    /** The segments a profile has been placed under */
    public var segments: [String]

    /** The maximum rating (inclusive) of content to return in feeds.

**DEPRECATED** - It's no longer recommended filtering content globally as apps can end up
with pages without content, even the homepage. Instead using features like segmentation
tags to target demographics like kids means content curation can be more thought out.
 */
    public var maxRatingContentFilter: ClassificationSummary?

    /** The minumum rating (inclusive) of content where an account pin should be presented before entring playback.

**DEPRECATED** - The playback guard is now defined at the account level, where an account
pin also exists. This is then applied across all profiles.
 */
    public var minRatingPlaybackGuard: ClassificationSummary?

    public init(id: String, name: String, isActive: Bool, pinEnabled: Bool, purchaseEnabled: Bool, marketingEnabled: Bool, segments: [String], maxRatingContentFilter: ClassificationSummary? = nil, minRatingPlaybackGuard: ClassificationSummary? = nil) {
        self.id = id
        self.name = name
        self.isActive = isActive
        self.pinEnabled = pinEnabled
        self.purchaseEnabled = purchaseEnabled
        self.marketingEnabled = marketingEnabled
        self.segments = segments
        self.maxRatingContentFilter = maxRatingContentFilter
        self.minRatingPlaybackGuard = minRatingPlaybackGuard
    }

    public required init(jsonDictionary: JSONDictionary) throws {
        id = try jsonDictionary.json(atKeyPath: "id")
        name = try jsonDictionary.json(atKeyPath: "name")
        isActive = try jsonDictionary.json(atKeyPath: "isActive")
        pinEnabled = try jsonDictionary.json(atKeyPath: "pinEnabled")
        purchaseEnabled = try jsonDictionary.json(atKeyPath: "purchaseEnabled")
        marketingEnabled = try jsonDictionary.json(atKeyPath: "marketingEnabled")
        segments = try jsonDictionary.json(atKeyPath: "segments")
        maxRatingContentFilter = jsonDictionary.json(atKeyPath: "maxRatingContentFilter")
        minRatingPlaybackGuard = jsonDictionary.json(atKeyPath: "minRatingPlaybackGuard")
    }

    public func encode() -> JSONDictionary {
        var dictionary: JSONDictionary = [:]
        dictionary["id"] = id
        dictionary["name"] = name
        dictionary["isActive"] = isActive
        dictionary["pinEnabled"] = pinEnabled
        dictionary["purchaseEnabled"] = purchaseEnabled
        dictionary["marketingEnabled"] = marketingEnabled
        dictionary["segments"] = segments
        if let maxRatingContentFilter = maxRatingContentFilter?.encode() {
            dictionary["maxRatingContentFilter"] = maxRatingContentFilter
        }
        if let minRatingPlaybackGuard = minRatingPlaybackGuard?.encode() {
            dictionary["minRatingPlaybackGuard"] = minRatingPlaybackGuard
        }
        return dictionary
    }

    /// pretty prints all properties including nested models
    public var prettyPrinted: String {
        return "\(type(of: self)):\n\(encode().recursivePrint(indentIndex: 1))"
    }
}
