Skip to content

Commit

Permalink
Finish v1.1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaskroepfl committed Sep 22, 2017
2 parents d073925 + e2b7b34 commit 1479fda
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 5 deletions.
36 changes: 36 additions & 0 deletions bitmovin/analytics/statistics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import urljoin from 'url-join';
import http, {utils} from '../http';
import BitmovinError from '../BitmovinError';

export const statistics = (configuration, http) => {
const { get } = http;

return {
impressions: (licenseKeyId, start, end, interval, offset, limit) => {
if (!licenseKeyId || !start || !end) {
return Promise.reject(new BitmovinError('Not all required params given.'))
}

const analyticsStatisticsBaseUrl = urljoin(configuration.apiBaseUrl, '/analytics/statistics/impressions');

const getParams = utils.buildGetParamString({
licenseKeyId,
start,
end,
interval,
offset,
limit
});

const url = urljoin(analyticsStatisticsBaseUrl, getParams);
return get(configuration, url);
},
INTERVAL: {
DAILY: 'DAILY'
}
};
};

export default (configuration) => {
return statistics(configuration, http);
};
6 changes: 4 additions & 2 deletions bitmovin/bitmovin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import playerStatistics from './player/statistics';
import analyticsLicenses from './analytics/licenses';
import analyticsQueries from './analytics/queries';
import analyticsImpressions from './analytics/impressions';
import analyticsStatistics from './analytics/statistics';

import logger from './Logger';
import utils from './Utils';
Expand Down Expand Up @@ -68,7 +69,7 @@ export default class Bitmovin {
'X-Api-Key' : configuration.apiKey,
'X-Tenant-Org-Id' : configuration.tenantOrgId,
'X-Api-Client' : configuration.xApiClient,
'X-Api-Client-Version': '1.1.17'
'X-Api-Client-Version': '1.1.19'
};

this.configuration = configuration;
Expand All @@ -93,7 +94,8 @@ export default class Bitmovin {
this.analytics = {
licenses: analyticsLicenses(this.configuration),
queries: analyticsQueries(this.configuration),
impressions: analyticsImpressions(this.configuration)
impressions: analyticsImpressions(this.configuration),
statistics: analyticsStatistics(this.configuration)
};

this.account = account(this.configuration);
Expand Down
6 changes: 5 additions & 1 deletion bitmovin/player/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const statistics = (configuration, http) => {
const { get } = http;

return {
impressions: (licenseKeyId, start, end, offset, limit) => {
impressions: (licenseKeyId, start, end, interval, offset, limit) => {
if (!licenseKeyId || !start || !end) {
return Promise.reject(new BitmovinError('Not all required params given.'))
}
Expand All @@ -17,12 +17,16 @@ export const statistics = (configuration, http) => {
licenseKeyId,
start,
end,
interval,
offset,
limit
});

const url = urljoin(playerStatisticsBaseUrl, getParams);
return get(configuration, url);
},
INTERVAL: {
DAILY: 'DAILY'
}
};
};
Expand Down
2 changes: 1 addition & 1 deletion examples/encoding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bitmovin-javascript-examples",
"version": "0.0.1",
"dependencies": {
"bitmovin-javascript": "1.1.18",
"bitmovin-javascript": "1.1.19",
"bluebird": "^3.4.7"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitmovin-javascript",
"version": "1.1.18",
"version": "1.1.19",
"scripts": {
"lint": "./node_modules/eslint/bin/eslint.js --color ./bitmovin",
"test": "node scripts/testRunner.js tests/",
Expand Down
34 changes: 34 additions & 0 deletions tests/analytics/statistics.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { getConfiguration } from '../utils';
import { statistics } from '../../bitmovin/analytics/statistics';

import {
mockGet,
mockHttp,
assertItReturnsUnderlyingPromise,
assertItCallsCorrectUrl,
testSetup
} from '../assertions';

let testConfiguration = getConfiguration();

describe('analytics', () => {
const statisticsClient = statistics(testConfiguration, mockHttp);
beforeEach(testSetup);

describe('statistics', () => {
describe('impressions', () => {
describe('impressions default interval', () => {
assertItCallsCorrectUrl('GET', '/v1/analytics/statistics/impressions',
statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02'));
assertItReturnsUnderlyingPromise(mockGet,
statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02'));
});
describe('impressions daily interval', () => {
assertItCallsCorrectUrl('GET', '/v1/analytics/statistics/impressions',
statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02', statisticsClient.INTERVAL.DAILY));
assertItReturnsUnderlyingPromise(mockGet,
statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02', statisticsClient.INTERVAL.DAILY));
});
});
});
});
34 changes: 34 additions & 0 deletions tests/player/statistics.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { getConfiguration } from '../utils';
import { statistics } from '../../bitmovin/player/statistics';

import {
mockGet,
mockHttp,
assertItReturnsUnderlyingPromise,
assertItCallsCorrectUrl,
testSetup
} from '../assertions';

let testConfiguration = getConfiguration();

describe('player', () => {
const statisticsClient = statistics(testConfiguration, mockHttp);
beforeEach(testSetup);

describe('statistics', () => {
describe('impressions', () => {
describe('impressions default interval', () => {
assertItCallsCorrectUrl('GET', '/v1/player/statistics/impressions',
statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02'));
assertItReturnsUnderlyingPromise(mockGet,
statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02'));
});
describe('impressions daily interval', () => {
assertItCallsCorrectUrl('GET', '/v1/player/statistics/impressions',
statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02', statisticsClient.INTERVAL.DAILY));
assertItReturnsUnderlyingPromise(mockGet,
statisticsClient.impressions.bind(this, 'asdf', '2017-01-01', '2017-01-02', statisticsClient.INTERVAL.DAILY));
});
});
});
});

0 comments on commit 1479fda

Please sign in to comment.