Skip to content

Commit dbfa553

Browse files
author
dmoser
committed
Merge branch 'release/v1.1.17'
2 parents 1ea5a0c + 36358f8 commit dbfa553

File tree

13 files changed

+215
-49
lines changed

13 files changed

+215
-49
lines changed

bitmovin/account/account.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import urljoin from 'url-join';
22
import http from '../http';
33
import organizations from './organizations/organizations.js';
4+
import contactDetails from './billing/contactDetails.js';
45

56
export const account = (configuration, http) => {
67
const { get, post } = http;
@@ -36,6 +37,7 @@ export const account = (configuration, http) => {
3637
information,
3738
login,
3839
changePassword,
40+
contactDetails: contactDetails(configuration),
3941
organizations: organizations(configuration)
4042
};
4143
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import urljoin from 'url-join';
2+
import http from '../../http';
3+
4+
export const contactDetails = (configuration, http) => {
5+
const contactDetailsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'billing', 'contact-details');
6+
const {get, put} = http;
7+
8+
return {
9+
details: () => {
10+
return get(configuration, contactDetailsBaseUrl)
11+
},
12+
update: (contactDetails) => {
13+
return put(configuration, contactDetailsBaseUrl, contactDetails);
14+
}
15+
}
16+
};
17+
18+
export default (configuration) => { return contactDetails(configuration, http); };
19+

bitmovin/analytics/impressions.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import urljoin from 'url-join';
2+
import http, { utils } from '../http';
3+
4+
export const impressions = (configuration, http) => {
5+
const { post } = http;
6+
const impressionBaseUrl = urljoin(configuration.apiBaseUrl, 'analytics', 'impressions');
7+
8+
const fn = (impressionId, licenseKey) => {
9+
let url = urljoin(impressionBaseUrl, impressionId);
10+
return post(configuration, url, { licenseKey });
11+
};
12+
13+
return fn;
14+
};
15+
16+
export default (configuration) => { return impressions(configuration, http); };

bitmovin/bitmovin.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import playerLicenses from './player/licenses';
1414
import playerStatistics from './player/statistics';
1515
import analyticsLicenses from './analytics/licenses';
1616
import analyticsQueries from './analytics/queries';
17+
import analyticsImpressions from './analytics/impressions';
1718

1819
import logger from './Logger';
1920
import utils from './Utils';
@@ -67,7 +68,7 @@ export default class Bitmovin {
6768
'X-Api-Key' : configuration.apiKey,
6869
'X-Tenant-Org-Id' : configuration.tenantOrgId,
6970
'X-Api-Client' : configuration.xApiClient,
70-
'X-Api-Client-Version': '1.1.12'
71+
'X-Api-Client-Version': '1.1.17'
7172
};
7273

7374
this.configuration = configuration;
@@ -91,9 +92,10 @@ export default class Bitmovin {
9192

9293
this.analytics = {
9394
licenses: analyticsLicenses(this.configuration),
94-
queries : analyticsQueries(this.configuration)
95+
queries: analyticsQueries(this.configuration),
96+
impressions: analyticsImpressions(this.configuration)
9597
};
9698

97-
this.account = account(configuration);
99+
this.account = account(this.configuration);
98100
}
99101
}

