Skip to content

Commit

Permalink
#627: allow retrieving single journeys by ID instead of key
Browse files Browse the repository at this point in the history
IDs are visible in URL, Keys are not visible
  • Loading branch information
JoernBerkefeld committed Jan 13, 2023
1 parent 86a51f0 commit 4732b08
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/metadataTypes/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ class Interaction extends MetadataType {
* @returns {Promise.<TYPE.MetadataTypeMapObj>} Promise
*/
static retrieve(retrieveDir, _, __, ___, key) {
let singleKey = '';
if (key) {
/* eslint-disable unicorn/prefer-ternary */
if (key.startWidth('id:')) {
// ! allow selecting journeys by ID because that's what users see in the URL
singleKey = '/' + encodeURIComponent(key);
} else {
singleKey = '/key:' + encodeURIComponent(key);
}
/* eslint-enable unicorn/prefer-ternary */
}
return super.retrieveREST(
retrieveDir,
`/interaction/v1/interactions${
key ? '/key:' + encodeURIComponent(key) : ''
}?extras=all`,
`/interaction/v1/interactions${singleKey}?extras=all`,
null,
null,
key
Expand Down

0 comments on commit 4732b08

Please sign in to comment.