zooniverse / json-api-client

Apache License 2.0
10 stars 5 forks source link

Add query params to PUT and POST #40

Closed eatyourgreens closed 6 years ago

eatyourgreens commented 6 years ago

Ideally, we'd like to be able to specify query params alongside request payloads, something along the lines of client.type(type).query(paramsObject).create(payloadObject).

This probably requires adding .query() to PUT and POST requests, and updating the client to differentiate between payload data and query params.

eatyourgreens commented 6 years ago

Turns out I didn't properly remember how query params are passed to the client. The syntax is client.type(type).get(queryParams).

Maybe the equivalent for create and update should be resource.update(changeSet).save(queryParams) client.type(type).create(payload).save(queryParams).

camallen commented 6 years ago

That is a pity as the intention of this code client.type(type).query(paramsObject) reads loud and clear whereas obfuscating behind the get / save params is less intuitive.

Something to revisit if it ever gets rewritten...

eatyourgreens commented 6 years ago

.query() reads better to me too, but .type() returns a Resource object so the query params would have to be written to the resource somehow then read on .save()? It might get messy.