Skip to content

Develop #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ Object {
"services": Object {
"api": Object {
"default": [Function],
"getApi": [Function],
"getApiV2": [Function],
"getApiV3": [Function],
"getApiV4": [Function],
Expand Down
18 changes: 9 additions & 9 deletions __tests__/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jest.mock(
);

const { config } = require('topcoder-react-utils');
const { getApiV2, getApiV3 } = require('../../src/services/api');
const { getApi } = require('../../src/services/api');

describe('Test api', () => {
const ENDPOINT = '/ENDPOINT';
Expand Down Expand Up @@ -79,43 +79,43 @@ describe('Test api', () => {

let api;
test('API v2 service works without auth token', () => {
api = getApiV2();
api = getApi('V2');
return testApi(api, config.API.V2);
});

test('API v2 service works with auth token', () => {
api = getApiV2('TOKEN');
api = getApi('V2', 'TOKEN');
return testApi(api, config.API.V2, 'TOKEN');
});

test(
'API v2 service from the previous call is re-used, if token is the same',
() => expect(getApiV2('TOKEN')).toBe(api),
() => expect(getApi('V2', 'TOKEN')).toBe(api),
);

test('New API v2 service is created if token is new', () => {
const api2 = getApiV2('TOKEN2');
const api2 = getApi('V2', 'TOKEN2');
expect(api2).not.toBe(api);
return testApi(api2, config.API.V2, 'TOKEN2');
});

test('API v3 service works without auth token', () => {
api = getApiV3();
api = getApi('V3');
return testApi(api, config.API.V3);
});

test('API v3 service works with auth token', () => {
api = getApiV3('TOKEN');
api = getApi('V3', 'TOKEN');
return testApi(api, config.API.V3, 'TOKEN');
});

test(
'API v3 service from the previous call is re-used, if token is the same',
() => expect(getApiV3('TOKEN')).toBe(api),
() => expect(getApi('V3', 'TOKEN')).toBe(api),
);

test('New API v3 service is created if token is new', () => {
const api2 = getApiV3('TOKEN2');
const api2 = getApi('V3', 'TOKEN2');
expect(api2).not.toBe(api);
return testApi(api2, config.API.V3, 'TOKEN2');
});
Expand Down
1,421 changes: 0 additions & 1,421 deletions dist/dev/index.js

This file was deleted.

6 changes: 0 additions & 6 deletions dist/prod/index.js

This file was deleted.

24 changes: 6 additions & 18 deletions docs/services.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ This module provides a service for conventient access to Topcoder APIs.
* [services.api](#module_services.api)
* _static_
* [.default](#module_services.api.default)
* [.getApiV2(token)](#module_services.api.getApiV2) ⇒ <code>Api</code>
* [.getApiV3(token)](#module_services.api.getApiV3) ⇒ <code>Api</code>
* [.getApi(version, token)](#module_services.api.getApi) ⇒ <code>Api</code>
* _inner_
* [~Api](#module_services.api..Api)
* [new Api(base, token)](#new_module_services.api..Api_new)
Expand All @@ -30,30 +29,19 @@ The default export from the module is
[Api](#module_services.api..Api) class.

**Kind**: static property of [<code>services.api</code>](#module_services.api)
<a name="module_services.api.getApiV2"></a>
<a name="module_services.api.getApi"></a>

### services.api.getApiV2(token) ⇒ <code>Api</code>
Returns a new or existing Api object for Topcoder API v2.
### services.api.getApi(version, token) ⇒ <code>Api</code>
Returns a new or existing Api object for Topcoder API.

**Kind**: static method of [<code>services.api</code>](#module_services.api)
**Returns**: <code>Api</code> - API v2 service object.
**Returns**: <code>Api</code> - API service object.

| Param | Type | Description |
| --- | --- | --- |
| version | <code>String</code> | The version of the API. |
| token | <code>String</code> | Optional. Auth token for Topcoder API v2. |

<a name="module_services.api.getApiV3"></a>

### services.api.getApiV3(token) ⇒ <code>Api</code>
Returns a new or existing Api object for Topcoder API v3

**Kind**: static method of [<code>services.api</code>](#module_services.api)
**Returns**: <code>Api</code> - API v3 service object.

| Param | Type | Description |
| --- | --- | --- |
| token | <code>String</code> | Optional. Auth token for Topcoder API v3. |

<a name="module_services.api..Api"></a>

### services.api~Api
Expand Down
Loading