package ru.nbch.credit_tracker.entities.external_response.online_download;

import jakarta.xml.bind.annotation.*;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Setter
@Getter
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
        "signals"
})
public class Inquiry {

    @XmlAttribute(name = "own", required = true)
    protected String own;
    @XmlAttribute(name = "inq_p", required = true)
    protected Integer inqP;
    @XmlAttribute(name = "currency", required = true)
    protected String currency;
    @XmlAttribute(name = "serial_num", required = true)
    protected String serialNum;
    @XmlAttribute(name = "date", required = true)
    protected String date;
    @XmlAttribute(name = "bus_category", required = true)
    protected String busCategory;
    @XmlAttribute(name = "inq_t", required = true)
    protected String inqT;
    @XmlAttribute(name = "channel", required = true)
    protected String channel;

    @XmlElement(name = "Signal", required = true)
    protected List<Signal> signals;

    public List<Signal> getSignals() {
        if (signals == null) {
            signals = new ArrayList<>();
        }
        return this.signals;
    }

    private Signal currentSignal;

    public void createCurrentSignal() {
        currentSignal = new Signal();
    }

    public Signal getCurrentSignal() {
        return currentSignal;
    }

    public void finalizeSignal() {
        getSignals().add(currentSignal);
    }

}
