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

import Foundation

public final class EstimatedOrderItemModel: Codable, Equatable {

    /** 商品 */
    public var product: ProductModel?

    /** 商品金額 */
    public var productAmount: Double?

    /** 購入数 */
    public var quantity: Int?

    public init(product: ProductModel? = nil, productAmount: Double? = nil, quantity: Int? = nil) {
        self.product = product
        self.productAmount = productAmount
        self.quantity = quantity
    }

    private enum CodingKeys: String, CodingKey {
        case product
        case productAmount
        case quantity
    }

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

        product = try container.decodeIfPresent(.product)
        productAmount = try container.decodeIfPresent(.productAmount)
        quantity = try container.decodeIfPresent(.quantity)
    }

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

        try container.encodeIfPresent(product, forKey: .product)
        try container.encodeIfPresent(productAmount, forKey: .productAmount)
        try container.encodeIfPresent(quantity, forKey: .quantity)
    }

    public func isEqual(to object: Any?) -> Bool {
      guard let object = object as? EstimatedOrderItemModel else { return false }
      guard self.product == object.product else { return false }
      guard self.productAmount == object.productAmount else { return false }
      guard self.quantity == object.quantity else { return false }
      return true
    }

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