import {ArduinoProxyPayloadType} from "./ArduinoProxyPayloadType";
import {ArduinoProxy} from "./ArduinoProxy";

export class ArduinoProxyPayload {
    set id(value: string) {
        this._id = value;
    }

    private readonly _type: ArduinoProxyPayloadType;
    private readonly _data: any;

    private _id: string ="";


    constructor(type: ArduinoProxyPayloadType, data: { pin?: number, value?: number|"HIGH"|"LOW", pin_data?: number, pin_clock?: number, mode?: "DIGITAL"|"ANALOG" } ) {
        this._type = type;
        this._data = data;
    }

    get type(): ArduinoProxyPayloadType {
        return this._type;
    }

    get data(): {value?: number} {
        return this._data;
    }

    get id(): string {
        return this._id;
    }

    public send() {
        return ArduinoProxy.sendRequest(this);
    }
}