{"version":3,"sources":["src/common.speech/SynthesisRestAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,aAAa,EAIhB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EAAY,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAG5E;;;;GAIG;AACH,qBAAa,oBAAoB;IAC7B,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,kBAAkB,CAAkB;gBAEzB,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe;IAe7E;;;;;;OAMG;IACI,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAQrE","file":"SynthesisRestAdapter.d.ts","sourcesContent":["import {\n    IRequestOptions,\n    IRestResponse,\n    RestConfigBase,\n    RestMessageAdapter,\n    RestRequestType,\n} from \"../common.browser/Exports.js\";\nimport {\n    PropertyId,\n} from \"../sdk/Exports.js\";\nimport { ConnectionFactoryBase } from \"./ConnectionFactoryBase.js\";\nimport { AuthInfo, IAuthentication, SynthesizerConfig } from \"./Exports.js\";\nimport { HeaderNames } from \"./HeaderNames.js\";\n\n/**\n * Implements methods for speaker recognition classes, sending requests to endpoint\n * and parsing response into expected format\n * @class SynthesisRestAdapter\n */\nexport class SynthesisRestAdapter {\n    private privRestAdapter: RestMessageAdapter;\n    private privUri: string;\n    private privAuthentication: IAuthentication;\n\n    public constructor(config: SynthesizerConfig, authentication: IAuthentication) {\n\n        let endpoint = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\n        if (!endpoint) {\n            const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, \"westus\");\n            const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\n            endpoint = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, `https://${region}.tts.speech${hostSuffix}`);\n        }\n        this.privUri = `${endpoint}/cognitiveservices/voices/list`;\n\n        const options: IRequestOptions = RestConfigBase.requestOptions;\n        this.privRestAdapter = new RestMessageAdapter(options);\n        this.privAuthentication = authentication;\n    }\n\n    /**\n     * Sends list voices request to endpoint.\n     * @function\n     * @public\n     * @param connectionId - guid for connectionId\n     * @returns {Promise<IRestResponse>} rest response to status request\n     */\n    public getVoicesList(connectionId: string): Promise<IRestResponse> {\n        this.privRestAdapter.setHeaders(HeaderNames.ConnectionId, connectionId);\n        return this.privAuthentication.fetch(connectionId).then((authInfo: AuthInfo): Promise<IRestResponse> => {\n            this.privRestAdapter.setHeaders(authInfo.headerName, authInfo.token);\n            return this.privRestAdapter.request(RestRequestType.Get, this.privUri);\n        });\n    }\n\n}\n"]}