// Models.swift
//
// Generated by swagger-codegen
// https://github.com/swagger-api/swagger-codegen
//

import Foundation

protocol JSONEncodable {
    func encodeToJSON() -> Any
}

public enum ErrorResponse : Error {
    case HttpError(statusCode: Int, data: Data?, error: Error)
    case DecodeError(response: Data?, decodeError: DecodeError)
}

open class Response<T> {
    open let statusCode: Int
    open let header: [String: String]
    open let body: T?

    public init(statusCode: Int, header: [String: String], body: T?) {
        self.statusCode = statusCode
        self.header = header
        self.body = body
    }

    public convenience init(response: HTTPURLResponse, body: T?) {
        let rawHeader = response.allHeaderFields
        var header = [String:String]()
        for (key, value) in rawHeader {
            header[key as! String] = value as? String
        }
        self.init(statusCode: response.statusCode, header: header, body: body)
    }
}

public enum Decoded<ValueType> {
    case success(ValueType)
    case failure(DecodeError)
}

public extension Decoded {
    var value: ValueType? {
        switch self {
        case let .success(value):
            return value
        case .failure:
            return nil
        }
    }
}

public enum DecodeError {
    case typeMismatch(expected: String, actual: String)
    case missingKey(key: String)
    case parseError(message: String)
}

private var once = Int()
class Decoders {
    static fileprivate var decoders = Dictionary<String, ((AnyObject, AnyObject?) -> AnyObject)>()

    static func addDecoder<T>(clazz: T.Type, decoder: @escaping ((AnyObject, AnyObject?) -> Decoded<T>)) {
        let key = "\(T.self)"
        decoders[key] = { decoder($0, $1) as AnyObject }
    }

