{"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 {\r\n    IRequestOptions,\r\n    IRestResponse,\r\n    RestConfigBase,\r\n    RestMessageAdapter,\r\n    RestRequestType,\r\n} from \"../common.browser/Exports.js\";\r\nimport {\r\n    PropertyId,\r\n} from \"../sdk/Exports.js\";\r\nimport { ConnectionFactoryBase } from \"./ConnectionFactoryBase.js\";\r\nimport { AuthInfo, IAuthentication, SynthesizerConfig } from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\n\r\n/**\r\n * Implements methods for speech synthesis classes, sending requests to endpoint\r\n * and parsing response into expected format\r\n * @class SynthesisRestAdapter\r\n */\r\nexport class SynthesisRestAdapter {\r\n    private privRestAdapter: RestMessageAdapter;\r\n    private privUri: string;\r\n    private privAuthentication: IAuthentication;\r\n\r\n    public constructor(config: SynthesizerConfig, authentication: IAuthentication) {\r\n\r\n        let endpoint = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\r\n        if (!endpoint) {\r\n            const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, \"westus\");\r\n            const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\r\n            endpoint = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, `https://${region}.tts.speech${hostSuffix}`);\r\n        }\r\n        this.privUri = `${endpoint}/cognitiveservices/voices/list`;\r\n\r\n        const options: IRequestOptions = RestConfigBase.requestOptions;\r\n        this.privRestAdapter = new RestMessageAdapter(options);\r\n        this.privAuthentication = authentication;\r\n    }\r\n\r\n    /**\r\n     * Sends list voices request to endpoint.\r\n     * @function\r\n     * @public\r\n     * @param connectionId - guid for connectionId\r\n     * @returns {Promise<IRestResponse>} rest response to status request\r\n     */\r\n    public getVoicesList(connectionId: string): Promise<IRestResponse> {\r\n        this.privRestAdapter.setHeaders(HeaderNames.ConnectionId, connectionId);\r\n        return this.privAuthentication.fetch(connectionId).then((authInfo: AuthInfo): Promise<IRestResponse> => {\r\n            this.privRestAdapter.setHeaders(authInfo.headerName, authInfo.token);\r\n            return this.privRestAdapter.request(RestRequestType.Get, this.privUri);\r\n        });\r\n    }\r\n\r\n}\r\n"]}