Skip to content

Commit

Permalink
use inner response types 1/1
Browse files Browse the repository at this point in the history
  • Loading branch information
natural committed Nov 26, 2023
1 parent b1cc76e commit 2f9e29a
Show file tree
Hide file tree
Showing 5 changed files with 453 additions and 185 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The Vements Client Library for JavaScript includes a command line tool that can
#### Usage

```bash
$ vements --help
$ npm run build; node dist/vements.cjs.js --help
```

The JavaScript CLI tool supports all of the same operations as the CLI tool in other languages:
Expand Down
176 changes: 80 additions & 96 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.achievement
.leaderboard({
achievement_id: args.achievementId,
achievementId: args.achievementId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -92,15 +92,13 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.achievement
.record({
achievement_id: args.achievementId,
body: {
participant_id: args.participantId,
value: args.value,
recorded: args.recorded,
},
achievementId: args.achievementId,
participantId: args.participantId,
value: args.value,
recorded: args.recorded,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -117,12 +115,12 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.achievement
.list({
project_id: args.projectId,
projectId: args.projectId,
limit: args.limit,
offset: args.offset,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand Down Expand Up @@ -153,20 +151,18 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.achievement
.create({
body: {
project_id: args.projectId,
display: args.display,
goal: args.goal,
repeats: args.repeats,
locked_image: args.lockedImage,
unlocked_image: args.unlockedImage,
position: args.position,
public: args.public,
extra: args.extra,
},
projectId: args.projectId,
display: args.display,
goal: args.goal,
repeats: args.repeats,
lockedImage: args.lockedImage,
unlockedImage: args.unlockedImage,
position: args.position,
public_: args.public_,
extra: args.extra,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -185,10 +181,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.achievement
.read({
achievement_id: args.achievementId,
achievementId: args.achievementId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand Down Expand Up @@ -223,20 +219,18 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.achievement
.update({
achievement_id: args.achievementId,
body: {
display: args.display,
goal: args.goal,
repeats: args.repeats,
locked_image: args.lockedImage,
unlocked_image: args.unlockedImage,
position: args.position,
public: args.public,
extra: args.extra,
},
achievementId: args.achievementId,
display: args.display,
goal: args.goal,
repeats: args.repeats,
lockedImage: args.lockedImage,
unlockedImage: args.unlockedImage,
position: args.position,
public_: args.public_,
extra: args.extra,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -255,10 +249,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.achievement
.delete({
achievement_id: args.achievementId,
achievementId: args.achievementId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -283,10 +277,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.participant
.progress({
participant_id: args.participantId,
participantId: args.participantId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -305,10 +299,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.participant
.scores({
participant_id: args.participantId,
participantId: args.participantId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -325,12 +319,12 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.participant
.list({
project_id: args.projectId,
projectId: args.projectId,
limit: args.limit,
offset: args.offset,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -349,16 +343,14 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.participant
.create({
body: {
project_id: args.projectId,
display: args.display,
external_id: args.externalId,
image: args.image,
extra: args.extra,
},
projectId: args.projectId,
display: args.display,
externalId: args.externalId,
image: args.image,
extra: args.extra,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -377,10 +369,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.participant
.read({
participant_id: args.participantId,
participantId: args.participantId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -403,16 +395,14 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.participant
.update({
participant_id: args.participantId,
body: {
display: args.display,
external_id: args.externalId,
image: args.image,
extra: args.extra,
},
participantId: args.participantId,
display: args.display,
externalId: args.externalId,
image: args.image,
extra: args.extra,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -431,10 +421,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.participant
.delete({
participant_id: args.participantId,
participantId: args.participantId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand Down Expand Up @@ -466,15 +456,13 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.scoreboard
.record({
scoreboard_id: args.scoreboardId,
body: {
participant_id: args.participantId,
value: args.value,
recorded: args.recorded,
},
scoreboardId: args.scoreboardId,
participantId: args.participantId,
value: args.value,
recorded: args.recorded,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -495,12 +483,12 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.scoreboard
.scores({
scoreboard_id: args.scoreboardId,
scoreboardId: args.scoreboardId,
from: args.from,
to: args.to,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -517,12 +505,12 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.scoreboard
.list({
project_id: args.projectId,
projectId: args.projectId,
limit: args.limit,
offset: args.offset,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -541,16 +529,14 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.scoreboard
.create({
body: {
project_id: args.projectId,
display: args.display,
rank_dir: args.rankDir,
public: args.public,
extra: args.extra,
},
projectId: args.projectId,
display: args.display,
rankDir: args.rankDir,
public_: args.public_,
extra: args.extra,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -569,10 +555,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.scoreboard
.read({
scoreboard_id: args.scoreboardId,
scoreboardId: args.scoreboardId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -595,16 +581,14 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.scoreboard
.update({
scoreboard_id: args.scoreboardId,
body: {
display: args.display,
rank_dir: args.rankDir,
public: args.public,
extra: args.extra,
},
scoreboardId: args.scoreboardId,
display: args.display,
rankDir: args.rankDir,
public_: args.public_,
extra: args.extra,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand All @@ -623,10 +607,10 @@ export const CLI = (config, client, args) => {
.action((args) => {
client.scoreboard
.delete({
scoreboard_id: args.scoreboardId,
scoreboardId: args.scoreboardId,
})
.then((response) => {
console.log(response.data());
console.log(response);
})
.catch((response) => {
console.error("ERROR:", response);
Expand Down
Loading

0 comments on commit 2f9e29a

Please sign in to comment.