"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const AuthType_1 = require("../enums/AuthType");
const js_sha256_1 = require("js-sha256");
class RequestObj {
    constructor(config, method, headers, parameters) {
        this.request = {
            headers: {
                uri: "",
                pid: "",
                version: ""
            },
            parameters: {}
        };
        this.method = method;
        this.request = {
            headers,
            parameters
        };
        headers[config.headerVariableName] = config.appId;
        headers["envCode"] = config.envCode;
        const timestamp = Number.parseInt((new Date().getTime() / 1000).toString());
        headers["timestamp"] = timestamp.toString();
        let sign, signSrc = "";
        const { sid, version } = headers;
        switch (config.authType) {
            case AuthType_1.AuthType.NONE:
                break;
            case AuthType_1.AuthType.BASE:
                signSrc = sid + version + timestamp + config.appKey;
                break;
        }
        sign = js_sha256_1.sha256(signSrc);
        headers["sign"] = sign;
        headers["signSrc"] = signSrc;
    }
}
exports.RequestObj = RequestObj;
