diff --git a/sdk/src/platform/Platform-spec.ts b/sdk/src/platform/Platform-spec.ts index 22376133..ced1294b 100644 --- a/sdk/src/platform/Platform-spec.ts +++ b/sdk/src/platform/Platform-spec.ts @@ -972,6 +972,13 @@ describe('RingCentral.platform.Platform', () => { expect(data.increment).to.equal(1); }); + it('should fetch rcv api request successfully', async () => { + apiCall('GET', '/rcvideo/v1/bridges', {id: 123}); + const res = await platform.get('/rcvideo/v1/bridges'); + const data = await res.json(); + expect(data.id).to.equal(123); + }); + it('should refresh token successfully', async () => { tokenRefresh(); const noErrors = true; diff --git a/sdk/src/platform/Platform.ts b/sdk/src/platform/Platform.ts index ed5d982b..15b02154 100644 --- a/sdk/src/platform/Platform.ts +++ b/sdk/src/platform/Platform.ts @@ -39,6 +39,8 @@ export default class Platform extends EventEmitter { private _server: string; + private _rcvServer: string; + private _clientId: string; private _clientSecret: string; @@ -109,6 +111,7 @@ export default class Platform extends EventEmitter { super(); this._server = server; + this._rcvServer = server; this._clientId = clientId; this._clientSecret = clientSecret; this._brandId = brandId; @@ -203,7 +206,13 @@ export default class Platform extends EventEmitter { const hasHttp = checkPathHasHttp(path); - if (options.addServer && !hasHttp) builtUrl += this._server; + if (options.addServer && !hasHttp) { + if (path.indexOf('/rcvideo') === 0 || (this._urlPrefix && this._urlPrefix.indexOf('/rcvideo') === 0)) { + builtUrl += this._rcvServer; + } else { + builtUrl += this._server; + } + } if (this._urlPrefix) builtUrl += this._urlPrefix; @@ -702,6 +711,7 @@ export default class Platform extends EventEmitter { throw new Error('Discovery data is missing'); } this._server = discoveryData.coreApi.baseUri; + this._rcvServer = discoveryData.rcv.baseApiUri; if (discoveryData.tag) { options.headers = options.headers || {}; options.headers['Discovery-Tag'] = discoveryData.tag; diff --git a/sdk/src/test/test.ts b/sdk/src/test/test.ts index 97113253..f1e1964b 100644 --- a/sdk/src/test/test.ts +++ b/sdk/src/test/test.ts @@ -161,6 +161,9 @@ export function getExternalDiscoveryMockData() { baseUri: 'http://whatever', tokenUri: 'http://whatever/restapi/oauth/token', }, + rcv: { + baseApiUri: 'http://whatever', + }, coreApi: { baseUri: 'http://whatever', pubnubOrigin: 'whatever',