Skip to content

Commit

Permalink
feat: Making API version modifyable
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed Jul 23, 2018
1 parent f60e7ed commit a2732b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/infrastructure/BaseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import XMLHttpRequester from './XMLHttpRequester';

class BaseModel {
constructor({
url = 'https://gitlab.com', token, oauthToken, useXMLHttpRequest = false,
token,
oauthToken,
url = 'https://gitlab.com',
useXMLHttpRequest = false,
version = 'v4',
} = {}) {
this.url = URLJoin(url, 'api', 'v4');
this.url = URLJoin(url, 'api', version);
this.headers = {};
this.requester = useXMLHttpRequest ? XMLHttpRequester : Request;
this.useXMLHttpRequest = useXMLHttpRequest;
Expand Down
6 changes: 6 additions & 0 deletions test/tests/infrastructure/BaseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ describe('Creation of BaseService instance', () => {

expect(service.headers['private-token']).toBe('1234');
});

test('API version should be modified', async () => {
const service = new BaseService({ url: 'https://testing.com', token: '1234', version: 'v3' });

expect(service.url).toBe('https://testing.com/api/v3');
});
});

0 comments on commit a2732b9

Please sign in to comment.