///
/// Copyright (c) 2016 Dropbox, Inc. All rights reserved.
///
/// Auto-generated by Stone, do not modify.
///

import Foundation

/// Datatypes and serializers for the seen_state namespace
open class SeenState {
    /// Possible platforms on which a user may view content.
    public enum PlatformType: CustomStringConvertible {
        /// The content was viewed on the web.
        case web
        /// The content was viewed on a mobile client.
        case mobile
        /// The content was viewed on a desktop client.
        case desktop
        /// The content was viewed on an unknown platform.
        case unknown
        /// An unspecified error.
        case other

        public var description: String {
            return "\(SerializeUtil.prepareJSONForSerialization(PlatformTypeSerializer().serialize(self)))"
        }
    }
    open class PlatformTypeSerializer: JSONSerializer {
        public init() { }
        open func serialize(_ value: PlatformType) -> JSON {
            switch value {
                case .web:
                    var d = [String: JSON]()
                    d[".tag"] = .str("web")
                    return .dictionary(d)
                case .mobile:
                    var d = [String: JSON]()
                    d[".tag"] = .str("mobile")
                    return .dictionary(d)
                case .desktop:
                    var d = [String: JSON]()
                    d[".tag"] = .str("desktop")
                    return .dictionary(d)
                case .unknown:
                    var d = [String: JSON]()
                    d[".tag"] = .str("unknown")
                    return .dictionary(d)
                case .other:
                    var d = [String: JSON]()
                    d[".tag"] = .str("other")
                    return .dictionary(d)
            }
        }
        open func deserialize(_ json: JSON) -> PlatformType {
            switch json {
                case .dictionary(let d):
                    let tag = Serialization.getTag(d)
                    switch tag {
                        case "web":
                            return PlatformType.web
                        case "mobile":
                            return PlatformType.mobile
                        case "desktop":
                            return PlatformType.desktop
                        case "unknown":
                            return PlatformType.unknown
                        case "other":
                            return PlatformType.other
                        default:
                            return PlatformType.other
                    }
                default:
                    fatalError("Failed to deserialize")
            }
        }
    }

}
