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

import Foundation

public class UserRating: APIModel {

    /** The id of the item rated. */
    public var itemId: String

    /** The rating out of 10 */
    public var rating: Int

    public init(itemId: String, rating: Int) {
        self.itemId = itemId
        self.rating = rating
    }

    private enum CodingKeys: String, CodingKey {
        case itemId
        case rating
    }

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

        itemId = try container.decode(.itemId)
        rating = try container.decode(.rating)
    }

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

        try container.encode(itemId, forKey: .itemId)
        try container.encode(rating, forKey: .rating)
    }

    public func isEqual(to object: Any?) -> Bool {
      guard let object = object as? UserRating else { return false }
      guard self.itemId == object.itemId else { return false }
      guard self.rating == object.rating else { return false }
      return true
    }

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