Skip to content

Commit

Permalink
Merge branch 'release/v1.1.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
moser4035 committed Sep 21, 2017
2 parents dbfa553 + a9f06ad commit d073925
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bitmovin/account/account.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import urljoin from 'url-join';
import http from '../http';
import organizations from './organizations/organizations.js';
import contactDetails from './billing/contactDetails.js';
import billing from './billing/billing';

export const account = (configuration, http) => {
const { get, post } = http;
Expand Down Expand Up @@ -37,7 +37,7 @@ export const account = (configuration, http) => {
information,
login,
changePassword,
contactDetails: contactDetails(configuration),
billing: billing(configuration),
organizations: organizations(configuration)
};
};
Expand Down
13 changes: 13 additions & 0 deletions bitmovin/account/billing/billing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import statements from './statements';
import invoices from './invoices';
import contactDetails from './contactDetails';

const billing = (configuration) => {
return {
statements: statements(configuration),
invoices: invoices(configuration),
contactDetails: contactDetails(configuration)
}
};

export default billing;
52 changes: 52 additions & 0 deletions bitmovin/account/billing/invoices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import urljoin from 'url-join';
import http, { utils } from '../../http';

export const invoices = (configuration, http) => {
const invoicesBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'billing', 'invoices');
const {get} = http;

return {
encoding: {
list: (limit, offset) => {
let url = urljoin(invoicesBaseUrl, 'encoding');
let getParams = utils.buildGetParamString({
limit : limit,
offset: offset
});
if (getParams.length > 0) {
url = urljoin(url, getParams);
}
return get(configuration, url);
}
},
player: {
list: (limit, offset) => {
let url = urljoin(invoicesBaseUrl, 'player');
let getParams = utils.buildGetParamString({
limit : limit,
offset: offset
});
if (getParams.length > 0) {
url = urljoin(url, getParams);
}
return get(configuration, url);
}
},
analytics: {
list: (limit, offset) => {
let url = urljoin(invoicesBaseUrl, 'analytics');
let getParams = utils.buildGetParamString({
limit : limit,
offset: offset
});
if (getParams.length > 0) {
url = urljoin(url, getParams);
}
return get(configuration, url);
}
}
}
};

export default (configuration) => { return invoices(configuration, http); };

52 changes: 52 additions & 0 deletions bitmovin/account/billing/statements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import urljoin from 'url-join';
import http, { utils } from '../../http';

export const statements = (configuration, http) => {
const statementsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'billing', 'statements');
const {get} = http;

return {
encoding: {
list: (limit, offset) => {
let url = urljoin(statementsBaseUrl, 'encoding');
let getParams = utils.buildGetParamString({
limit : limit,
offset: offset
});
if (getParams.length > 0) {
url = urljoin(url, getParams);
}
return get(configuration, url);
}
},
player: {
list: (limit, offset) => {
let url = urljoin(statementsBaseUrl, 'player');
let getParams = utils.buildGetParamString({
limit : limit,
offset: offset
});
if (getParams.length > 0) {
url = urljoin(url, getParams);
}
return get(configuration, url);
}
},
analytics: {
list: (limit, offset) => {
let url = urljoin(statementsBaseUrl, 'analytics');
let getParams = utils.buildGetParamString({
limit : limit,
offset: offset
});
if (getParams.length > 0) {
url = urljoin(url, getParams);
}
return get(configuration, url);
}
}
}
};

