News for hackers. Stuff that matters.
Re:RESTful thinking considered harmful by dalore on Friday March 30, 2012 @11:13AM (#3776302)
> POST /orders/42/payment

> POST /orders/42/shipment

Fixed?

Re:RESTful thinking considered harmful by Roboprog on Friday March 30, 2012 @04:09PM (#3777877)
Pretty close. If you really want to make the process "safe" (idempotent, to avoid double posted payments), you might actually have to do something more complicated such as:

GET /order/42/payment/new (returns "3", for example)

PUT /order/42/payment/3 (supplying content for payment info and amount)

Re-issuing the "PUT" (in case confirmation was lost? user double clicked "submit"?) would simply resend the same value, thus, an "idempotent" action.

Viewing this particular payment is simply:

GET /order/42/payment/3

Without the "3", who knows which payment you would get? (unless you got back the list of all payments on the order so far)

I'm not sure if this an argument for or against REST, but I'd sure hate to see a SOAP example typed into a "comment box" in a discussion forum :-)

Re:RESTful thinking considered harmful by pfraze on Friday March 30, 2012 @09:02PM (#3778899)
Good point. I wonder, though-- could you make /order/42/payment the only payment resource related to /order/42, so the ID isn't needed? (PUT /order/42/payment)

If the payment doesn't cover the bill, you could have the PUT respond with a link to /order/42/payment/remaining/1, then (if needed) continue with /remaining/2, and so on.

That would avoid the danger of a gap between your id GET and the payment PUT.

Re:RESTful thinking considered harmful by pbreit on Friday March 30, 2012 @09:22PM (#3778962)
Shouldn't it be:

  POST /payment
  order=42
Or:

  POST(or PUT) /order/42
  status=shipped
Re:RESTful thinking considered harmful by pfraze on Friday March 30, 2012 @11:23AM (#3776363)
Yeah.