namespace OpenAuth.WebApi;

public class CommonTopicRequest<T>
{
    /**
     * The command is sent and the response is matched by the tid and bid fields in the message,
     * and the reply should keep the tid and bid the same.
     */
    public string tid { get; set; }

    public string bid { get; set; }

    public long? timestamp { get; set; }

    public T data { get; set; }

    public override string ToString()
    {
        return $"CommonTopicRequest{{tid='{tid}', bid='{bid}', timestamp={timestamp}, data={data}}}";
    }

    public CommonTopicRequest<T> SetTid(string tid)
    {
        this.tid = tid;
        return this;
    }

    public CommonTopicRequest<T> SetBid(string bid)
    {
        this.bid = bid;
        return this;
    }

    public CommonTopicRequest<T> SetTimestamp(long? timestamp)
    {
        this.timestamp = timestamp;
        return this;
    }

    public CommonTopicRequest<T> SetData(T data)
    {
        this.data = data;
        return this;
    }
}

public class OsdTopicRequest<T> : CommonTopicRequest<T>
{
    public string method { get; set; }


    public OsdTopicRequest<T> SetTid(string tid)
    {
        base.tid = tid;
        return this;
    }

    public OsdTopicRequest<T> SetBid(string bid)
    {
        base.bid = bid;
        return this;
    }

    public OsdTopicRequest<T> SetTimestamp(long? timestamp)
    {
        base.timestamp = timestamp;
        return this;
    }

    public OsdTopicRequest<T> SetData(T data)
    {
        base.data = data;
        return this;
    }

    public OsdTopicRequest<T> SetMethod(string method)
    {
        this.method = method;
        return this;
    }
}