开发者

Best practice way of Restfully updating multiple Resource types

I am just looking for some opinions on what is the best RESTful way of updating multiple differ开发者_运维百科ent Resource types or if I am looking at the problem in the wrong way.

We are looking for a solution change the attribute of a collection of different resource types.

For example, we have an account and deals, each of which have a owner and deals are linked to an account. The owner of the account may also own some or all of the deals associated with the account but deals can have owners that are not the account owner. We are looking to implement functionality that will allow us to replace the owner of an account and also update the deals owner by the account owner in one call.

What would be the best way to implement such functionality using REST?

Many Thanks


You could create a new virtual resource that is responsible for making the changes to the other resources.

Resources: User, Account, Deal

Account has an attribute, owner (a User)

Account has many Deals

Deal has an attribute, owner (a User)

User has many Deals

Want the resource to manage:

  • Changing Account owner
  • Changing Deal owner for all Deals associated with the Account where Deal owner == (old) Account owner

Synchronous:

URL /account_ownership_update

  • POST: Send the Account to be updated and the new User. Return success/failure

Asynchronous:

URL /account_ownership_update

  • POST: Send the Account to be updated and the new User. Return enqueue successful/failed
  • GET: Return the status of the update (pending, running, successful, failed)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