codemix / restyii

A RESTful extension for Yii.
15 stars 10 forks source link

Documentation: Emitted MQ json object structure #12

Open JorgenSmith opened 11 years ago

JorgenSmith commented 11 years ago

When an update or insert action is performed on the API and an MQ component is specified, the API will emit a message on the MQ bus.

The message has a content_type of "application/json" (without quotes, all lower case).

The structure of the submitted message is as follows: {"name": $action,"type": $resource,"id":$pk,"params":[]} E.g. {"name":"update","type":"User","id":"97","params":[]}

Params will contain the objects properties with arrays of new and old values. E.g. changing user 97's first name from Johnathan to John, and setting the previously blank streetname (assuming those are the only three fields in the resource).

{"name":"update","type":"User","id":"97","params":{"firstname":["Johnathan","John"],"lastname":["Smith","Smith"],"streetname":[null,"Hardware Lane"]}}

Please note that on an update, a hash of the new object properties is compared to that of the existing ones. If the hash is the same (no changes detected), params will be an empty array.