From 9b3da5d6dd6c25906db6b0a24aed404f9d040da9 Mon Sep 17 00:00:00 2001 From: Huan Li Date: Wed, 24 Apr 2019 18:59:43 +0800 Subject: [PATCH 1/4] Remove V2 API from Dashboard and Profile Page --- __tests__/__snapshots__/index.js.snap | 6 +++ .../actions/__snapshots__/profile.js.snap | 1 + package-lock.json | 41 +++++-------------- src/actions/members.js | 18 ++++++++ src/actions/profile.js | 14 ++++++- src/actions/settings.js | 3 +- src/reducers/members.js | 1 + src/reducers/profile.js | 21 ++++++++++ src/services/user.js | 12 +++++- src/utils/tc.js | 12 ++++++ 10 files changed, 95 insertions(+), 34 deletions(-) diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap index 180895cd..444821e9 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap @@ -69,6 +69,7 @@ Object { "dropAll": [Function], "getAchievementsDone": [Function], "getAchievementsInit": [Function], + "getAchievementsV3Done": [Function], "getActiveChallengesDone": [Function], "getActiveChallengesInit": [Function], "getFinancesDone": [Function], @@ -98,6 +99,7 @@ Object { "deleteWebLinkInit": [Function], "getAchievementsDone": [Function], "getAchievementsInit": [Function], + "getAchievementsV3Done": [Function], "getCredentialDone": [Function], "getCredentialInit": [Function], "getEmailPreferencesDone": [Function], @@ -206,14 +208,17 @@ Object { "countReset": [Function], "debug": [Function], "dir": [Function], + "dirxml": [Function], "error": [Function], "group": [Function], "groupCollapsed": [Function], "groupEnd": [Function], "info": [Function], "log": [Function], + "table": [Function], "time": [Function], "timeEnd": [Function], + "timeLog": [Function], "trace": [Function], "warn": [Function], }, @@ -318,6 +323,7 @@ Object { "Spec Review": "Specification Review", }, "getApiResponsePayload": [Function], + "getApiResponsePayloadV3": [Function], "getLookerApiResponsePayload": [Function], }, "time": Object { diff --git a/__tests__/actions/__snapshots__/profile.js.snap b/__tests__/actions/__snapshots__/profile.js.snap index 3ae1356e..b784f238 100644 --- a/__tests__/actions/__snapshots__/profile.js.snap +++ b/__tests__/actions/__snapshots__/profile.js.snap @@ -14,6 +14,7 @@ Object { "deleteWebLinkInit": [Function], "getAchievementsDone": [Function], "getAchievementsInit": [Function], + "getAchievementsV3Done": [Function], "getCredentialDone": [Function], "getCredentialInit": [Function], "getEmailPreferencesDone": [Function], diff --git a/package-lock.json b/package-lock.json index 05183fd7..abdb3ada 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6849,8 +6849,7 @@ "ansi-regex": { "version": "2.1.1", "resolved": false, - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "optional": true + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "aproba": { "version": "1.2.0", @@ -6871,14 +6870,12 @@ "balanced-match": { "version": "1.0.0", "resolved": false, - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "optional": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -6893,20 +6890,17 @@ "code-point-at": { "version": "1.1.0", "resolved": false, - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "optional": true + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "concat-map": { "version": "0.0.1", "resolved": false, - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "optional": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "console-control-strings": { "version": "1.1.0", "resolved": false, - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "optional": true + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, "core-util-is": { "version": "1.0.2", @@ -7023,8 +7017,7 @@ "inherits": { "version": "2.0.3", "resolved": false, - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "optional": true + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "ini": { "version": "1.3.5", @@ -7036,7 +7029,6 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7051,7 +7043,6 @@ "version": "3.0.4", "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7059,14 +7050,12 @@ "minimist": { "version": "0.0.8", "resolved": false, - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "optional": true + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7085,7 +7074,6 @@ "version": "0.5.1", "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "optional": true, "requires": { "minimist": "0.0.8" } @@ -7166,8 +7154,7 @@ "number-is-nan": { "version": "1.0.1", "resolved": false, - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "optional": true + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, "object-assign": { "version": "4.1.1", @@ -7179,7 +7166,6 @@ "version": "1.4.0", "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "optional": true, "requires": { "wrappy": "1" } @@ -7265,8 +7251,7 @@ "safe-buffer": { "version": "5.1.1", "resolved": false, - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "optional": true + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" }, "safer-buffer": { "version": "2.1.2", @@ -7302,7 +7287,6 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7322,7 +7306,6 @@ "version": "3.0.1", "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7366,14 +7349,12 @@ "wrappy": { "version": "1.0.2", "resolved": false, - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "optional": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "yallist": { "version": "3.0.2", "resolved": false, - "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "optional": true + "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=" } } }, diff --git a/src/actions/members.js b/src/actions/members.js index 34425a6d..38b25a1c 100644 --- a/src/actions/members.js +++ b/src/actions/members.js @@ -57,6 +57,23 @@ async function getAchievementsDone(handle, uuid) { return { data, handle, uuid }; } +/** + * @static + * @desc Creates an action that loads member achievements from v3 API. + * @param {String} handle Member handle. + * @param {String} uuid Loading operation + * @return {Action} + */ +async function getAchievementsV3Done(handle, uuid) { + let data; + try { + data = await getUserService().getAchievementsV3(handle); + } catch (e) { + data = []; + } + return { data, handle, uuid }; +} + /** * @static * @desc Creates an action that signals beginning of loading the member's @@ -344,6 +361,7 @@ export default createActions({ DROP_ALL: dropAll, GET_ACHIEVEMENTS_INIT: getAchievementsInit, GET_ACHIEVEMENTS_DONE: getAchievementsDone, + GET_ACHIEVEMENTS_V3_DONE: getAchievementsV3Done, GET_FINANCES_INIT: getFinancesInit, GET_FINANCES_DONE: getFinancesDone, GET_STATS_INIT: getStatsInit, diff --git a/src/actions/profile.js b/src/actions/profile.js index 3996263c..21643c99 100644 --- a/src/actions/profile.js +++ b/src/actions/profile.js @@ -31,7 +31,7 @@ function getAchievementsInit() {} /** * @static - * @desc Creates an action that loads user achievements. + * @desc Creates an action that loads user achievements from API v2. * @todo This duplicates similar action in {@link actions.members.md}! * @param {String} handle User handle. * @return {Action} @@ -40,6 +40,17 @@ function getAchievementsDone(handle) { return getUserService().getUserPublic(handle); } +/** + * @static + * @desc Creates an action that loads user achievements from API v3. + * @todo This duplicates similar action in {@link actions.members.md}! + * @param {String} handle User handle. + * @return {Action} + */ +function getAchievementsV3Done(handle) { + return getUserService().getUserPublicV3(handle); +} + /** * @static * @todo To be documented. @@ -450,6 +461,7 @@ export default createActions({ CLEAR_PROFILE: _.noop, GET_ACHIEVEMENTS_INIT: getAchievementsInit, GET_ACHIEVEMENTS_DONE: getAchievementsDone, + GET_ACHIEVEMENTS_V3_DONE: getAchievementsV3Done, GET_EXTERNAL_ACCOUNTS_INIT: getExternalAccountsInit, GET_EXTERNAL_ACCOUNTS_DONE: getExternalAccountsDone, GET_EXTERNAL_LINKS_INIT: getExternalLinksInit, diff --git a/src/actions/settings.js b/src/actions/settings.js index f0f506f3..7c538300 100644 --- a/src/actions/settings.js +++ b/src/actions/settings.js @@ -10,11 +10,10 @@ import { getService } from '../services/user-traits'; /** * @static * @desc Creates an action that loads user's all traits. - * @param {String} uuid Operation UUID. + * @param {String} handle the topcoder member handle * @param {String} tokenV3 v3 auth token. * @return {Action} */ - async function getAllUserTraits(handle, tokenV3) { const data = await getService(tokenV3).getAllUserTraits(handle); return { data, handle }; diff --git a/src/reducers/members.js b/src/reducers/members.js index f4cce8cf..23d0a08b 100644 --- a/src/reducers/members.js +++ b/src/reducers/members.js @@ -438,6 +438,7 @@ function create(initialState = {}) { [a.dropAll]: onDropAll, [a.getAchievementsInit]: onGetAchievementsInit, [a.getAchievementsDone]: onGetAchievementsDone, + [a.getAchievementsV3Done]: onGetAchievementsDone, [a.getFinancesInit]: onGetFinancesInit, [a.getFinancesDone]: onGetFinancesDone, [a.getStatsInit]: onGetStatsInit, diff --git a/src/reducers/profile.js b/src/reducers/profile.js index 1d7711a7..875dc582 100644 --- a/src/reducers/profile.js +++ b/src/reducers/profile.js @@ -29,6 +29,26 @@ function onGetAchievementsDone(state, { payload, error }) { }); } +/** + * Handles PROFILE/GET_ACHIEVEMENTS_V3_DONE action. + * @param {Object} state + * @param {Object} action Payload will be JSON from api call + * @return {Object} New state + */ +function onGetAchievementsV3Done(state, { payload, error }) { + if (error) { + return { ...state, loadingError: true }; + } + + return ({ + ...state, + achievements: payload.achievements || [], + copilot: payload.copilot, + country: payload.country, + loadingError: false, + }); +} + /** * Handles PROFILE/GET_EXTERNAL_ACCOUNTS_DONE action. * @param {Object} state @@ -490,6 +510,7 @@ function create(initialState) { [a.loadProfile]: (state, action) => ({ ...state, profileForHandle: action.payload }), [a.getAchievementsInit]: state => state, [a.getAchievementsDone]: onGetAchievementsDone, + [a.getAchievementsV3Done]: onGetAchievementsV3Done, [a.getExternalAccountsInit]: state => state, [a.getExternalAccountsDone]: onGetExternalAccountsDone, [a.getExternalLinksInit]: state => state, diff --git a/src/services/user.js b/src/services/user.js index 7da7f53b..ff1a780e 100644 --- a/src/services/user.js +++ b/src/services/user.js @@ -6,7 +6,7 @@ import { config, isomorphy } from 'topcoder-react-utils'; import logger from '../utils/logger'; -import { getApiResponsePayload } from '../utils/tc'; +import { getApiResponsePayload, getApiResponsePayloadV3 } from '../utils/tc'; import { getApi } from './api'; let auth0; @@ -141,6 +141,16 @@ class User { return res.json() || null; } + /** + * Gets public user info from v3 API. Does not need auth. + * @param {String} username + * @return {Object} + */ + async getUserPublicV3(username) { + const res = await this.private.api.get(`/members/${username}`); + return getApiResponsePayloadV3(res); + } + /** * Gets user data object for the specified username. * diff --git a/src/utils/tc.js b/src/utils/tc.js index 16d47b3d..3ea8a786 100644 --- a/src/utils/tc.js +++ b/src/utils/tc.js @@ -38,6 +38,18 @@ export async function getApiResponsePayload(res) { return x.content; } +/** + * Gets payload from a standard success response from TC API v3; or throws + * an error in case of a failure response. + * @param {Object} res + * @return {Promise} Resolves to the payload. + */ +export async function getApiResponsePayloadV3(res) { + if (!res.ok) throw new Error(res.statusText); + const x = (await res.json()).result; + if (!x.success) throw new Error(x.content); + return x.content; +} /** * Gets payload from a standard success response from TC LOOKER API; or throws From b93239de25b6dd871da904d76914efe4a4277bb4 Mon Sep 17 00:00:00 2001 From: Huan Li Date: Wed, 24 Apr 2019 19:44:00 +0800 Subject: [PATCH 2/4] Update docs of Remove v2 API --- docs/actions.members.md | 15 ++++++++++++++- docs/actions.profile.md | 10 +++++++++- docs/reducers.members.md | 19 ++++++++++++++++++- docs/reducers.profile.md | 18 +++++++++++++++++- docs/services.user.md | 15 ++++++++++++++- docs/tc.md | 15 ++++++++++++++- 6 files changed, 86 insertions(+), 6 deletions(-) diff --git a/docs/actions.members.md b/docs/actions.members.md index 7a04f558..0a0e18e8 100644 --- a/docs/actions.members.md +++ b/docs/actions.members.md @@ -9,6 +9,7 @@ Actions related to members data. * [.dropAll()](#module_actions.members.dropAll) ⇒ Action * [.getAchievementsInit(handle, uuid)](#module_actions.members.getAchievementsInit) ⇒ Action * [.getAchievementsDone(handle, uuid)](#module_actions.members.getAchievementsDone) ⇒ Action + * [.getAchievementsV3Done(handle, uuid)](#module_actions.members.getAchievementsV3Done) ⇒ Action * [.getFinancesInit(handle, uuid)](#module_actions.members.getFinancesInit) ⇒ Action * [.getFinancesDone(handle, uuid, tokenV3)](#module_actions.members.getFinancesDone) ⇒ Action * [.getStatsInit(handle, uuid)](#module_actions.members.getStatsInit) ⇒ Action @@ -55,7 +56,19 @@ Creates an action that signals beginning of member achievements ### actions.members.getAchievementsDone(handle, uuid) ⇒ Action -Creates an action that loads member achievements. +Creates an action that loads member achievements from v2 API. + +**Kind**: static method of [actions.members](#module_actions.members) + +| Param | Type | Description | +| --- | --- | --- | +| handle | String | Member handle. | +| uuid | String | Loading operation | + + + +### actions.members.getAchievementsV3Done(handle, uuid) ⇒ Action +Creates an action that loads member achievements from v3 API. **Kind**: static method of [actions.members](#module_actions.members) diff --git a/docs/actions.profile.md b/docs/actions.profile.md index 528d0612..9129918d 100644 --- a/docs/actions.profile.md +++ b/docs/actions.profile.md @@ -14,6 +14,7 @@ Actions for interactions with profile details API. * [.clearProfile()](#module_actions.profile.clearProfile) ⇒ Action * [.getAchievementsInit()](#module_actions.profile.getAchievementsInit) ⇒ Action * [.getAchievementsDone(handle)](#module_actions.profile.getAchievementsDone) ⇒ Action + * [.getAchievementsV3Done(handle)](#module_actions.profile.getAchievementsV3Done) ⇒ Action * [.getExternalAccountsInit()](#module_actions.profile.getExternalAccountsInit) ⇒ Action * [.getExternalAccountsDone(handle)](#module_actions.profile.getExternalAccountsDone) ⇒ Action * [.getExternalLinksInit()](#module_actions.profile.getExternalLinksInit) ⇒ Action @@ -94,7 +95,7 @@ Creates an action that signals beginning of user achievements loading. ### actions.profile.getAchievementsDone(handle) ⇒ Action -Creates an action that loads user achievements. +Creates an action that loads user achievements from v2 API. **Kind**: static method of [actions.profile](#module_actions.profile) **Todo** @@ -106,6 +107,13 @@ Creates an action that loads user achievements. | --- | --- | --- | | handle | String | User handle. | + + +### actions.profile.getAchievementsV3Done(handle) ⇒ Action +Creates an action that loads user achievements from V3 API. + +**Kind**: static method of [actions.profile](#module_actions.profile) + ### actions.profile.getExternalAccountsInit() ⇒ Action diff --git a/docs/reducers.members.md b/docs/reducers.members.md index 4d75fcfc..56811eb3 100644 --- a/docs/reducers.members.md +++ b/docs/reducers.members.md @@ -17,6 +17,7 @@ Reducer for the Redux store segment that holds members data. * [~onDropAll()](#module_reducers.members..onDropAll) ⇒ Object * [~onGetAchievementsInit(state)](#module_reducers.members..onGetAchievementsInit) ⇒ Object * [~onGetAchievementsDone(state, error)](#module_reducers.members..onGetAchievementsDone) ⇒ Object + * [~onGetAchievementsV3Done(state, error)](#module_reducers.members..onGetAchievementsV3Done) ⇒ Object * [~onGetFinancesInit(state)](#module_reducers.members..onGetFinancesInit) ⇒ Object * [~onGetFinancesDone(state, action)](#module_reducers.members..onGetFinancesDone) ⇒ Object * [~onGetStatsInit(state, action)](#module_reducers.members..onGetStatsInit) ⇒ Object @@ -81,7 +82,23 @@ Inits the loading of member achievements. ### reducers.members~onGetAchievementsDone(state, error) ⇒ Object -Finalizes the loading of member achievements. +Finalizes the loading of member achievements from v2 API. + +**Kind**: inner method of [reducers.members](#module_reducers.members) +**Returns**: Object - New state. + +| Param | Type | +| --- | --- | +| state | Object | +| error | Object | +| payload.data | Array | +| payload.handle | String | +| payload.uuid | String | + + + +### reducers.members~onGetAchievementsV3Done(state, error) ⇒ Object +Finalizes the loading of member achievements from v3 API. **Kind**: inner method of [reducers.members](#module_reducers.members) **Returns**: Object - New state. diff --git a/docs/reducers.profile.md b/docs/reducers.profile.md index 43d9ad78..21ae1d12 100644 --- a/docs/reducers.profile.md +++ b/docs/reducers.profile.md @@ -14,6 +14,7 @@ Actions for interactions with profile details API. * [.clearProfile()](#module_actions.profile.clearProfile) ⇒ Action * [.getAchievementsInit()](#module_actions.profile.getAchievementsInit) ⇒ Action * [.getAchievementsDone(handle)](#module_actions.profile.getAchievementsDone) ⇒ Action + * [.getAchievementsV3Done(handle)](#module_actions.profile.getAchievementsV3Done) ⇒ Action * [.getExternalAccountsInit()](#module_actions.profile.getExternalAccountsInit) ⇒ Action * [.getExternalAccountsDone(handle)](#module_actions.profile.getExternalAccountsDone) ⇒ Action * [.getExternalLinksInit()](#module_actions.profile.getExternalLinksInit) ⇒ Action @@ -94,7 +95,22 @@ Creates an action that signals beginning of user achievements loading. ### actions.profile.getAchievementsDone(handle) ⇒ Action -Creates an action that loads user achievements. +Creates an action that loads user achievements from v2 API. + +**Kind**: static method of [actions.profile](#module_actions.profile) +**Todo** + +- [ ] This duplicates similar action in [actions.members.md](actions.members.md)! + + +| Param | Type | Description | +| --- | --- | --- | +| handle | String | User handle. | + + + +### actions.profile.getAchievementsV3Done(handle) ⇒ Action +Creates an action that loads user achievements from v3 API. **Kind**: static method of [actions.profile](#module_actions.profile) **Todo** diff --git a/docs/services.user.md b/docs/services.user.md index de282529..fc039b68 100644 --- a/docs/services.user.md +++ b/docs/services.user.md @@ -14,6 +14,7 @@ The User service provides functionality related to Topcoder user * [new User(tokenV3, tokenV2)](#new_module_services.user..User_new) * [.getAchievements(username)](#module_services.user..User+getAchievements) ⇒ Object * [.getUserPublic(username)](#module_services.user..User+getUserPublic) ⇒ Object + * [.getUserPublicV3(username)](#module_services.user..User+getUserPublicV3) ⇒ Object * [.getUser(username)](#module_services.user..User+getUser) ⇒ Promise * [.getEmailPreferences(userId)](#module_services.user..User+getEmailPreferences) ⇒ Promise * [.saveEmailPreferences(user, preferences)](#module_services.user..User+saveEmailPreferences) ⇒ Promise @@ -54,6 +55,7 @@ Service class. * [new User(tokenV3, tokenV2)](#new_module_services.user..User_new) * [.getAchievements(username)](#module_services.user..User+getAchievements) ⇒ Object * [.getUserPublic(username)](#module_services.user..User+getUserPublic) ⇒ Object + * [.getUserPublicV3(username)](#module_services.user..User+getUserPublicV3) ⇒ Object * [.getUser(username)](#module_services.user..User+getUser) ⇒ Promise * [.getEmailPreferences(userId)](#module_services.user..User+getEmailPreferences) ⇒ Promise * [.saveEmailPreferences(user, preferences)](#module_services.user..User+saveEmailPreferences) ⇒ Promise @@ -88,7 +90,18 @@ Gets user achievements. Does not need auth. #### user.getUserPublic(username) ⇒ Object -Gets public user info. Does not need auth. +Gets public user info from v2 API. Does not need auth. + +**Kind**: instance method of [User](#module_services.user..User) + +| Param | Type | +| --- | --- | +| username | String | + + + +#### user.getUserPublicV3(username) ⇒ Object +Gets public user info from v3 API. Does not need auth. **Kind**: instance method of [User](#module_services.user..User) diff --git a/docs/tc.md b/docs/tc.md index e1e92105..60a67427 100644 --- a/docs/tc.md +++ b/docs/tc.md @@ -11,6 +11,7 @@ Collection of small Topcoder-related functions. * [tc](#module_tc) * [.REVIEW_OPPORTUNITY_TYPES](#module_tc.REVIEW_OPPORTUNITY_TYPES) * [.getApiResponsePayload(res)](#module_tc.getApiResponsePayload) ⇒ Promise + * [.getApiResponsePayloadV3(res)](#module_tc.getApiResponsePayloadV3) ⇒ Promise @@ -21,7 +22,7 @@ Review Opportunity types ### tc.getApiResponsePayload(res) ⇒ Promise -Gets payload from a standard success response from TC API; or throws +Gets payload from a standard success response from TC v2 API; or throws an error in case of a failure response. **Kind**: static method of [tc](#module_tc) @@ -31,3 +32,15 @@ an error in case of a failure response. | --- | --- | | res | Object | + + +### tc.getApiResponsePayloadV3(res) ⇒ Promise +Gets payload from a standard success response from TC v3 API; or throws +an error in case of a failure response. + +**Kind**: static method of [tc](#module_tc) +**Returns**: Promise - Resolves to the payload. + +| Param | Type | +| --- | --- | +| res | Object | From 99d378bb02f1675824f2bbd5b0e346b02d0d6468 Mon Sep 17 00:00:00 2001 From: Huan Li Date: Wed, 24 Apr 2019 22:03:46 +0800 Subject: [PATCH 3/4] Remove V2 API from Dashboard and Profile Page --- docs/tc.md | 13 ------------- src/services/user.js | 4 ++-- src/utils/tc.js | 13 ------------- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/docs/tc.md b/docs/tc.md index 60a67427..8e060798 100644 --- a/docs/tc.md +++ b/docs/tc.md @@ -11,7 +11,6 @@ Collection of small Topcoder-related functions. * [tc](#module_tc) * [.REVIEW_OPPORTUNITY_TYPES](#module_tc.REVIEW_OPPORTUNITY_TYPES) * [.getApiResponsePayload(res)](#module_tc.getApiResponsePayload) ⇒ Promise - * [.getApiResponsePayloadV3(res)](#module_tc.getApiResponsePayloadV3) ⇒ Promise @@ -32,15 +31,3 @@ an error in case of a failure response. | --- | --- | | res | Object | - - -### tc.getApiResponsePayloadV3(res) ⇒ Promise -Gets payload from a standard success response from TC v3 API; or throws -an error in case of a failure response. - -**Kind**: static method of [tc](#module_tc) -**Returns**: Promise - Resolves to the payload. - -| Param | Type | -| --- | --- | -| res | Object | diff --git a/src/services/user.js b/src/services/user.js index ff1a780e..802f5af3 100644 --- a/src/services/user.js +++ b/src/services/user.js @@ -6,7 +6,7 @@ import { config, isomorphy } from 'topcoder-react-utils'; import logger from '../utils/logger'; -import { getApiResponsePayload, getApiResponsePayloadV3 } from '../utils/tc'; +import { getApiResponsePayload } from '../utils/tc'; import { getApi } from './api'; let auth0; @@ -148,7 +148,7 @@ class User { */ async getUserPublicV3(username) { const res = await this.private.api.get(`/members/${username}`); - return getApiResponsePayloadV3(res); + return getApiResponsePayload(res); } /** diff --git a/src/utils/tc.js b/src/utils/tc.js index 3ea8a786..77fce85a 100644 --- a/src/utils/tc.js +++ b/src/utils/tc.js @@ -38,19 +38,6 @@ export async function getApiResponsePayload(res) { return x.content; } -/** - * Gets payload from a standard success response from TC API v3; or throws - * an error in case of a failure response. - * @param {Object} res - * @return {Promise} Resolves to the payload. - */ -export async function getApiResponsePayloadV3(res) { - if (!res.ok) throw new Error(res.statusText); - const x = (await res.json()).result; - if (!x.success) throw new Error(x.content); - return x.content; -} - /** * Gets payload from a standard success response from TC LOOKER API; or throws * an error in case of a failure response. From e1c8d7a330cf518caeaed101c7a3eb455fb4ab12 Mon Sep 17 00:00:00 2001 From: Huan Li Date: Wed, 24 Apr 2019 22:07:54 +0800 Subject: [PATCH 4/4] Update testing --- __tests__/__snapshots__/index.js.snap | 1 - 1 file changed, 1 deletion(-) diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap index 444821e9..47276ed3 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap @@ -323,7 +323,6 @@ Object { "Spec Review": "Specification Review", }, "getApiResponsePayload": [Function], - "getApiResponsePayloadV3": [Function], "getLookerApiResponsePayload": [Function], }, "time": Object { 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