Reviews
Creating reviews
A review can be created for a given ReviewForm. Your Review input should therefore also correspond to this form. Each ReviewQuestion of the ReviewForm must have a ReviewAnswer.
This can be achieved by using Sideposting: the ReviewAnswers are sideposted in the included
object. An example Review can be seen below.
Each ReviewAnswer must have a relationship to a ReviewQuestion belonging to the ReviewForm. These resources don't have an ID yet, therefore it is required to link these resources by setting /meta/temp_id
. You will also need to define what the system needs to do with these resources by specifying /meta/method
create on the relationship.
Endpoint : POST review
// Endpoint: POST review
{
"data": {
"type": "review",
"attributes": {
"name": "M Rowe",
"locale": "nl",
"stayed_nights": 7,
"stayed_date": "2014-01-15",
"original_identifier": "review-1"
},
"relationships": {
"rentable_type": {
"data": {
"id": "1",
"type": "rentable_type"
}
},
"review_answers": {
"data": [
{
"type": "review_answer",
"meta": {
"temp_id": "open-answer-id",
"method": "create"
}
},{
"type": "review_answer",
"meta": {
"temp_id": "boolean-answer-id",
"method": "create"
}
},{
"type": "review_answer",
"meta": {
"temp_id": "rating-answer-id",
"method": "create"
}
},{
"type": "review_answer",
"meta": {
"temp_id": "not-applicable-answer-id",
"method": "create"
}
}
]
}
}
},
"included": [{
"type": "review_answer",
"attributes": {
"answer": "It was great"
},
"relationships": {
"review_question": {
"data": {
"id": "1",
"type": "review_question"
}
}
},
"meta": {
"temp_id": "open-answer-id"
}
},{
"type": "review_answer",
"attributes": {
"boolean_answer": "true"
},
"relationships": {
"review_question": {
"data": {
"id": "2",
"type": "review_question"
}
}
},
"meta": {
"temp_id": "boolean-answer-id"
}
},{
"type": "review_answer",
"attributes": {
"rating": 8
},
"relationships": {
"review_question": {
"data": {
"id": "3",
"type": "review_question"
}
}
},
"meta": {
"temp_id": "rating-answer-id"
}
},{
"type": "review_answer",
"attributes": {
"not_applicable": true
},
"relationships": {
"review_question": {
"data": {
"id": "4",
"type": "review_question"
}
}
},
"meta": {
"temp_id": "not-applicable-answer-id"
}
}]
}
Updated 9 months ago