SpaceTradersAPI / issues-and-suggestions

16 stars 1 forks source link

Suggestion: Scrap ship response #121

Closed Ironolife closed 1 year ago

Ironolife commented 3 years ago

Current Response:

{ "success": "Ship scrapped for 9438 credits" }

Suggested Response:

{ "scrappedFor": 9438 }

or

{ "credits":  123456 }

This would allow clients to update credits more reliably without matching with regex or refetching the user.

bloveless commented 3 years ago

I would also like to second this one and vote that the new credits for the user are returned or both scrappedFor and new credits are returned.

jsProj commented 3 years ago

You can additionally just do this +result.success.split(" ")[3]

nhowell commented 3 years ago

You can additionally just do this +result.success.split(" ")[3]

Right, the OP mentioned this - i.e. the point about Regex, which is not really any different than what you're proposing here.

The issue is that parsing the credits from the string is brittle (e.g. what if the message is re-worded), and also requires extra work of the client.