Skip to content

Commit 69bfce3

Browse files
authored
Merge pull request topcoder-platform#42 from topcoder-platform/develop
Develop
2 parents 19422d4 + b3bf8b3 commit 69bfce3

File tree

24 files changed

+327
-2957
lines changed

24 files changed

+327
-2957
lines changed

__tests__/__snapshots__/index.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ Object {
237237
"services": Object {
238238
"api": Object {
239239
"default": [Function],
240+
"getApi": [Function],
240241
"getApiV2": [Function],
241242
"getApiV3": [Function],
242243
"getApiV4": [Function],

__tests__/services/api.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jest.mock(
55
);
66

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

1010
describe('Test api', () => {
1111
const ENDPOINT = '/ENDPOINT';
@@ -79,43 +79,43 @@ describe('Test api', () => {
7979

8080
let api;
8181
test('API v2 service works without auth token', () => {
82-
api = getApiV2();
82+
api = getApi('V2');
8383
return testApi(api, config.API.V2);
8484
});
8585

8686
test('API v2 service works with auth token', () => {
87-
api = getApiV2('TOKEN');
87+
api = getApi('V2', 'TOKEN');
8888
return testApi(api, config.API.V2, 'TOKEN');
8989
});
9090

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

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

102102
test('API v3 service works without auth token', () => {
103-
api = getApiV3();
103+
api = getApi('V3');
104104
return testApi(api, config.API.V3);
105105
});
106106

107107
test('API v3 service works with auth token', () => {
108-
api = getApiV3('TOKEN');
108+
api = getApi('V3', 'TOKEN');
109109
return testApi(api, config.API.V3, 'TOKEN');
110110
});
111111

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

117117
test('New API v3 service is created if token is new', () => {
118-
const api2 = getApiV3('TOKEN2');
118+
const api2 = getApi('V3', 'TOKEN2');
119119
expect(api2).not.toBe(api);
120120
return testApi(api2, config.API.V3, 'TOKEN2');
121121
});

dist/dev/index.js

Lines changed: 0 additions & 1421 deletions
This file was deleted.

dist/prod/index.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/services.api.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ This module provides a service for conventient access to Topcoder APIs.
77
* [services.api](#module_services.api)
88
* _static_
99
* [.default](#module_services.api.default)
10-
* [.getApiV2(token)](#module_services.api.getApiV2) ⇒ <code>Api</code>
11-
* [.getApiV3(token)](#module_services.api.getApiV3) ⇒ <code>Api</code>
10+
* [.getApi(version, token)](#module_services.api.getApi) ⇒ <code>Api</code>
1211
* _inner_
1312
* [~Api](#module_services.api..Api)
1413
* [new Api(base, token)](#new_module_services.api..Api_new)
@@ -30,30 +29,19 @@ The default export from the module is
3029
[Api](#module_services.api..Api) class.
3130

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

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

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

4140
| Param | Type | Description |
4241
| --- | --- | --- |
42+
| version | <code>String</code> | The version of the API. |
4343
| token | <code>String</code> | Optional. Auth token for Topcoder API v2. |
4444

45-
<a name="module_services.api.getApiV3"></a>
46-
47-
### services.api.getApiV3(token) ⇒ <code>Api</code>
48-
Returns a new or existing Api object for Topcoder API v3
49-
50-
**Kind**: static method of [<code>services.api</code>](#module_services.api)
51-
**Returns**: <code>Api</code> - API v3 service object.
52-
53-
| Param | Type | Description |
54-
| --- | --- | --- |
55-
| token | <code>String</code> | Optional. Auth token for Topcoder API v3. |
56-
5745
<a name="module_services.api..Api"></a>
5846

5947
### services.api~Api

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy