diff --git a/dist/ottProvider.js b/dist/ottProvider.js old mode 100644 new mode 100755 diff --git a/dist/ottProvider.js.map b/dist/ottProvider.js.map old mode 100644 new mode 100755 diff --git a/dist/ovpProvider.js b/dist/ovpProvider.js old mode 100644 new mode 100755 diff --git a/dist/ovpProvider.js.map b/dist/ovpProvider.js.map old mode 100644 new mode 100755 diff --git a/dist/statsService.js b/dist/statsService.js old mode 100644 new mode 100755 diff --git a/dist/statsService.js.map b/dist/statsService.js.map old mode 100644 new mode 100755 diff --git a/src/k-provider/ovp/ovp-provider.js b/src/k-provider/ovp/ovp-provider.js index eda24b24..23d128eb 100644 --- a/src/k-provider/ovp/ovp-provider.js +++ b/src/k-provider/ovp/ovp-provider.js @@ -49,7 +49,7 @@ export class OvpProvider { * @type {string} * @private */ - _pVersion: string; + _playerVersion: string; /** * @member - is anonymous * @type {boolean} @@ -69,46 +69,53 @@ export class OvpProvider { */ _dataLoader: DataLoaderManager; + /** + + * @member - Does UiConf should be loaded + + * @type {boolean} + + * @private + + */ + _loadUiConf: boolean; + /** * @constructor - * @param {string} pVersion The player version - * @param {number} partnerID The partner ID - * @param {string} [ks=""] The provider ks (has empty string as default value) - * @param {Object} [config] The provider config(optional) - * @param {string} [logLevel] The provider log level(optional) + * @param {Object} options The provider options */ - constructor(pVersion: string, partnerID: number, ks: string = "", config?: Object, logLevel?: string) { - this._pVersion = pVersion; - this.partnerID = partnerID; - this.ks = ks; + constructor(options: {playerVersion: string, partnerID: number, ks: string, config: Object, loadUiConf: boolean, logLevel?: string} = + {playerVersion: "", partnerID: 0, ks: "", config: {}, loadUiConf: false}) { + this._playerVersion = options.playerVersion; + this.partnerID = options.partnerID; + this.ks = options.ks; this._isAnonymous = !this.ks; - if (logLevel && this.LogLevel[logLevel]) { - setLogLevel(this.LogLevel[logLevel]); + this._loadUiConf = options.loadUiConf; + if (options.logLevel && this.LogLevel[options.logLevel]) { + setLogLevel(this.LogLevel[options.logLevel]); } - Configuration.set(config); + Configuration.set(options.config); } /** * Returns player json configuration * @function getConfig - * @param {string} entryId The entry ID - * @param {number} uiConfId The uiConf ID + * @param {string} entryId - The entry ID + * @param {number?} uiConfId - The uiConf ID * @returns {Promise} The provider config object as promise */ - getConfig(entryId?: string, uiConfId?: number): Promise { - if (uiConfId != null) { + getConfig(entryId: string, uiConfId?: number): Promise { + if (uiConfId !== null && uiConfId !== undefined) { this._uiConfId = uiConfId; } - this._dataLoader = new DataLoaderManager(this._pVersion, this.partnerID, this.ks); + this._dataLoader = new DataLoaderManager(this._playerVersion, this.partnerID, this.ks); return new Promise((resolve, reject) => { - if (this.validateParams(entryId, uiConfId)) { + if (entryId) { let ks: string = this.ks; if (!ks) { ks = "{1:result:ks}"; this._dataLoader.add(SessionLoader, {partnerId: this.partnerID}); } this._dataLoader.add(MediaEntryLoader, {entryId: entryId, ks: ks}); - this._dataLoader.add(UiConfigLoader, {uiConfId: uiConfId, ks: ks}); + if (this._loadUiConf) { + this._dataLoader.add(UiConfigLoader, {uiConfId: uiConfId, ks: ks}); + } this._dataLoader.fetchData() .then(response => { resolve(this.parseDataFromResponse(response)); @@ -179,16 +186,6 @@ export class OvpProvider { return (config); } - /** - * Parameters validation function - * @param {string} entryId The entry ID - * @param {number} uiConfId The uiConfID - * @returns {boolean} Is valid params - */ - validateParams(entryId?: string, uiConfId?: number): boolean { - return !!entryId || !!uiConfId; - } - /** * Get the log levels * @returns {Object} - The log levels of the player. diff --git a/test/src/k-provider/ovp/ovp-provider.spec.js b/test/src/k-provider/ovp/ovp-provider.spec.js index 8b4ab99a..1e051c0e 100644 --- a/test/src/k-provider/ovp/ovp-provider.spec.js +++ b/test/src/k-provider/ovp/ovp-provider.spec.js @@ -13,7 +13,7 @@ describe('OvpProvider.partnerId:1082342', function () { beforeEach(() => { sandbox = sinon.sandbox.create(); - provider = new OvpProvider(pVersion, partnerId); + provider = new OvpProvider({playerVersion: pVersion, partnerID: partnerId}); }); afterEach(() => { @@ -48,7 +48,7 @@ describe('OvpProvider.partnerId:1082342', function () { it('should return config with plugins and without drm data', (done) => { let entryID = "1_rsrdfext"; let uiConfID = 38621471; - provider = new OvpProvider(pVersion, partnerId); + provider = new OvpProvider({playerVersion: pVersion, partnerID: partnerId, loadUiConf: true}); sinon.stub(MultiRequestBuilder.prototype, "execute").callsFake( function () { return new Promise((resolve) => { @@ -129,7 +129,7 @@ describe('OvpProvider.partnerId:1068292', function () { beforeEach(() => { sandbox = sinon.sandbox.create(); - provider = new OvpProvider(pVersion, partnerId, ks); + provider = new OvpProvider({playerVersion: pVersion, partnerID: partnerId, ks: ks, loadUiConf: true}); }); afterEach(() => { @@ -234,14 +234,17 @@ describe('OvpProvider.partnerId:1068292', function () { }); describe('logger', () => { + let partnerId = 1068292; + let pVersion = '1.2.3'; + it('should return the current log level', () => { - const provider = new OvpProvider("xyz", "xyz"); + const provider = new OvpProvider({playerVersion: pVersion, partnerID: partnerId}); const currentLogLevel = provider.getLogLevel(); currentLogLevel.should.equal(provider.LogLevel.ERROR); }); it('should enable setting the current log level', () => { - const provider = new OvpProvider("xyz", "xyz"); + const provider = new OvpProvider({playerVersion: pVersion, partnerID: partnerId}); let currentLogLevel = provider.getLogLevel(); currentLogLevel.should.equal(provider.LogLevel.ERROR); provider.setLogLevel(provider.LogLevel.WARN);