Skip to content

Instantly share code, notes, and snippets.

@hobodave
Created January 24, 2013 23:24
Show Gist options
  • Save hobodave/4629479 to your computer and use it in GitHub Desktop.
Save hobodave/4629479 to your computer and use it in GitHub Desktop.
"create_ticket": {
"httpMethod":"POST",
"uri": "tickets.json",
"summary": "Create a ticket",
"parameters":{
"data": {
"type": "array",
"location": "body",
"description":"Ticket JSON",
"filters": "json_encode",
"required": true
},
"Content-Type":{
"type": "string",
"location":"header",
"static": "application/json"
}
}
}
<command name="create_ticket" method="POST" uri="tickets.json">
<doc>Create a ticket</doc>
<param name="data" type="array" location="body" filters="json_encode" doc="ticket JSON"/>
<param name="Content-Type" location="header" static="application/json"/>
</command>
<?php
/**
* Creates a new resource, returning the updated $object
*
* @param string $resource
* @param AbstractCommand $command
* @param ModelAbstract $object
*/
protected function doCreate($resource, AbstractCommand $command, ModelAbstract $object)
{
$command->set('data', array($resource => $object->toArray()));
$data = $command->execute();
$object->fromArray($data[$resource]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment