"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.SendLinkResponseBodyFile = exports.SendByAppResponseBodyFile = exports.SendResponseBodyFile = exports.GetSpaceResponseBodySpace = exports.SendLinkResponse = exports.SendLinkResponseBody = exports.SendLinkRequest = exports.SendLinkHeaders = exports.SendByAppResponse = exports.SendByAppResponseBody = exports.SendByAppRequest = exports.SendByAppHeaders = exports.SendResponse = exports.SendResponseBody = exports.SendRequest = exports.SendHeaders = exports.GetSpaceResponse = exports.GetSpaceResponseBody = exports.GetSpaceRequest = exports.GetSpaceHeaders = 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 GetSpaceHeaders 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.GetSpaceHeaders = GetSpaceHeaders;
class GetSpaceRequest extends $tea.Model {
    static names() {
        return {
            openConversationId: 'openConversationId',
            unionId: 'unionId',
        };
    }
    static types() {
        return {
            openConversationId: 'string',
            unionId: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetSpaceRequest = GetSpaceRequest;
class GetSpaceResponseBody extends $tea.Model {
    static names() {
        return {
            space: 'space',
        };
    }
    static types() {
        return {
            space: GetSpaceResponseBodySpace,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetSpaceResponseBody = GetSpaceResponseBody;
class GetSpaceResponse 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: GetSpaceResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetSpaceResponse = GetSpaceResponse;
class SendHeaders 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.SendHeaders = SendHeaders;
class SendRequest extends $tea.Model {
    static names() {
        return {
            dentryId: 'dentryId',
            openConversationId: 'openConversationId',
            spaceId: 'spaceId',
            unionId: 'unionId',
        };
    }
    static types() {
        return {
            dentryId: 'string',
            openConversationId: 'string',
            spaceId: 'string',
            unionId: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendRequest = SendRequest;
class SendResponseBody extends $tea.Model {
    static names() {
        return {
            file: 'file',
        };
    }
    static types() {
        return {
            file: SendResponseBodyFile,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendResponseBody = SendResponseBody;
class SendResponse 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: SendResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendResponse = SendResponse;
class SendByAppHeaders 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.SendByAppHeaders = SendByAppHeaders;
class SendByAppRequest extends $tea.Model {
    static names() {
        return {
            dentryId: 'dentryId',
            spaceId: 'spaceId',
            unionId: 'unionId',
        };
    }
    static types() {
        return {
            dentryId: 'string',
            spaceId: 'string',
            unionId: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendByAppRequest = SendByAppRequest;
class SendByAppResponseBody extends $tea.Model {
    static names() {
        return {
            file: 'file',
        };
    }
    static types() {
        return {
            file: SendByAppResponseBodyFile,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendByAppResponseBody = SendByAppResponseBody;
class SendByAppResponse 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: SendByAppResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendByAppResponse = SendByAppResponse;
class SendLinkHeaders 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.SendLinkHeaders = SendLinkHeaders;
class SendLinkRequest extends $tea.Model {
    static names() {
        return {
            dentryId: 'dentryId',
            openConversationId: 'openConversationId',
            spaceId: 'spaceId',
            unionId: 'unionId',
        };
    }
    static types() {
        return {
            dentryId: 'string',
            openConversationId: 'string',
            spaceId: 'string',
            unionId: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendLinkRequest = SendLinkRequest;
class SendLinkResponseBody extends $tea.Model {
    static names() {
        return {
            file: 'file',
        };
    }
    static types() {
        return {
            file: SendLinkResponseBodyFile,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendLinkResponseBody = SendLinkResponseBody;
class SendLinkResponse 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: SendLinkResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendLinkResponse = SendLinkResponse;
class GetSpaceResponseBodySpace extends $tea.Model {
    static names() {
        return {
            corpId: 'corpId',
            createTime: 'createTime',
            modifiedTime: 'modifiedTime',
            spaceId: 'spaceId',
        };
    }
    static types() {
        return {
            corpId: 'string',
            createTime: 'string',
            modifiedTime: 'string',
            spaceId: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.GetSpaceResponseBodySpace = GetSpaceResponseBodySpace;
class SendResponseBodyFile extends $tea.Model {
    static names() {
        return {
            conversationId: 'conversationId',
            createTime: 'createTime',
            creatorId: 'creatorId',
            extension: 'extension',
            id: 'id',
            modifiedTime: 'modifiedTime',
            modifierId: 'modifierId',
            name: 'name',
            parentId: 'parentId',
            path: 'path',
            size: 'size',
            spaceId: 'spaceId',
            status: 'status',
            type: 'type',
            uuid: 'uuid',
            version: 'version',
        };
    }
    static types() {
        return {
            conversationId: 'string',
            createTime: 'string',
            creatorId: 'string',
            extension: 'string',
            id: 'string',
            modifiedTime: 'string',
            modifierId: 'string',
            name: 'string',
            parentId: 'string',
            path: 'string',
            size: 'number',
            spaceId: 'string',
            status: 'string',
            type: 'string',
            uuid: 'string',
            version: 'number',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendResponseBodyFile = SendResponseBodyFile;
class SendByAppResponseBodyFile extends $tea.Model {
    static names() {
        return {
            conversationId: 'conversationId',
            createTime: 'createTime',
            creatorId: 'creatorId',
            extension: 'extension',
            id: 'id',
            modifiedTime: 'modifiedTime',
            modifierId: 'modifierId',
            name: 'name',
            parentId: 'parentId',
            path: 'path',
            size: 'size',
            spaceId: 'spaceId',
            status: 'status',
            type: 'type',
            uuid: 'uuid',
            version: 'version',
        };
    }
    static types() {
        return {
            conversationId: 'string',
            createTime: 'string',
            creatorId: 'string',
            extension: 'string',
            id: 'string',
            modifiedTime: 'string',
            modifierId: 'string',
            name: 'string',
            parentId: 'string',
            path: 'string',
            size: 'number',
            spaceId: 'string',
            status: 'string',
            type: 'string',
            uuid: 'string',
            version: 'number',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendByAppResponseBodyFile = SendByAppResponseBodyFile;
class SendLinkResponseBodyFile extends $tea.Model {
    static names() {
        return {
            conversationId: 'conversationId',
            createTime: 'createTime',
            creatorId: 'creatorId',
            extension: 'extension',
            id: 'id',
            modifiedTime: 'modifiedTime',
            modifierId: 'modifierId',
            name: 'name',
            parentId: 'parentId',
            path: 'path',
            size: 'size',
            spaceId: 'spaceId',
            status: 'status',
            type: 'type',
            uuid: 'uuid',
            version: 'version',
        };
    }
    static types() {
        return {
            conversationId: 'string',
            createTime: 'string',
            creatorId: 'string',
            extension: 'string',
            id: 'string',
            modifiedTime: 'string',
            modifierId: 'string',
            name: 'string',
            parentId: 'string',
            path: 'string',
            size: 'number',
            spaceId: 'string',
            status: 'string',
            type: 'string',
            uuid: 'string',
            version: 'number',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.SendLinkResponseBodyFile = SendLinkResponseBodyFile;
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";
        }
    }
    /**
     * 获取IM会话存储空间信息
     *
     * @param request - GetSpaceRequest
     * @param headers - GetSpaceHeaders
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns GetSpaceResponse
     */
    async getSpaceWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let query = {};
        if (!tea_util_1.default.isUnset(request.unionId)) {
            query["unionId"] = request.unionId;
        }
        let body = {};
        if (!tea_util_1.default.isUnset(request.openConversationId)) {
            body["openConversationId"] = request.openConversationId;
        }
        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),
            body: openapi_util_1.default.parseToMap(body),
        });
        let params = new $OpenApi.Params({
            action: "GetSpace",
            version: "convFile_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/convFile/conversations/spaces/query`,
            method: "POST",
            authType: "AK",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new GetSpaceResponse({}));
    }
    /**
     * 获取IM会话存储空间信息
     *
     * @param request - GetSpaceRequest
     * @returns GetSpaceResponse
     */
    async getSpace(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = new GetSpaceHeaders({});
        return await this.getSpaceWithOptions(request, headers, runtime);
    }
    /**
     * 发送文件到指定会话
     *
     * @param request - SendRequest
     * @param headers - SendHeaders
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns SendResponse
     */
    async sendWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let query = {};
        if (!tea_util_1.default.isUnset(request.unionId)) {
            query["unionId"] = request.unionId;
        }
        let body = {};
        if (!tea_util_1.default.isUnset(request.dentryId)) {
            body["dentryId"] = request.dentryId;
        }
        if (!tea_util_1.default.isUnset(request.openConversationId)) {
            body["openConversationId"] = request.openConversationId;
        }
        if (!tea_util_1.default.isUnset(request.spaceId)) {
            body["spaceId"] = request.spaceId;
        }
        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),
            body: openapi_util_1.default.parseToMap(body),
        });
        let params = new $OpenApi.Params({
            action: "Send",
            version: "convFile_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/convFile/conversations/files/send`,
            method: "POST",
            authType: "AK",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new SendResponse({}));
    }
    /**
     * 发送文件到指定会话
     *
     * @param request - SendRequest
     * @returns SendResponse
     */
    async send(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = new SendHeaders({});
        return await this.sendWithOptions(request, headers, runtime);
    }
    /**
     * 以应用身份发送文件给自己
     *
     * @param request - SendByAppRequest
     * @param headers - SendByAppHeaders
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns SendByAppResponse
     */
    async sendByAppWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let query = {};
        if (!tea_util_1.default.isUnset(request.unionId)) {
            query["unionId"] = request.unionId;
        }
        let body = {};
        if (!tea_util_1.default.isUnset(request.dentryId)) {
            body["dentryId"] = request.dentryId;
        }
        if (!tea_util_1.default.isUnset(request.spaceId)) {
            body["spaceId"] = request.spaceId;
        }
        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),
            body: openapi_util_1.default.parseToMap(body),
        });
        let params = new $OpenApi.Params({
            action: "SendByApp",
            version: "convFile_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/convFile/apps/conversations/files/send`,
            method: "POST",
            authType: "AK",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new SendByAppResponse({}));
    }
    /**
     * 以应用身份发送文件给自己
     *
     * @param request - SendByAppRequest
     * @returns SendByAppResponse
     */
    async sendByApp(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = new SendByAppHeaders({});
        return await this.sendByAppWithOptions(request, headers, runtime);
    }
    /**
     * 发送文件链接到指定会话
     *
     * @param request - SendLinkRequest
     * @param headers - SendLinkHeaders
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns SendLinkResponse
     */
    async sendLinkWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let query = {};
        if (!tea_util_1.default.isUnset(request.unionId)) {
            query["unionId"] = request.unionId;
        }
        let body = {};
        if (!tea_util_1.default.isUnset(request.dentryId)) {
            body["dentryId"] = request.dentryId;
        }
        if (!tea_util_1.default.isUnset(request.openConversationId)) {
            body["openConversationId"] = request.openConversationId;
        }
        if (!tea_util_1.default.isUnset(request.spaceId)) {
            body["spaceId"] = request.spaceId;
        }
        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),
            body: openapi_util_1.default.parseToMap(body),
        });
        let params = new $OpenApi.Params({
            action: "SendLink",
            version: "convFile_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/convFile/conversations/files/links/send`,
            method: "POST",
            authType: "AK",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new SendLinkResponse({}));
    }
    /**
     * 发送文件链接到指定会话
     *
     * @param request - SendLinkRequest
     * @returns SendLinkResponse
     */
    async sendLink(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = new SendLinkHeaders({});
        return await this.sendLinkWithOptions(request, headers, runtime);
    }
}
exports.default = Client;
//# sourceMappingURL=client.js.map