"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.OpenConnectionRequestSubscriptions = exports.OpenConnectionResponse = exports.OpenConnectionResponseBody = exports.OpenConnectionRequest = 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 OpenConnectionRequest extends $tea.Model {
    static names() {
        return {
            clientId: 'clientId',
            clientSecret: 'clientSecret',
            extras: 'extras',
            localIp: 'localIp',
            subscriptions: 'subscriptions',
        };
    }
    static types() {
        return {
            clientId: 'string',
            clientSecret: 'string',
            extras: { 'type': 'map', 'keyType': 'string', 'valueType': 'any' },
            localIp: 'string',
            subscriptions: { 'type': 'array', 'itemType': OpenConnectionRequestSubscriptions },
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.OpenConnectionRequest = OpenConnectionRequest;
class OpenConnectionResponseBody extends $tea.Model {
    static names() {
        return {
            endpoint: 'endpoint',
            ticket: 'ticket',
        };
    }
    static types() {
        return {
            endpoint: 'string',
            ticket: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.OpenConnectionResponseBody = OpenConnectionResponseBody;
class OpenConnectionResponse 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: OpenConnectionResponseBody,
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.OpenConnectionResponse = OpenConnectionResponse;
class OpenConnectionRequestSubscriptions extends $tea.Model {
    static names() {
        return {
            topic: 'topic',
            type: 'type',
        };
    }
    static types() {
        return {
            topic: 'string',
            type: 'string',
        };
    }
    constructor(map) {
        super(map);
    }
}
exports.OpenConnectionRequestSubscriptions = OpenConnectionRequestSubscriptions;
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";
        }
    }
    /**
     * 云上网关注册长连接
     *
     * @param request - OpenConnectionRequest
     * @param headers - map
     * @param runtime - runtime options for this request RuntimeOptions
     * @returns OpenConnectionResponse
     */
    async openConnectionWithOptions(request, headers, runtime) {
        tea_util_1.default.validateModel(request);
        let body = {};
        if (!tea_util_1.default.isUnset(request.clientId)) {
            body["clientId"] = request.clientId;
        }
        if (!tea_util_1.default.isUnset(request.clientSecret)) {
            body["clientSecret"] = request.clientSecret;
        }
        if (!tea_util_1.default.isUnset(request.extras)) {
            body["extras"] = request.extras;
        }
        if (!tea_util_1.default.isUnset(request.localIp)) {
            body["localIp"] = request.localIp;
        }
        if (!tea_util_1.default.isUnset(request.subscriptions)) {
            body["subscriptions"] = request.subscriptions;
        }
        let req = new $OpenApi.OpenApiRequest({
            headers: headers,
            body: openapi_util_1.default.parseToMap(body),
        });
        let params = new $OpenApi.Params({
            action: "OpenConnection",
            version: "gateway_1.0",
            protocol: "HTTP",
            pathname: `/v1.0/gateway/connections/open`,
            method: "POST",
            authType: "Anonymous",
            style: "ROA",
            reqBodyType: "none",
            bodyType: "json",
        });
        return $tea.cast(await this.execute(params, req, runtime), new OpenConnectionResponse({}));
    }
    /**
     * 云上网关注册长连接
     *
     * @param request - OpenConnectionRequest
     * @returns OpenConnectionResponse
     */
    async openConnection(request) {
        let runtime = new $Util.RuntimeOptions({});
        let headers = {};
        return await this.openConnectionWithOptions(request, headers, runtime);
    }
}
exports.default = Client;
//# sourceMappingURL=client.js.map