"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var method_type_1 = require("../../api/request/method-type");
var header_1 = require("./header");
var core_1 = require("../../../core");
var ApiRequest = /** @class */ (function () {
    function ApiRequest(method, url, data) {
        // if (Cmd != null) {
        //     // Check if getVar/setVar with only variable index
        //     if (Cmd.indexOf('/') == -1) {
        //         if (method == MethodType.GET)
        //             Cmd = Header.ID_OBJ_VAR + Cmd + Header.ID_VAR_VALUE_READ;
        //         else
        //             Cmd = Header.ID_OBJ_VAR + Cmd + Header.ID_VAR_VALUE_WRITE;
        //     }
        // }
        this.method = method;
        this.commandUrl = url;
        this.data = data || new Uint8Array(0);
    }
    ApiRequest.prototype.getCommandUrl = function () {
        return this.commandUrl;
    };
    ApiRequest.prototype.setCommandUrl = function (commandUrl) {
        this.commandUrl = commandUrl;
        return this;
    };
    ApiRequest.prototype.getHeader = function () {
        return header_1.Header.fromString(this.commandUrl);
    };
    ApiRequest.prototype.setHeader = function (id) {
        this.commandUrl = id;
    };
    ApiRequest.prototype.setMethod = function (type) {
        this.method = type;
    };
    ApiRequest.prototype.getMethod = function () {
        return this.method;
    };
    ApiRequest.prototype.getData = function () {
        return this.data ? this.data : new Uint8Array(0);
    };
    ApiRequest.prototype.setData = function (data) {
        this.data = data;
    };
    ApiRequest.prototype.hasData = function () {
        return this.data != null && this.data.length > 0;
    };
    ApiRequest.prototype.toString = function () {
        return method_type_1.MethodType[this.method] + " " + this.commandUrl + " " + (this.data ? core_1.FormatHelper.toHexString(this.data) : "");
    };
    ApiRequest.GET = function (url, data) {
        var requestMessage = new ApiRequest(method_type_1.MethodType.GET, url, data);
        return requestMessage;
    };
    ApiRequest.PUT = function (url, body) {
        var requestMessage = new ApiRequest(method_type_1.MethodType.PUT, url, body);
        return requestMessage;
    };
    ApiRequest.POST = function (url, body) {
        var requestMessage = new ApiRequest(method_type_1.MethodType.POST, url, body);
        return requestMessage;
    };
    ApiRequest.create = function (from, header, data) {
        return new ApiRequest(from, header, data);
    };
    ApiRequest.TAG = "ApiRequestMessage";
    return ApiRequest;
}());
exports.ApiRequest = ApiRequest;
