"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PublishPackageResponse = exports.PublishPackageResponseBody = exports.PublishPackageRequest = exports.PublishPackageHeaders = exports.GetCreateStatusResponse = exports.GetCreateStatusResponseBody = exports.GetCreateStatusRequest = exports.GetCreateStatusHeaders = exports.GetAccessTokenResponse = exports.GetAccessTokenResponseBody = exports.GetAccessTokenRequest = exports.GetAccessTokenHeaders = exports.CreatePackageResponse = exports.CreatePackageResponseBody = exports.CreatePackageRequest = exports.CreatePackageHeaders = void 0;
// This file is auto-generated, don't edit it
/**
 */
const tea_util_1 = __importStar(require("@alicloud/tea-util")), $Util = tea_util_1;
const gateway_dingtalk_1 = __importDefault(require("@alicloud/gateway-dingtalk"));
const openapi_client_1 = __importStar(require("@alicloud/openapi-client")), $OpenApi = openapi_client_1;
const openapi_util_1 = __importDefault(require("@alicloud/openapi-util"));
const $tea = __importStar(require("@alicloud/tea-typescript"));
class CreatePackageHeaders extends $tea.Model {
    static names() {
        return {
            commonHeaders: 'commonHeaders',
            xAcsDingtalkAccessToken: 'x-acs-dingtalk-access-token',
        };
    }
    static types() {
        return {
            commonHeaders: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
            xAcsDingtalkAccessToken: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.CreatePackageHeaders = CreatePackageHeaders;
class CreatePackageRequest extends $tea.Model {
    static names() {
        return {
            agentId: 'agentId',
            appId: 'appId',
            homeUrl: 'homeUrl',
            ossObjectKey: 'ossObjectKey',
        };
    }
    static types() {
        return {
            agentId: 'number',
            appId: 'number',
            homeUrl: 'string',
            ossObjectKey: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.CreatePackageRequest = CreatePackageRequest;
class CreatePackageResponseBody extends $tea.Model {
    static names() {
        return {
            taskId: 'taskId',
        };
    }
    static types() {
        return {
            taskId: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.CreatePackageResponseBody = CreatePackageResponseBody;
class CreatePackageResponse extends $tea.Model {
    static names() {
        return {
            headers: 'headers',
            statusCode: 'statusCode',
            body: 'body',
        };
    }
    static types() {
        return {
            headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
            statusCode: 'number',
            body: CreatePackageResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.CreatePackageResponse = CreatePackageResponse;
class GetAccessTokenHeaders extends $tea.Model {
    static names() {
        return {
            commonHeaders: 'commonHeaders',
            xAcsDingtalkAccessToken: 'x-acs-dingtalk-access-token',
        };
    }
    static types() {
        return {
            commonHeaders: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
            xAcsDingtalkAccessToken: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetAccessTokenHeaders = GetAccessTokenHeaders;
class GetAccessTokenRequest extends $tea.Model {
    static names() {
        return {
            agentId: 'agentId',
            appId: 'appId',
        };
    }
    static types() {
        return {
            agentId: 'number',
            appId: 'number',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetAccessTokenRequest = GetAccessTokenRequest;
class GetAccessTokenResponseBody extends $tea.Model {
    static names() {
        return {
            accessKeyId: 'accessKeyId',
            accessKeySecret: 'accessKeySecret',
            bucket: 'bucket',
            endpoint: 'endpoint',
            expiration: 'expiration',
            name: 'name',
            region: 'region',
            stsToken: 'stsToken',
        };
    }
    static types() {
        return {
            accessKeyId: 'string',
            accessKeySecret: 'string',
            bucket: 'string',
            endpoint: 'string',
            expiration: 'string',
            name: 'string',
            region: 'string',
            stsToken: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetAccessTokenResponseBody = GetAccessTokenResponseBody;
class GetAccessTokenResponse extends $tea.Model {
    static names() {
        return {
            headers: 'headers',
            statusCode: 'statusCode',
            body: 'body',
        };
    }
    static types() {
        return {
            headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
            statusCode: 'number',
            body: GetAccessTokenResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetAccessTokenResponse = GetAccessTokenResponse;
class GetCreateStatusHeaders extends $tea.Model {
    static names() {
        return {
            commonHeaders: 'commonHeaders',
            xAcsDingtalkAccessToken: 'x-acs-dingtalk-access-token',
        };
    }
    static types() {
        return {
            commonHeaders: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
            xAcsDingtalkAccessToken: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetCreateStatusHeaders = GetCreateStatusHeaders;
class GetCreateStatusRequest extends $tea.Model {
    static names() {
        return {
            taskId: 'taskId',
        };
    }
    static types() {
        return {
            taskId: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetCreateStatusRequest = GetCreateStatusRequest;
class GetCreateStatusResponseBody extends $tea.Model {
    static names() {
        return {
            buildTime: 'buildTime',
            finished: 'finished',
            packageSize: 'packageSize',
            status: 'status',
            taskId: 'taskId',
            version: 'version',
        };
    }
    static types() {
        return {
            buildTime: 'number',
            finished: 'boolean',
            packageSize: 'number',
            status: 'string',
            taskId: 'string',
            version: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetCreateStatusResponseBody = GetCreateStatusResponseBody;
class GetCreateStatusResponse extends $tea.Model {
    static names() {
        return {
            headers: 'headers',
            statusCode: 'statusCode',
            body: 'body',
        };
    }
    static types() {
        return {
            headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
            statusCode: 'number',
            body: GetCreateStatusResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetCreateStatusResponse = GetCreateStatusResponse;
class PublishPackageHeaders extends $tea.Model {
    static names() {
        return {
            commonHeaders: 'commonHeaders',
            xAcsDingtalkAccessToken: 'x-acs-dingtalk-access-token',
        };
    }
    static types() {
        return {
            commonHeaders: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
            xAcsDingtalkAccessToken: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.PublishPackageHeaders = PublishPackageHeaders;
class PublishPackageRequest extends $tea.Model {
    static names() {
        return {
            agentId: 'agentId',
            appId: 'appId',
            version: 'version',
        };
    }
    static types() {
        return {
            agentId: 'number',
            appId: 'number',
            version: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.PublishPackageRequest = PublishPackageRequest;
class PublishPackageResponseBody extends $tea.Model {
    static names() {
        return {
            success: 'success',
        };
    }
    static types() {
        return {
            success: 'boolean',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.PublishPackageResponseBody = PublishPackageResponseBody;
class PublishPackageResponse extends $tea.Model {
    static names() {
        return {
            headers: 'headers',
            statusCode: 'statusCode',
            body: 'body',
        };
    }
    static types() {
        return {
            headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
            statusCode: 'number',
            body: PublishPackageResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.PublishPackageResponse = PublishPackageResponse;
class Client extends openapi_client_1.default {
    constructor(config) {
        super(config);
        let gatewayClient = new gateway_dingtalk_1.default();
        this._spi = gatewayClient;
        this._endpointRule = "";
        if (tea_util_1.default.empty(this._endpoint)) {
            this._endpoint = "api.dingtalk.com";
        }
    }
    /**
     * 上传H5离线包
     *
     * @param request - CreatePackageRequest
     * @param headers - CreatePackageHeaders
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns CreatePackageResponse
     */
    async createPackageWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let body = {};
        if (!tea_util_1.default.isUnset(request.agentId)) {
            body["agentId"] = request.agentId;
        }
        if (!tea_util_1.default.isUnset(request.appId)) {
            body["appId"] = request.appId;
        }
        if (!tea_util_1.default.isUnset(request.homeUrl)) {
            body["homeUrl"] = request.homeUrl;
        }
        if (!tea_util_1.default.isUnset(request.ossObjectKey)) {
            body["ossObjectKey"] = request.ossObjectKey;
        }
        let realHeaders = {};
        if (!tea_util_1.default.isUnset(headers.commonHeaders)) {
            realHeaders = headers.commonHeaders;
        }
        if (!tea_util_1.default.isUnset(headers.xAcsDingtalkAccessToken)) {
            realHeaders["x-acs-dingtalk-access-token"] = tea_util_1.default.toJSONString(headers.xAcsDingtalkAccessToken);
        }
        let req = new $OpenApi.OpenApiRequest({
            headers: realHeaders,
            body: openapi_util_1.default.parseToMap(body),
        });
        let params = new $OpenApi.Params({
            action: "CreatePackage",
            version: "h5package_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/h5package/asyncUpload`,
            method: "POST",
            authType: "AK",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new CreatePackageResponse({}));
    }
    /**
     * 上传H5离线包
     *
     * @param request - CreatePackageRequest
     * @returns CreatePackageResponse
     */
    async createPackage(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = new CreatePackageHeaders({});
        return await this.createPackageWithOptions(request, headers, runtime);
    }
    /**
     * 获取包上传一次性AccessToken
     *
     * @param request - GetAccessTokenRequest
     * @param headers - GetAccessTokenHeaders
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns GetAccessTokenResponse
     */
    async getAccessTokenWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let query = {};
        if (!tea_util_1.default.isUnset(request.agentId)) {
            query["agentId"] = request.agentId;
        }
        if (!tea_util_1.default.isUnset(request.appId)) {
            query["appId"] = request.appId;
        }
        let realHeaders = {};
        if (!tea_util_1.default.isUnset(headers.commonHeaders)) {
            realHeaders = headers.commonHeaders;
        }
        if (!tea_util_1.default.isUnset(headers.xAcsDingtalkAccessToken)) {
            realHeaders["x-acs-dingtalk-access-token"] = tea_util_1.default.toJSONString(headers.xAcsDingtalkAccessToken);
        }
        let req = new $OpenApi.OpenApiRequest({
            headers: realHeaders,
            query: openapi_util_1.default.query(query),
        });
        let params = new $OpenApi.Params({
            action: "GetAccessToken",
            version: "h5package_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/h5package/uploadTokens`,
            method: "GET",
            authType: "AK",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new GetAccessTokenResponse({}));
    }
    /**
     * 获取包上传一次性AccessToken
     *
     * @param request - GetAccessTokenRequest
     * @returns GetAccessTokenResponse
     */
    async getAccessToken(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = new GetAccessTokenHeaders({});
        return await this.getAccessTokenWithOptions(request, headers, runtime);
    }
    /**
     * 获取H5离线包版本创建状态
     *
     * @param request - GetCreateStatusRequest
     * @param headers - GetCreateStatusHeaders
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns GetCreateStatusResponse
     */
    async getCreateStatusWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let query = {};
        if (!tea_util_1.default.isUnset(request.taskId)) {
            query["taskId"] = request.taskId;
        }
        let realHeaders = {};
        if (!tea_util_1.default.isUnset(headers.commonHeaders)) {
            realHeaders = headers.commonHeaders;
        }
        if (!tea_util_1.default.isUnset(headers.xAcsDingtalkAccessToken)) {
            realHeaders["x-acs-dingtalk-access-token"] = tea_util_1.default.toJSONString(headers.xAcsDingtalkAccessToken);
        }
        let req = new $OpenApi.OpenApiRequest({
            headers: realHeaders,
            query: openapi_util_1.default.query(query),
        });
        let params = new $OpenApi.Params({
            action: "GetCreateStatus",
            version: "h5package_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/h5package/uploadStatus`,
            method: "GET",
            authType: "AK",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new GetCreateStatusResponse({}));
    }
    /**
     * 获取H5离线包版本创建状态
     *
     * @param request - GetCreateStatusRequest
     * @returns GetCreateStatusResponse
     */
    async getCreateStatus(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = new GetCreateStatusHeaders({});
        return await this.getCreateStatusWithOptions(request, headers, runtime);
    }
    /**
     * 发布离线包
     *
     * @param request - PublishPackageRequest
     * @param headers - PublishPackageHeaders
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns PublishPackageResponse
     */
    async publishPackageWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let body = {};
        if (!tea_util_1.default.isUnset(request.agentId)) {
            body["agentId"] = request.agentId;
        }
        if (!tea_util_1.default.isUnset(request.appId)) {
            body["appId"] = request.appId;
        }
        if (!tea_util_1.default.isUnset(request.version)) {
            body["version"] = request.version;
        }
        let realHeaders = {};
        if (!tea_util_1.default.isUnset(headers.commonHeaders)) {
            realHeaders = headers.commonHeaders;
        }
        if (!tea_util_1.default.isUnset(headers.xAcsDingtalkAccessToken)) {
            realHeaders["x-acs-dingtalk-access-token"] = tea_util_1.default.toJSONString(headers.xAcsDingtalkAccessToken);
        }
        let req = new $OpenApi.OpenApiRequest({
            headers: realHeaders,
            body: openapi_util_1.default.parseToMap(body),
        });
        let params = new $OpenApi.Params({
            action: "PublishPackage",
            version: "h5package_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/h5package/publish`,
            method: "POST",
            authType: "AK",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new PublishPackageResponse({}));
    }
    /**
     * 发布离线包
     *
     * @param request - PublishPackageRequest
     * @returns PublishPackageResponse
     */
    async publishPackage(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = new PublishPackageHeaders({});
        return await this.publishPackageWithOptions(request, headers, runtime);
    }
}
exports.default = Client;
//# sourceMappingURL=client.js.map