bitmovin/encoding/statistics.js

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,54 @@ export const statistics = (configuration, http) => {
77
const { get } = http;
88

99
const typeFn = (type) => {
10-
return {
11-
daily: (options = {}) => {
12-
let url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings/', type , '/daily');
13-
let { limit, offset } = options;
10+
return {
11+
daily: (options = {}) => {
12+
let url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings/', type, '/daily');
13+
let { limit, offset } = options;
1414

15-
if (options !== {} && options.from && options.to) {
16-
if (!isValidApiRequestDateString(options.from) || !isValidApiRequestDateString(options.to)) {
17-
console.error('Wrong date format! Correct format is yyyy-MM-dd');
18-
return Promise.reject(new BitmovinError('Wrong date format! Correct format is yyyy-MM-dd', {}));
19-
}
20-
url = urljoin(url, options.from, options.to);
15+
if (options !== {} && options.from && options.to) {
16+
if (!isValidApiRequestDateString(options.from) || !isValidApiRequestDateString(options.to)) {
17+
console.error('Wrong date format! Correct format is yyyy-MM-dd');
18+
return Promise.reject(new BitmovinError('Wrong date format! Correct format is yyyy-MM-dd', {}));
2119
}
20+
url = urljoin(url, options.from, options.to);
21+
}
2222

23-
const getParams = utils.buildGetParamString({
24-
limit : limit,
25-
offset: offset
26-
});
23+
const getParams = utils.buildGetParamString({
24+
limit : limit,
25+
offset: offset
26+
});
2727

28-
if (getParams.length > 0) {
29-
url = urljoin(url, getParams);
30-
}
31-
return get(configuration, url);
32-
},
28+
if (getParams.length > 0) {
29+
url = urljoin(url, getParams);
30+
}
31+
return get(configuration, url);
32+
},
3333

34-
list: (options = {}) => {
35-
let url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings/', type);
36-
let { limit, offset } = options;
34+
list: (options = {}) => {
35+
let url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings/', type);
36+
let { limit, offset } = options;
3737

38-
if (options !== {} && options.from && options.to) {
39-
if (!isValidApiRequestDateString(options.from) || !isValidApiRequestDateString(options.to)) {
40-
console.error('Wrong date format! Correct format is yyyy-MM-dd');
41-
return Promise.reject(new BitmovinError('Wrong date format! Correct format is yyyy-MM-dd', {}));
42-
}
43-
url = urljoin(url, options.from, options.to);
38+
if (options !== {} && options.from && options.to) {
39+
if (!isValidApiRequestDateString(options.from) || !isValidApiRequestDateString(options.to)) {
40+
console.error('Wrong date format! Correct format is yyyy-MM-dd');
41+
return Promise.reject(new BitmovinError('Wrong date format! Correct format is yyyy-MM-dd', {}));
4442
}
43+
url = urljoin(url, options.from, options.to);
44+
}
4545

46-
const getParams = utils.buildGetParamString({
47-
limit : limit,
48-
offset: offset
49-
});
46+
const getParams = utils.buildGetParamString({
47+
limit : limit,
48+
offset: offset
49+
});
5050

51-
if (getParams.length > 0) {
52-
url = urljoin(url, getParams);
53-
}
54-
55-
return get(configuration, url);
51+
if (getParams.length > 0) {
52+
url = urljoin(url, getParams);
5653
}
54+
55+
return get(configuration, url);
5756
}
57+
}
5858
};
5959

6060
return {
@@ -70,8 +70,11 @@ export const statistics = (configuration, http) => {
7070
* from: Date
7171
* to: Date
7272
*/
73-
overall : () => {
74-
const url = urljoin(configuration.apiBaseUrl, 'encoding/statistics');
73+
overall : (from = null, to = null) => {
74+
let url = urljoin(configuration.apiBaseUrl, 'encoding/statistics');
75+
if (from && to) {
76+
url = urljoin(url, from, to);
77+
}
7578
return get(configuration, url);
7679
},
7780

@@ -80,6 +83,10 @@ export const statistics = (configuration, http) => {
8083

8184
encodings: (encodingId) => {
8285
return {
86+
statistics: () => {
87+
const url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings', encodingId);
88+
return get(configuration, url);
89+
},
8390
liveStatistics: () => {
8491
const url = urljoin(configuration.apiBaseUrl, 'encoding/statistics/encodings', encodingId, 'live-statistics');
8592
return get(configuration, url);

bitmovin/http.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Promise from 'bluebird';
66
const GET = 'GET';
77
const POST = 'POST';
88
const DELETE = 'DELETE';
9+
const PUT = 'PUT';
910

1011
const buildParams = (method, configuration, body) => {
1112
return {
@@ -61,6 +62,13 @@ const post = (configuration, url, object, fetchMethod = fetch) => {
6162
return request(configuration, POST, url, fetchMethod, body);
6263
};
6364

65+
const put = (configuration, url, object, fetchMethod = fetch) => {
66+
logger.log('Request payload will be: ' + JSON.stringify(object, undefined, 2));
67+
const body = JSON.stringify(object);
68+
69+
return request(configuration, PUT, url, fetchMethod, body);
70+
};
71+
6472
const delete_ = (configuration, url, fetchMethod = fetch) => {
6573
return request(configuration, DELETE, url, fetchMethod);
6674
};
@@ -108,6 +116,7 @@ const utils = {
108116
module.exports = {
109117
get,
110118
post,
119+
put,
111120
delete_,
112121
utils
113122
};

examples/encoding/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "bitmovin-javascript-examples",
33
"version": "0.0.1",
44
"dependencies": {
5-
"bitmovin-javascript": "1.1.12",
5+
"bitmovin-javascript": "1.1.17",
66
"bluebird": "^3.4.7"
77
}
88
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bitmovin-javascript",
3-
"version": "1.1.12",
3+
"version": "1.1.17",
44
"scripts": {
55
"lint": "./node_modules/eslint/bin/eslint.js --color ./bitmovin",
66
"test": "node scripts/testRunner.js tests/",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { contactDetails } from '../../../bitmovin/account/billing/contactDetails'
2+
3+
import {
4+
mockGet,
5+
mockPut,
6+
mockHttp,
7+
assertItReturnsUnderlyingPromise,
8+
assertItCallsCorrectUrl,
9+
testSetup,
10+
} from '../../assertions';
11+
12+
import {getConfiguration} from '../../utils';
13+
14+
let testConfiguration = getConfiguration();
15+
16+
describe('account', () => {
17+
beforeEach(testSetup);
18+
describe('billing', () => {
19+
describe('accountDetails', () => {
20+
const client = contactDetails(testConfiguration, mockHttp);
21+
describe('details', () => {
22+
assertItCallsCorrectUrl('GET', '/v1/account/billing/contact-details', client.details);
23+
assertItReturnsUnderlyingPromise(mockGet, client.details);
24+
});
25+
describe('update', () => {
26+
assertItCallsCorrectUrl('PUT', '/v1/account/billing/contact-details', client.update);
27+
assertItReturnsUnderlyingPromise(mockPut, client.update);
28+
});
29+
});
30+
});
31+
});
32+

tests/account/organizations/organizations.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ import {
55
mockPost,
66
mockDelete,
77
mockHttp,
8-
methodToMock,
9-
assertPayload,
108
assertItReturnsUnderlyingPromise,
119
assertItCallsCorrectUrl,
1210
testSetup,
13-
assertItReturnsPromise,
14-
assertItReturnsCorrectResponse
1511
} from '../../assertions';
1612

1713
import {getConfiguration} from '../../utils';

0 commit comments

Comments
 (0)