package com.dexorder.flink.ingestor;

/**
 * Represents a data request message to be sent to ingestors.
 * This is a simplified wrapper until we generate the actual protobuf classes.
 */
public class DataRequestMessage {
    private final String requestId;
    private final RequestType requestType;
    private final String ticker;
    private final HistoricalParams historicalParams;
    private final RealtimeParams realtimeParams;

    public enum RequestType {
        HISTORICAL_OHLC,
        REALTIME_TICKS
    }

    public DataRequestMessage(String requestId, RequestType requestType, String ticker,
                            HistoricalParams historicalParams, RealtimeParams realtimeParams) {
        this.requestId = requestId;
        this.requestType = requestType;
        this.ticker = ticker;
        this.historicalParams = historicalParams;
        this.realtimeParams = realtimeParams;
    }

    public String getRequestId() {
        return requestId;
    }

    public RequestType getRequestType() {
        return requestType;
    }

    public String getTicker() {
        return ticker;
    }

    public HistoricalParams getHistoricalParams() {
        return historicalParams;
    }

    public RealtimeParams getRealtimeParams() {
        return realtimeParams;
    }

    /**
     * Serialize to protobuf bytes.
     * TODO: Replace with actual generated protobuf serialization
     */
    public byte[] toProtobuf() {
        // For now, return a placeholder
        // This will be replaced with actual protobuf serialization once we compile the .proto files
        return new byte[0];
    }

    public static class HistoricalParams {
        private final long startTime;
        private final long endTime;
        private final int periodSeconds;
        private final Integer limit;

        public HistoricalParams(long startTime, long endTime, int periodSeconds, Integer limit) {
            this.startTime = startTime;
            this.endTime = endTime;
            this.periodSeconds = periodSeconds;
            this.limit = limit;
        }

        public long getStartTime() {
            return startTime;
        }

        public long getEndTime() {
            return endTime;
        }

        public int getPeriodSeconds() {
            return periodSeconds;
        }

        public Integer getLimit() {
            return limit;
        }
    }

    public static class RealtimeParams {
        private final boolean includeTicks;
        private final boolean includeOhlc;
        private final int[] ohlcPeriodSeconds;

        public RealtimeParams(boolean includeTicks, boolean includeOhlc, int[] ohlcPeriodSeconds) {
            this.includeTicks = includeTicks;
            this.includeOhlc = includeOhlc;
            this.ohlcPeriodSeconds = ohlcPeriodSeconds;
        }

        public boolean isIncludeTicks() {
            return includeTicks;
        }

        public boolean isIncludeOhlc() {
            return includeOhlc;
        }

        public int[] getOhlcPeriodSeconds() {
            return ohlcPeriodSeconds;
        }
    }
}
