pakcikkantin
pakcikkantin

Reputation: 101

REST design advice on simple order service

i am looking for advice for my REST JSON service. I have 1 simple order which basically does simple CRUD. So basically besides getting the details of the order , create order and delete the order , i also want to do more activities on a single order like :

Can anyone share ideas on how i can extend the service. Currently i have an URI below like

http://myapi.com/order/

Thank you very much

Upvotes: 0

Views: 67

Answers (2)

fpmoles
fpmoles

Reputation: 1219

so http://myapi.com/orders/{id} would be the get of a single order, most designers I have seen use the plural, fyi.

I would offer two options in this case (least favorite example is first)

A. Enumerate actions that can occur and do a query param for the action for instance http://myapi.com/orders/123?action=APPROVE that responds to a POST method with whatever data you need to provide.

**Note I dislike the above because it feels more like RPC than REST, but it definitely can work for you needs.

B. Provide a Behavior Pattern in addition to your CRUD. so you would do crud form /orders through @POST, @GET, ect and then provide /orderActions/approve/{id} or something similar to POST to for the approve action.

Upvotes: 1

Richard Brown
Richard Brown

Reputation: 11436

You don't mention what language you're using for this project. I would recommend Ruby on Rails with the state_machine gem, which will allow you to do your CRUD as well as the additional 'states' you're looking to move the order through.

I say RoR mainly because it'll do the CRUD for you out of the box and the state_machine gem will do the rest.

Upvotes: 0

Related Questions