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

import Foundation

/// Datatypes and serializers for the users_common namespace
open class UsersCommon {
    /// What type of account this user has.
    public enum AccountType: CustomStringConvertible {
        /// The basic account type.
        case basic
        /// The Dropbox Pro account type.
        case pro
        /// The Dropbox Business account type.
        case business

        public var description: String {
            return "\(SerializeUtil.prepareJSONForSerialization(AccountTypeSerializer().serialize(self)))"
        }
    }
    open class AccountTypeSerializer: JSONSerializer {
        public init() { }
        open func serialize(_ value: AccountType) -> JSON {
            switch value {
                case .basic:
                    var d = [String: JSON]()
                    d[".tag"] = .str("basic")
                    return .dictionary(d)
                case .pro:
                    var d = [String: JSON]()
                    d[".tag"] = .str("pro")
                    return .dictionary(d)
                case .business:
                    var d = [String: JSON]()
                    d[".tag"] = .str("business")
                    return .dictionary(d)
            }
        }
        open func deserialize(_ json: JSON) -> AccountType {
            switch json {
                case .dictionary(let d):
                    let tag = Serialization.getTag(d)
                    switch tag {
                        case "basic":
                            return AccountType.basic
                        case "pro":
                            return AccountType.pro
                        case "business":
                            return AccountType.business
                        default:
                            fatalError("Unknown tag \(tag)")
                    }
                default:
                    fatalError("Failed to deserialize")
            }
        }
    }

}