    static func decode<T>(clazz: T.Type, discriminator: String, source: AnyObject) -> Decoded<T> {
        let key = discriminator
        if let decoder = decoders[key], let value = decoder(source, nil) as? Decoded<T> {
            return value
        } else {
            return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source)))
        }
    }

    static func decode<T>(clazz: [T].Type, source: AnyObject) -> Decoded<[T]> {
        if let sourceArray = source as? [AnyObject] {
            var values = [T]()
            for sourceValue in sourceArray {
                switch Decoders.decode(clazz: T.self, source: sourceValue, instance: nil) {
                case let .success(value):
                    values.append(value)
                case let .failure(error):
                    return .failure(error)
                }
            }
            return .success(values)
        } else {
            return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source)))
        }
    }

    static func decode<T, Key: Hashable>(clazz: [Key:T].Type, source: AnyObject) -> Decoded<[Key:T]> {
        if let sourceDictionary = source as? [Key: AnyObject] {
            var dictionary = [Key:T]()
            for (key, value) in sourceDictionary {
                switch Decoders.decode(clazz: T.self, source: value, instance: nil) {
                case let .success(value):
                    dictionary[key] = value
                case let .failure(error):
                    return .failure(error)
                }
            }
            return .success(dictionary)
        } else {
            return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source)))
        }
    }

    static func decodeOptional<T: RawRepresentable>(clazz: T.Type, source: AnyObject?) -> Decoded<T?> {
        guard !(source is NSNull), source != nil else { return .success(nil) }
        if let value = source as? T.RawValue {
            if let enumValue = T.init(rawValue: value) {
                return .success(enumValue)
            } else {
                return .failure(.typeMismatch(expected: "A value from the enumeration \(T.self)", actual: "\(value)"))
            }
        } else {
            return .failure(.typeMismatch(expected: "\(T.RawValue.self) matching a case from the enumeration \(T.self)", actual: String(describing: type(of: source))))
        }
    }

    static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> Decoded<T> {
        initialize()
        if let value = source.int32Value as? T, source is NSNumber, T.self is Int32.Type {
            return .success(value)
        }
        if let value = source.int32Value as? T, source is NSNumber, T.self is Int64.Type {
            return .success(value)
        }
        if let intermediate = source as? String, let value = UUID(uuidString: intermediate) as? T, source is String, T.self is UUID.Type {
            return .success(value)
        }
        if let value = source as? T {
            return .success(value)
        }
        if let intermediate = source as? String, let value = Data(base64Encoded: intermediate) as? T {
            return .success(value)
        }

        let key = "\(T.self)"
        if let decoder = decoders[key], let value = decoder(source, instance) as? Decoded<T> {
           return value
        } else {
            return .failure(.typeMismatch(expected: String(describing: clazz), actual: String(describing: source)))
        }
    }

    //Convert a Decoded so that its value is optional. DO WE STILL NEED THIS?
    static func toOptional<T>(decoded: Decoded<T>) -> Decoded<T?> {
        return .success(decoded.value)
    }

    static func decodeOptional<T>(clazz: T.Type, source: AnyObject?) -> Decoded<T?> {
        if let source = source, !(source is NSNull) {
            switch Decoders.decode(clazz: clazz, source: source, instance: nil) {
            case let .success(value): return .success(value)
            case let .failure(error): return .failure(error)
            }
        } else {
            return .success(nil)
        }
    }

    static func decodeOptional<T>(clazz: [T].Type, source: AnyObject?) -> Decoded<[T]?> {
        if let source = source as? [AnyObject] {
            var values = [T]()
            for sourceValue in source {
                switch Decoders.decode(clazz: T.self, source: sourceValue, instance: nil) {
                case let .success(value): values.append(value)
                case let .failure(error): return .failure(error)
                }
            }
            return .success(values)
        } else {
            return .success(nil)
        }
    }

    static func decodeOptional<T, Key: Hashable>(clazz: [Key:T].Type, source: AnyObject?) -> Decoded<[Key:T]?> {
        if let sourceDictionary = source as? [Key: AnyObject] {
            var dictionary = [Key:T]()
            for (key, value) in sourceDictionary {
                switch Decoders.decode(clazz: T.self, source: value, instance: nil) {
                case let .success(value): dictionary[key] = value
                case let .failure(error): return .failure(error)
                }
            }
            return .success(dictionary)
        } else {
            return .success(nil)
        }
    }

    static func decodeOptional<T: RawRepresentable, U: AnyObject where T.RawValue == U>(clazz: T, source: AnyObject) -> Decoded<T?> {
        if let value = source as? U {
            if let enumValue = T.init(rawValue: value) {
                return .success(enumValue)
            } else {
                return .failure(.typeMismatch(expected: "A value from the enumeration \(T.self)", actual: "\(value)"))
            }
        } else {
            return .failure(.typeMismatch(expected: "String", actual: String(describing: type(of: source))))
        }
    }


    private static var __once: () = {
        let formatters = [
            "yyyy-MM-dd",
            "yyyy-MM-dd'T'HH:mm:ssZZZZZ",
            "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ",
            "yyyy-MM-dd'T'HH:mm:ss'Z'",
            "yyyy-MM-dd'T'HH:mm:ss.SSS",
            "yyyy-MM-dd HH:mm:ss"
        ].map { (format: String) -> DateFormatter in
            let formatter = DateFormatter()
            formatter.locale = Locale(identifier: "en_US_POSIX")
            formatter.dateFormat = format
            return formatter
        }
        // Decoder for Date
        Decoders.addDecoder(clazz: Date.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Date> in
           if let sourceString = source as? String {
                for formatter in formatters {
                    if let date = formatter.date(from: sourceString) {
                        return .success(date)
                    }
                }
            }
            if let sourceInt = source as? Int {
                // treat as a java date
                return .success(Date(timeIntervalSince1970: Double(sourceInt / 1000) ))
            }
            if source is String || source is Int {
                return .failure(.parseError(message: "Could not decode date"))
            } else {
                return .failure(.typeMismatch(expected: "String or Int", actual: "\(source)"))
            }
        }

        // Decoder for ISOFullDate
        Decoders.addDecoder(clazz: ISOFullDate.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ISOFullDate> in
            if let string = source as? String,
               let isoDate = ISOFullDate.from(string: string) {
                return .success(isoDate)
            } else {
            	return .failure(.typeMismatch(expected: "ISO date", actual: "\(source)"))
            }
        }

        // Decoder for ActivityView
        Decoders.addDecoder(clazz: ActivityView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ActivityView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? ActivityView() : instance as! ActivityView
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["activityHandle"] as AnyObject?) {
                
                case let .success(value): result.activityHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["createdTime"] as AnyObject?) {
                
                case let .success(value): result.createdTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: ActivityView.ActivityType.self, source: sourceDictionary["activityType"] as AnyObject?) {
                
                case let .success(value): result.activityType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: [UserCompactView].self, source: sourceDictionary["actorUsers"] as AnyObject?) {
                
                case let .success(value): result.actorUsers = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserCompactView.self, source: sourceDictionary["actedOnUser"] as AnyObject?) {
                
                case let .success(value): result.actedOnUser = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: ContentCompactView.self, source: sourceDictionary["actedOnContent"] as AnyObject?) {
                
                case let .success(value): result.actedOnContent = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["totalActions"] as AnyObject?) {
                
                case let .success(value): result.totalActions = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["unread"] as AnyObject?) {
                
                case let .success(value): result.unread = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: AppCompactView.self, source: sourceDictionary["app"] as AnyObject?) {
                
                case let .success(value): result.app = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "ActivityView", actual: "\(source)"))
            }
        }
        // Decoder for AppCompactView
        Decoders.addDecoder(clazz: AppCompactView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<AppCompactView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? AppCompactView() : instance as! AppCompactView
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) {
                
                case let .success(value): result.name = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["iconHandle"] as AnyObject?) {
                
                case let .success(value): result.iconHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["iconUrl"] as AnyObject?) {
                
                case let .success(value): result.iconUrl = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: AppCompactView.PlatformType.self, source: sourceDictionary["platformType"] as AnyObject?) {
                
                case let .success(value): result.platformType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["deepLink"] as AnyObject?) {
                
                case let .success(value): result.deepLink = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["storeLink"] as AnyObject?) {
                
                case let .success(value): result.storeLink = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "AppCompactView", actual: "\(source)"))
            }
        }
        // Decoder for BuildsCurrentResponse
        Decoders.addDecoder(clazz: BuildsCurrentResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<BuildsCurrentResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? BuildsCurrentResponse() : instance as! BuildsCurrentResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["dateAndTime"] as AnyObject?) {
                
                case let .success(value): result.dateAndTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["commitHash"] as AnyObject?) {
                
                case let .success(value): result.commitHash = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["hostname"] as AnyObject?) {
                
                case let .success(value): result.hostname = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["serviceApiVersion"] as AnyObject?) {
                
                case let .success(value): result.serviceApiVersion = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: [String].self, source: sourceDictionary["dirtyFiles"] as AnyObject?) {
                
                case let .success(value): result.dirtyFiles = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "BuildsCurrentResponse", actual: "\(source)"))
            }
        }
        // Decoder for CommentView
        Decoders.addDecoder(clazz: CommentView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<CommentView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? CommentView() : instance as! CommentView
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["commentHandle"] as AnyObject?) {
                
                case let .success(value): result.commentHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["createdTime"] as AnyObject?) {
                
                case let .success(value): result.createdTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["lastUpdatedTime"] as AnyObject?) {
                
                case let .success(value): result.lastUpdatedTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserCompactView.self, source: sourceDictionary["user"] as AnyObject?) {
                
                case let .success(value): result.user = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["text"] as AnyObject?) {
                
                case let .success(value): result.text = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: CommentView.BlobType.self, source: sourceDictionary["blobType"] as AnyObject?) {
                
                case let .success(value): result.blobType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobHandle"] as AnyObject?) {
                
                case let .success(value): result.blobHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobUrl"] as AnyObject?) {
                
                case let .success(value): result.blobUrl = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["language"] as AnyObject?) {
                
                case let .success(value): result.language = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["totalLikes"] as AnyObject?) {
                
                case let .success(value): result.totalLikes = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["totalReplies"] as AnyObject?) {
                
                case let .success(value): result.totalReplies = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["liked"] as AnyObject?) {
                
                case let .success(value): result.liked = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: CommentView.ContentStatus.self, source: sourceDictionary["contentStatus"] as AnyObject?) {
                
                case let .success(value): result.contentStatus = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "CommentView", actual: "\(source)"))
            }
        }
        // Decoder for ContentCompactView
        Decoders.addDecoder(clazz: ContentCompactView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ContentCompactView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? ContentCompactView() : instance as! ContentCompactView
                switch Decoders.decodeOptional(clazz: ContentCompactView.ContentType.self, source: sourceDictionary["contentType"] as AnyObject?) {
                
                case let .success(value): result.contentType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["contentHandle"] as AnyObject?) {
                
                case let .success(value): result.contentHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["parentHandle"] as AnyObject?) {
                
                case let .success(value): result.parentHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["rootHandle"] as AnyObject?) {
                
                case let .success(value): result.rootHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["text"] as AnyObject?) {
                
                case let .success(value): result.text = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: ContentCompactView.BlobType.self, source: sourceDictionary["blobType"] as AnyObject?) {
                
                case let .success(value): result.blobType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobHandle"] as AnyObject?) {
                
                case let .success(value): result.blobHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobUrl"] as AnyObject?) {
                
                case let .success(value): result.blobUrl = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "ContentCompactView", actual: "\(source)"))
            }
        }
        // Decoder for CountResponse
        Decoders.addDecoder(clazz: CountResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<CountResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? CountResponse() : instance as! CountResponse
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["count"] as AnyObject?) {
                
                case let .success(value): result.count = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "CountResponse", actual: "\(source)"))
            }
        }
        // Decoder for DeleteTopicNameRequest
        Decoders.addDecoder(clazz: DeleteTopicNameRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<DeleteTopicNameRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? DeleteTopicNameRequest() : instance as! DeleteTopicNameRequest
                switch Decoders.decodeOptional(clazz: DeleteTopicNameRequest.PublisherType.self, source: sourceDictionary["publisherType"] as AnyObject?) {
                
                case let .success(value): result.publisherType = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "DeleteTopicNameRequest", actual: "\(source)"))
            }
        }
        // Decoder for FeedResponseActivityView
        Decoders.addDecoder(clazz: FeedResponseActivityView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<FeedResponseActivityView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? FeedResponseActivityView() : instance as! FeedResponseActivityView
                switch Decoders.decodeOptional(clazz: [ActivityView].self, source: sourceDictionary["data"] as AnyObject?) {
                
                case let .success(value): result.data = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["cursor"] as AnyObject?) {
                
                case let .success(value): result.cursor = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "FeedResponseActivityView", actual: "\(source)"))
            }
        }
        // Decoder for FeedResponseCommentView
        Decoders.addDecoder(clazz: FeedResponseCommentView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<FeedResponseCommentView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? FeedResponseCommentView() : instance as! FeedResponseCommentView
                switch Decoders.decodeOptional(clazz: [CommentView].self, source: sourceDictionary["data"] as AnyObject?) {
                
                case let .success(value): result.data = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["cursor"] as AnyObject?) {
                
                case let .success(value): result.cursor = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "FeedResponseCommentView", actual: "\(source)"))
            }
        }
        // Decoder for FeedResponseReplyView
        Decoders.addDecoder(clazz: FeedResponseReplyView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<FeedResponseReplyView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? FeedResponseReplyView() : instance as! FeedResponseReplyView
                switch Decoders.decodeOptional(clazz: [ReplyView].self, source: sourceDictionary["data"] as AnyObject?) {
                
                case let .success(value): result.data = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["cursor"] as AnyObject?) {
                
                case let .success(value): result.cursor = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "FeedResponseReplyView", actual: "\(source)"))
            }
        }
        // Decoder for FeedResponseTopicView
        Decoders.addDecoder(clazz: FeedResponseTopicView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<FeedResponseTopicView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? FeedResponseTopicView() : instance as! FeedResponseTopicView
                switch Decoders.decodeOptional(clazz: [TopicView].self, source: sourceDictionary["data"] as AnyObject?) {
                
                case let .success(value): result.data = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["cursor"] as AnyObject?) {
                
                case let .success(value): result.cursor = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "FeedResponseTopicView", actual: "\(source)"))
            }
        }
        // Decoder for FeedResponseUserCompactView
        Decoders.addDecoder(clazz: FeedResponseUserCompactView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<FeedResponseUserCompactView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? FeedResponseUserCompactView() : instance as! FeedResponseUserCompactView
                switch Decoders.decodeOptional(clazz: [UserCompactView].self, source: sourceDictionary["data"] as AnyObject?) {
                
                case let .success(value): result.data = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["cursor"] as AnyObject?) {
                
                case let .success(value): result.cursor = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "FeedResponseUserCompactView", actual: "\(source)"))
            }
        }
        // Decoder for FeedResponseUserProfileView
        Decoders.addDecoder(clazz: FeedResponseUserProfileView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<FeedResponseUserProfileView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? FeedResponseUserProfileView() : instance as! FeedResponseUserProfileView
                switch Decoders.decodeOptional(clazz: [UserProfileView].self, source: sourceDictionary["data"] as AnyObject?) {
                
                case let .success(value): result.data = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["cursor"] as AnyObject?) {
                
                case let .success(value): result.cursor = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "FeedResponseUserProfileView", actual: "\(source)"))
            }
        }
        // Decoder for GetRequestTokenResponse
        Decoders.addDecoder(clazz: GetRequestTokenResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<GetRequestTokenResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? GetRequestTokenResponse() : instance as! GetRequestTokenResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["requestToken"] as AnyObject?) {
                
                case let .success(value): result.requestToken = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "GetRequestTokenResponse", actual: "\(source)"))
            }
        }
        // Decoder for GetTopicByNameResponse
        Decoders.addDecoder(clazz: GetTopicByNameResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<GetTopicByNameResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? GetTopicByNameResponse() : instance as! GetTopicByNameResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "GetTopicByNameResponse", actual: "\(source)"))
            }
        }
        // Decoder for LinkedAccountView
        Decoders.addDecoder(clazz: LinkedAccountView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<LinkedAccountView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? LinkedAccountView() : instance as! LinkedAccountView
                switch Decoders.decodeOptional(clazz: LinkedAccountView.IdentityProvider.self, source: sourceDictionary["identityProvider"] as AnyObject?) {
                
                case let .success(value): result.identityProvider = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["accountId"] as AnyObject?) {
                
                case let .success(value): result.accountId = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "LinkedAccountView", actual: "\(source)"))
            }
        }
        // Decoder for Object
        Decoders.addDecoder(clazz: Object.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<Object> in
            if let source = source as? Any {
                return .success(source)
            } else {
                return .failure(.typeMismatch(expected: "Typealias Object", actual: "\(source)"))
            }
        }
        // Decoder for PostBlobResponse
        Decoders.addDecoder(clazz: PostBlobResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostBlobResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostBlobResponse() : instance as! PostBlobResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobHandle"] as AnyObject?) {
                
                case let .success(value): result.blobHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostBlobResponse", actual: "\(source)"))
            }
        }
        // Decoder for PostBlockedUserRequest
        Decoders.addDecoder(clazz: PostBlockedUserRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostBlockedUserRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostBlockedUserRequest() : instance as! PostBlockedUserRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["userHandle"] as AnyObject?) {
                
                case let .success(value): result.userHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostBlockedUserRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostCommentRequest
        Decoders.addDecoder(clazz: PostCommentRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostCommentRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostCommentRequest() : instance as! PostCommentRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["text"] as AnyObject?) {
                
                case let .success(value): result.text = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: PostCommentRequest.BlobType.self, source: sourceDictionary["blobType"] as AnyObject?) {
                
                case let .success(value): result.blobType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobHandle"] as AnyObject?) {
                
                case let .success(value): result.blobHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["language"] as AnyObject?) {
                
                case let .success(value): result.language = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostCommentRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostCommentResponse
        Decoders.addDecoder(clazz: PostCommentResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostCommentResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostCommentResponse() : instance as! PostCommentResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["commentHandle"] as AnyObject?) {
                
                case let .success(value): result.commentHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostCommentResponse", actual: "\(source)"))
            }
        }
        // Decoder for PostFollowerRequest
        Decoders.addDecoder(clazz: PostFollowerRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostFollowerRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostFollowerRequest() : instance as! PostFollowerRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["userHandle"] as AnyObject?) {
                
                case let .success(value): result.userHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostFollowerRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostFollowingTopicRequest
        Decoders.addDecoder(clazz: PostFollowingTopicRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostFollowingTopicRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostFollowingTopicRequest() : instance as! PostFollowingTopicRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostFollowingTopicRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostFollowingUserRequest
        Decoders.addDecoder(clazz: PostFollowingUserRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostFollowingUserRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostFollowingUserRequest() : instance as! PostFollowingUserRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["userHandle"] as AnyObject?) {
                
                case let .success(value): result.userHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostFollowingUserRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostImageResponse
        Decoders.addDecoder(clazz: PostImageResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostImageResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostImageResponse() : instance as! PostImageResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobHandle"] as AnyObject?) {
                
                case let .success(value): result.blobHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostImageResponse", actual: "\(source)"))
            }
        }
        // Decoder for PostLinkedAccountRequest
        Decoders.addDecoder(clazz: PostLinkedAccountRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostLinkedAccountRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostLinkedAccountRequest() : instance as! PostLinkedAccountRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["sessionToken"] as AnyObject?) {
                
                case let .success(value): result.sessionToken = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostLinkedAccountRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostPinRequest
        Decoders.addDecoder(clazz: PostPinRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostPinRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostPinRequest() : instance as! PostPinRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostPinRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostReplyRequest
        Decoders.addDecoder(clazz: PostReplyRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostReplyRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostReplyRequest() : instance as! PostReplyRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["text"] as AnyObject?) {
                
                case let .success(value): result.text = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["language"] as AnyObject?) {
                
                case let .success(value): result.language = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostReplyRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostReplyResponse
        Decoders.addDecoder(clazz: PostReplyResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostReplyResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostReplyResponse() : instance as! PostReplyResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["replyHandle"] as AnyObject?) {
                
                case let .success(value): result.replyHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostReplyResponse", actual: "\(source)"))
            }
        }
        // Decoder for PostReportRequest
        Decoders.addDecoder(clazz: PostReportRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostReportRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostReportRequest() : instance as! PostReportRequest
                switch Decoders.decodeOptional(clazz: PostReportRequest.Reason.self, source: sourceDictionary["reason"] as AnyObject?) {
                
                case let .success(value): result.reason = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostReportRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostSessionRequest
        Decoders.addDecoder(clazz: PostSessionRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostSessionRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostSessionRequest() : instance as! PostSessionRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["instanceId"] as AnyObject?) {
                
                case let .success(value): result.instanceId = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["userHandle"] as AnyObject?) {
                
                case let .success(value): result.userHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostSessionRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostSessionResponse
        Decoders.addDecoder(clazz: PostSessionResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostSessionResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostSessionResponse() : instance as! PostSessionResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["userHandle"] as AnyObject?) {
                
                case let .success(value): result.userHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["sessionToken"] as AnyObject?) {
                
                case let .success(value): result.sessionToken = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostSessionResponse", actual: "\(source)"))
            }
        }
        // Decoder for PostTopicNameRequest
        Decoders.addDecoder(clazz: PostTopicNameRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostTopicNameRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostTopicNameRequest() : instance as! PostTopicNameRequest
                switch Decoders.decodeOptional(clazz: PostTopicNameRequest.PublisherType.self, source: sourceDictionary["publisherType"] as AnyObject?) {
                
                case let .success(value): result.publisherType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicName"] as AnyObject?) {
                
                case let .success(value): result.topicName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostTopicNameRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostTopicRequest
        Decoders.addDecoder(clazz: PostTopicRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostTopicRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostTopicRequest() : instance as! PostTopicRequest
                switch Decoders.decodeOptional(clazz: PostTopicRequest.PublisherType.self, source: sourceDictionary["publisherType"] as AnyObject?) {
                
                case let .success(value): result.publisherType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["title"] as AnyObject?) {
                
                case let .success(value): result.title = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["text"] as AnyObject?) {
                
                case let .success(value): result.text = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: PostTopicRequest.BlobType.self, source: sourceDictionary["blobType"] as AnyObject?) {
                
                case let .success(value): result.blobType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobHandle"] as AnyObject?) {
                
                case let .success(value): result.blobHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["categories"] as AnyObject?) {
                
                case let .success(value): result.categories = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["language"] as AnyObject?) {
                
                case let .success(value): result.language = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["deepLink"] as AnyObject?) {
                
                case let .success(value): result.deepLink = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["friendlyName"] as AnyObject?) {
                
                case let .success(value): result.friendlyName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["group"] as AnyObject?) {
                
                case let .success(value): result.group = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostTopicRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostTopicResponse
        Decoders.addDecoder(clazz: PostTopicResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostTopicResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostTopicResponse() : instance as! PostTopicResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostTopicResponse", actual: "\(source)"))
            }
        }
        // Decoder for PostUserRequest
        Decoders.addDecoder(clazz: PostUserRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostUserRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostUserRequest() : instance as! PostUserRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["instanceId"] as AnyObject?) {
                
                case let .success(value): result.instanceId = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) {
                
                case let .success(value): result.firstName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) {
                
                case let .success(value): result.lastName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bio"] as AnyObject?) {
                
                case let .success(value): result.bio = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["photoHandle"] as AnyObject?) {
                
                case let .success(value): result.photoHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostUserRequest", actual: "\(source)"))
            }
        }
        // Decoder for PostUserResponse
        Decoders.addDecoder(clazz: PostUserResponse.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PostUserResponse> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PostUserResponse() : instance as! PostUserResponse
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["userHandle"] as AnyObject?) {
                
                case let .success(value): result.userHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["sessionToken"] as AnyObject?) {
                
                case let .success(value): result.sessionToken = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PostUserResponse", actual: "\(source)"))
            }
        }
        // Decoder for PutNotificationsStatusRequest
        Decoders.addDecoder(clazz: PutNotificationsStatusRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PutNotificationsStatusRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PutNotificationsStatusRequest() : instance as! PutNotificationsStatusRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["readActivityHandle"] as AnyObject?) {
                
                case let .success(value): result.readActivityHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PutNotificationsStatusRequest", actual: "\(source)"))
            }
        }
        // Decoder for PutPushRegistrationRequest
        Decoders.addDecoder(clazz: PutPushRegistrationRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PutPushRegistrationRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PutPushRegistrationRequest() : instance as! PutPushRegistrationRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastUpdatedTime"] as AnyObject?) {
                
                case let .success(value): result.lastUpdatedTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["language"] as AnyObject?) {
                
                case let .success(value): result.language = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PutPushRegistrationRequest", actual: "\(source)"))
            }
        }
        // Decoder for PutTopicNameRequest
        Decoders.addDecoder(clazz: PutTopicNameRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PutTopicNameRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PutTopicNameRequest() : instance as! PutTopicNameRequest
                switch Decoders.decodeOptional(clazz: PutTopicNameRequest.PublisherType.self, source: sourceDictionary["publisherType"] as AnyObject?) {
                
                case let .success(value): result.publisherType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PutTopicNameRequest", actual: "\(source)"))
            }
        }
        // Decoder for PutTopicRequest
        Decoders.addDecoder(clazz: PutTopicRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PutTopicRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PutTopicRequest() : instance as! PutTopicRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["title"] as AnyObject?) {
                
                case let .success(value): result.title = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["text"] as AnyObject?) {
                
                case let .success(value): result.text = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["categories"] as AnyObject?) {
                
                case let .success(value): result.categories = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PutTopicRequest", actual: "\(source)"))
            }
        }
        // Decoder for PutUserInfoRequest
        Decoders.addDecoder(clazz: PutUserInfoRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PutUserInfoRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PutUserInfoRequest() : instance as! PutUserInfoRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) {
                
                case let .success(value): result.firstName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) {
                
                case let .success(value): result.lastName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bio"] as AnyObject?) {
                
                case let .success(value): result.bio = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PutUserInfoRequest", actual: "\(source)"))
            }
        }
        // Decoder for PutUserPhotoRequest
        Decoders.addDecoder(clazz: PutUserPhotoRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PutUserPhotoRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PutUserPhotoRequest() : instance as! PutUserPhotoRequest
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["photoHandle"] as AnyObject?) {
                
                case let .success(value): result.photoHandle = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PutUserPhotoRequest", actual: "\(source)"))
            }
        }
        // Decoder for PutUserVisibilityRequest
        Decoders.addDecoder(clazz: PutUserVisibilityRequest.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<PutUserVisibilityRequest> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? PutUserVisibilityRequest() : instance as! PutUserVisibilityRequest
                switch Decoders.decodeOptional(clazz: PutUserVisibilityRequest.Visibility.self, source: sourceDictionary["visibility"] as AnyObject?) {
                
                case let .success(value): result.visibility = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "PutUserVisibilityRequest", actual: "\(source)"))
            }
        }
        // Decoder for ReplyView
        Decoders.addDecoder(clazz: ReplyView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<ReplyView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? ReplyView() : instance as! ReplyView
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["replyHandle"] as AnyObject?) {
                
                case let .success(value): result.replyHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["commentHandle"] as AnyObject?) {
                
                case let .success(value): result.commentHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["createdTime"] as AnyObject?) {
                
                case let .success(value): result.createdTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["lastUpdatedTime"] as AnyObject?) {
                
                case let .success(value): result.lastUpdatedTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserCompactView.self, source: sourceDictionary["user"] as AnyObject?) {
                
                case let .success(value): result.user = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["text"] as AnyObject?) {
                
                case let .success(value): result.text = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["language"] as AnyObject?) {
                
                case let .success(value): result.language = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["totalLikes"] as AnyObject?) {
                
                case let .success(value): result.totalLikes = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["liked"] as AnyObject?) {
                
                case let .success(value): result.liked = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: ReplyView.ContentStatus.self, source: sourceDictionary["contentStatus"] as AnyObject?) {
                
                case let .success(value): result.contentStatus = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "ReplyView", actual: "\(source)"))
            }
        }
        // Decoder for TopicView
        Decoders.addDecoder(clazz: TopicView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<TopicView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? TopicView() : instance as! TopicView
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["topicHandle"] as AnyObject?) {
                
                case let .success(value): result.topicHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["createdTime"] as AnyObject?) {
                
                case let .success(value): result.createdTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["lastUpdatedTime"] as AnyObject?) {
                
                case let .success(value): result.lastUpdatedTime = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: TopicView.PublisherType.self, source: sourceDictionary["publisherType"] as AnyObject?) {
                
                case let .success(value): result.publisherType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserCompactView.self, source: sourceDictionary["user"] as AnyObject?) {
                
                case let .success(value): result.user = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["title"] as AnyObject?) {
                
                case let .success(value): result.title = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["text"] as AnyObject?) {
                
                case let .success(value): result.text = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: TopicView.BlobType.self, source: sourceDictionary["blobType"] as AnyObject?) {
                
                case let .success(value): result.blobType = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobHandle"] as AnyObject?) {
                
                case let .success(value): result.blobHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["blobUrl"] as AnyObject?) {
                
                case let .success(value): result.blobUrl = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["categories"] as AnyObject?) {
                
                case let .success(value): result.categories = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["language"] as AnyObject?) {
                
                case let .success(value): result.language = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["group"] as AnyObject?) {
                
                case let .success(value): result.group = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["deepLink"] as AnyObject?) {
                
                case let .success(value): result.deepLink = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["friendlyName"] as AnyObject?) {
                
                case let .success(value): result.friendlyName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["totalLikes"] as AnyObject?) {
                
                case let .success(value): result.totalLikes = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["totalComments"] as AnyObject?) {
                
                case let .success(value): result.totalComments = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["liked"] as AnyObject?) {
                
                case let .success(value): result.liked = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["pinned"] as AnyObject?) {
                
                case let .success(value): result.pinned = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: TopicView.ContentStatus.self, source: sourceDictionary["contentStatus"] as AnyObject?) {
                
                case let .success(value): result.contentStatus = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: AppCompactView.self, source: sourceDictionary["app"] as AnyObject?) {
                
                case let .success(value): result.app = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "TopicView", actual: "\(source)"))
            }
        }
        // Decoder for UserCompactView
        Decoders.addDecoder(clazz: UserCompactView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<UserCompactView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? UserCompactView() : instance as! UserCompactView
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["userHandle"] as AnyObject?) {
                
                case let .success(value): result.userHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) {
                
                case let .success(value): result.firstName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) {
                
                case let .success(value): result.lastName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["photoHandle"] as AnyObject?) {
                
                case let .success(value): result.photoHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["photoUrl"] as AnyObject?) {
                
                case let .success(value): result.photoUrl = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserCompactView.Visibility.self, source: sourceDictionary["visibility"] as AnyObject?) {
                
                case let .success(value): result.visibility = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserCompactView.FollowerStatus.self, source: sourceDictionary["followerStatus"] as AnyObject?) {
                
                case let .success(value): result.followerStatus = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "UserCompactView", actual: "\(source)"))
            }
        }
        // Decoder for UserProfileView
        Decoders.addDecoder(clazz: UserProfileView.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<UserProfileView> in
            if let sourceDictionary = source as? [AnyHashable: Any] {
                let result = instance == nil ? UserProfileView() : instance as! UserProfileView
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["userHandle"] as AnyObject?) {
                
                case let .success(value): result.userHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) {
                
                case let .success(value): result.firstName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) {
                
                case let .success(value): result.lastName = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bio"] as AnyObject?) {
                
                case let .success(value): result.bio = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["photoHandle"] as AnyObject?) {
                
                case let .success(value): result.photoHandle = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["photoUrl"] as AnyObject?) {
                
                case let .success(value): result.photoUrl = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserProfileView.Visibility.self, source: sourceDictionary["visibility"] as AnyObject?) {
                
                case let .success(value): result.visibility = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["totalTopics"] as AnyObject?) {
                
                case let .success(value): result.totalTopics = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["totalFollowers"] as AnyObject?) {
                
                case let .success(value): result.totalFollowers = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["totalFollowing"] as AnyObject?) {
                
                case let .success(value): result.totalFollowing = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserProfileView.FollowerStatus.self, source: sourceDictionary["followerStatus"] as AnyObject?) {
                
                case let .success(value): result.followerStatus = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserProfileView.FollowingStatus.self, source: sourceDictionary["followingStatus"] as AnyObject?) {
                
                case let .success(value): result.followingStatus = value
                case let .failure(error): return .failure(error)
                
                }
                switch Decoders.decodeOptional(clazz: UserProfileView.ProfileStatus.self, source: sourceDictionary["profileStatus"] as AnyObject?) {
                
                case let .success(value): result.profileStatus = value
                case let .failure(error): return .failure(error)
                
                }
                return .success(result)
            } else {
                return .failure(.typeMismatch(expected: "UserProfileView", actual: "\(source)"))
            }
        }
    }()

    static fileprivate func initialize() {
        _ = Decoders.__once
    }
}