export default (configuration) => { return statements(configuration, http); };

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.17",
"bitmovin-javascript": "1.1.18",
"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.17",
"version": "1.1.18",
"scripts": {
"lint": "./node_modules/eslint/bin/eslint.js --color ./bitmovin",
"test": "node scripts/testRunner.js tests/",
Expand Down
68 changes: 68 additions & 0 deletions tests/account/billing/invoices.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { invoices } from '../../../bitmovin/account/billing/invoices'
import { getConfiguration } from '../../utils';
import {
mockGet,
mockHttp,
assertItReturnsUnderlyingPromise,
assertItCallsCorrectUrl,
testSetup,
} from '../../assertions';

let testConfiguration = getConfiguration();

describe('account', () => {
beforeEach(testSetup);
describe('billing', () => {
describe('invoices/encodings', () => {
const client = invoices(testConfiguration, mockHttp);
describe('list', () => {
assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/encoding', client.encoding.list);
assertItReturnsUnderlyingPromise(mockGet, client.encoding.list);
});

describe('list with limit offset', () => {
const limit = 100;
const offset = 15;
const expectedGetParameters = '\\?limit\=' + limit + '\&offset=' + offset;

assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/encoding' + expectedGetParameters, () => client.encoding.list(limit, offset));
assertItReturnsUnderlyingPromise(mockGet, client.encoding.list);
});
});

describe('invoices/player', () => {
const client = invoices(testConfiguration, mockHttp);
describe('list', () => {
assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/player', client.player.list);
assertItReturnsUnderlyingPromise(mockGet, client.player.list);
});

describe('list with limit offset', () => {
const limit = 100;
const offset = 15;
const expectedGetParameters = '\\?limit\=' + limit + '\&offset=' + offset;

assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/player' + expectedGetParameters, () => client.player.list(limit, offset));
assertItReturnsUnderlyingPromise(mockGet, client.encoding.list);
});
});

describe('invoices/analytics', () => {
const client = invoices(testConfiguration, mockHttp);
describe('list', () => {
assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/analytics', client.analytics.list);
assertItReturnsUnderlyingPromise(mockGet, client.player.list);
});

describe('list with limit offset', () => {
const limit = 100;
const offset = 15;
const expectedGetParameters = '\\?limit\=' + limit + '\&offset=' + offset;

assertItCallsCorrectUrl('GET', '/v1/account/billing/invoices/analytics' + expectedGetParameters, () => client.analytics.list(limit, offset));
assertItReturnsUnderlyingPromise(mockGet, client.encoding.list);
});
});
});
});

68 changes: 68 additions & 0 deletions tests/account/billing/statements.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { statements } from '../../../bitmovin/account/billing/statements';
import { getConfiguration } from '../../utils';
import {
mockGet,
mockHttp,
assertItReturnsUnderlyingPromise,
assertItCallsCorrectUrl,
testSetup,
} from '../../assertions';

let testConfiguration = getConfiguration();

describe('account', () => {
beforeEach(testSetup);
describe('billing', () => {
describe('statements/encodings', () => {
const client = statements(testConfiguration, mockHttp);
describe('list', () => {
assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/encoding', client.encoding.list);
assertItReturnsUnderlyingPromise(mockGet, client.encoding.list);
});

describe('list with limit offset', () => {
const limit = 100;
const offset = 15;
const expectedGetParameters = '\\?limit\=' + limit + '\&offset=' + offset;

assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/encoding' + expectedGetParameters, () => client.encoding.list(limit, offset));
assertItReturnsUnderlyingPromise(mockGet, client.encoding.list);
});
});

describe('statements/player', () => {
const client = statements(testConfiguration, mockHttp);
describe('list', () => {
assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/player', client.player.list);
assertItReturnsUnderlyingPromise(mockGet, client.player.list);
});

describe('list with limit offset', () => {
const limit = 100;
const offset = 15;
const expectedGetParameters = '\\?limit\=' + limit + '\&offset=' + offset;

assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/player' + expectedGetParameters, () => client.player.list(limit, offset));
assertItReturnsUnderlyingPromise(mockGet, client.encoding.list);
});
});

describe('statements/analytics', () => {
const client = statements(testConfiguration, mockHttp);
describe('list', () => {
assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/analytics', client.analytics.list);
assertItReturnsUnderlyingPromise(mockGet, client.player.list);
});

describe('list with limit offset', () => {
const limit = 100;
const offset = 15;
const expectedGetParameters = '\\?limit\=' + limit + '\&offset=' + offset;

assertItCallsCorrectUrl('GET', '/v1/account/billing/statements/analytics' + expectedGetParameters, () => client.analytics.list(limit, offset));
assertItReturnsUnderlyingPromise(mockGet, client.encoding.list);
});
});
});
});

0 comments on commit d073925

Please sign in to comment.