Hello!
> a) If customer wants to create or update a coffee card, it needs to go to URL
http://restbucks.com/order/{OrderId}/coffeecard
>
> I assume this URL doesn't identify a coffee card resource, but instead identifies a service endpoint which creates/updates a coffee card?
I can totally empathise with that point of view. You're right that the link in the order is like this:
<dap:link rel=′′
http://relations.restbucks.com/coffee-card′′
uri=′′
http://restbucks.com/order/1234/coffeecard′′
mediaType=′′application/vnd.restbucks+xml′′/>
But when the coffee card representation is returned (200 OK) the self link is:
http://restbucks.com/coffeecard/4456afd23
In retrospect it might have been sensible to use the second URI in both places. However in the note following the example it states:
"there is no correlation between the coffee card and a specific order, despite the format of the UrI in example 5-13. remember, UrIs are opaque to consumers. In this case, the link contains information that the restbucks ordering service uses when updating the count of endorsements in the coffee card."
Remember, we're not invited to parse the URIs, only understand and act on the links.
It identifies the payment for that order as the link advertises.
> b) Is payment resource still created ( behind the scenes ) when we pay for order using a coffee card?
Yes, in the implementation I believe it is. Go to
http://restinpractice.com and grab to code for Chapter 5.
Hope that helps,
Jim