-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: implement method POST to /objects endpoint #714
Comments
also move check on writableObjects in ApiValidator
Save in private attribute $relations to avoid to perform the same operations many times Every time the config is cached the $relations attribute is generated
Implemented POST /objects Added To save objects you have to define in configuration what object types are allowed $config['api'] = array(
....
'validation' => array(
'writableObjects' => array('document', 'event')
)
); or from public $components = array(
'ResponseHandler' => array('type' => 'json'),
'ApiFormatter',
'ApiValidator' => array(
'writableObjects' => array('document', 'event')
),
'BeAuthJwt'
); Saving new objects (user has to be authenticated) data from client must contain:
Example of valid data from client: {
"data": {
"title": "My title",
"object_type": "event",
"description": "bla bla bla",
"parents": [1, 34, 65],
"relations": {
"attach": [
{
"related_id": 12,
"params": {
"label": "foobar"
}
},
{
"related_id": 23
}
],
"seealso": [
{
"related_id": 167
}
]
},
"categories": ["name-category-one", "name-category-two"],
"tags": ["name-tag_one", "name-tag-two"],
"geo_tags": [
{
"title": "geo tag title",
"address": "via ....",
"latitude": 43.012,
"longitude": 10.45
}
],
"date_items": [
{
"start_date": "2015-07-08T15:00:35+0200",
"end_date": "2015-07-08T15:00:35+0200",
"days": [0,3,4]
},
{
"start_date": "2015-09-01T15:00:35+0200",
"end_date": "2015-09-30T15:00:35+0200"
}
]
}
} dates must be in ISO 8601 format. You can use POST also to update an existent object. In that case the object |
GET To add/edit a relation the client payload should for example {
"data": {
"related_id": 15,
"priority": 1,
"params": {
"label": "lorem"
}
}
} If relation attach between 10 and 15 not exists it will be created else it will be updated. If relation is created and missing priority it will set to max value on db + 1. To add/update many relations at once client has to pass an array of relations data: {
"data": [
{
"related_id": 12,
"priority": 1,
"params": {
"label": "lorem"
}
},
{
"related_id": 13,
},
{
"related_id": 9
}
]
} |
/objects
endpoint has to support POST request to create new objects.We could use POST to create new relations, children, etc... on existent object. For example
/objects/13/relations/attach
create new relations attach to object 13/objects/1/children
create new children of object 1The text was updated successfully, but these errors were encountered: