Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Adapting for new V5 skills api #5

Merged
merged 8 commits into from
Aug 19, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Readded getUbahnResource helper
It was called by getUser method as well
  • Loading branch information
vikasrohit authored Aug 18, 2021
commit b917f0a1cb1c3c9d32ed9632823ade69c45e58ad
19 changes: 19 additions & 0 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ async function getV5SkillResource (path, params) {
return result
}

/**
* Get the ubahn record
* @param {String} path the resource path
* @param {String} params the query params
* @returns {Object} the u-bahn user
*/
async function getUbahnResource (path, params) {
const token = await getM2MUbahnToken()
const res = await axios.get(`${config.UBAHN_API_URL}/${path}`, {
params,
headers: { Authorization: `Bearer ${token}` }
})
const result = _.head(_.get(res, 'data'))
if (!result) {
throw Error(`Cannot find u-bahn resource ${path} with params ${JSON.stringify(params)}`)
}
return result
}

/**
* Create user skill
* @param {String} userId the user id
Expand Down