// Generated by Create API
// https://github.com/CreateAPI/CreateAPI

import Foundation

public struct ExperimentSchema: Codable {
    public var config: [String: ConfigItem]?
    public var data: [String: AnyJSON]?
    public var userExposure: Bool

    public struct ConfigItem: Codable {
        public var int: Int?
        public var double: Double?
        public var string: String?
        public var bool: Bool?

        public init(int: Int? = nil, double: Double? = nil, string: String? = nil, bool: Bool? = nil) {
            self.int = int
            self.double = double
            self.string = string
            self.bool = bool
        }

        public init(from decoder: Decoder) throws {
            let container = try decoder.singleValueContainer()
            self.int = try? container.decode(Int.self)
            self.double = try? container.decode(Double.self)
            self.string = try? container.decode(String.self)
            self.bool = try? container.decode(Bool.self)
        }

        public func encode(to encoder: Encoder) throws {
            var container = encoder.singleValueContainer()
            if let value = int { try container.encode(value) }
            if let value = double { try container.encode(value) }
            if let value = string { try container.encode(value) }
            if let value = bool { try container.encode(value) }
        }
    }

    public init(config: [String: ConfigItem]? = nil, data: [String: AnyJSON]? = nil, userExposure: Bool) {
        self.config = config
        self.data = data
        self.userExposure = userExposure
    }
}
