package com.petshop.backend.dto.refund;

import com.petshop.backend.dto.sale.SaleItemRequest;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;

public class RefundRequest {
    @NotNull(message = "Sale ID is required")
    private Long saleId;

    @NotBlank(message = "Reason is required")
    private String reason;

    @NotEmpty(message = "At least one item is required")
    @Valid
    private List<SaleItemRequest> items;

    public Long getSaleId() {
        return saleId;
    }

    public void setSaleId(Long saleId) {
        this.saleId = saleId;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public List<SaleItemRequest> getItems() {
        return items;
    }

    public void setItems(List<SaleItemRequest> items) {
        this.items = items;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RefundRequest that = (RefundRequest) o;
        return Objects.equals(saleId, that.saleId) &&
                Objects.equals(reason, that.reason) &&
                Objects.equals(items, that.items);
    }

    @Override
    public int hashCode() {
        return Objects.hash(saleId, reason, items);
    }

    @Override
    public String toString() {
        return "RefundRequest{" +
                "saleId=" + saleId +
                ", reason='" + reason + '\'' +
                ", items=" + items +
                '}';
    }
}
