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

import Foundation

public class ItemScheduleList: APIModel {

    /** The id of the channel the schedules belong to. */
    public var channelId: String

    /** The date and time this list of schedules starts. */
    public var startDate: DateTime

    /** The date and time this list of schedules ends. */
    public var endDate: DateTime

    /** The list of item schedules. */
    public var schedules: [ItemSchedule]

    public init(channelId: String, startDate: DateTime, endDate: DateTime, schedules: [ItemSchedule]) {
        self.channelId = channelId
        self.startDate = startDate
        self.endDate = endDate
        self.schedules = schedules
    }

    public required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: StringCodingKey.self)

        channelId = try container.decode("channelId")
        startDate = try container.decode("startDate")
        endDate = try container.decode("endDate")
        schedules = try container.decodeArray("schedules")
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: StringCodingKey.self)

        try container.encode(channelId, forKey: "channelId")
        try container.encode(startDate, forKey: "startDate")
        try container.encode(endDate, forKey: "endDate")
        try container.encode(schedules, forKey: "schedules")
    }

    public func isEqual(to object: Any?) -> Bool {
      guard let object = object as? ItemScheduleList else { return false }
      guard self.channelId == object.channelId else { return false }
      guard self.startDate == object.startDate else { return false }
      guard self.endDate == object.endDate else { return false }
      guard self.schedules == object.schedules else { return false }
      return true
    }

    public static func == (lhs: ItemScheduleList, rhs: ItemScheduleList) -> Bool {
        return lhs.isEqual(to: rhs)
    }
}
