SaaS - Booking Documents
How to upload documents to Bookings
1. Send a request to /api/me/document_upload
with the file info/metadata.
curl \
-X 'POST' 'https://rnters-staging.herokuapp.com/api/me/document_upload' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"byte_size": 13264,
"checksum": "<FILE_MD5_CHECKSUM>",
"content_type": "application/pdf",
"filename": "dummy.pdf",
"metadata": {}
}'
Response will have a blob_signed_id
, a upload_url
and the headers
needed to upload the file to cloudflare:
{
"blob_signed_id": "<BLOB_SIGNED_ID>",
"upload_url": "<CLOUDFLARE_STORAGE_URL>",
"headers": {
"Content-Type": "application/pdf",
"Content-MD5": "<FILE_MD5_CHECKSUM>",
"Content-Disposition": "inline; filename=\"dummy.pdf\"; filename*=UTF-8''dummy.pdf"
},
"byte_size": 13264
}
2. Send the file to the upload_url
from the previous request with the response headers.
curl \
-X 'PUT' '<CLOUDFLARE_STORAGE_URL>' \
-H "Content-Type: application/pdf" \
-H "Content-MD5: <FILE_MD5_CHECKSUM>" \
-H "Content-Disposition: inline; filename=\"dummy.pdf\"; filename*=UTF-8''dummy.pdf" \
--upload-file ./dummy.pdf
3. Send a request to /api/saas/me/bookings/{internal_id}/documents
with the parameters in the first step response.
curl \
-X 'POST' 'https://rnters-staging.herokuapp.com/api/saas/me/bookings/1/documents' \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"data": {
"type": "booking_document",
"attributes": {
"file_id": "<BLOB_SIGNED_ID>",
"visible_to_renter": true,
"category": "invoice"
}
}
}'
Expected Response:
{
"data": {
"id": "1",
"type": "booking_document",
"attributes": {
"category": "invoice",
"visible_to_renter": true,
"filename_base": "dummy"
},
"relationships": {
"booking": { "data": { "id": "1", "type": "booking" } }
},
"meta": {
"filename": "dummy.pdf",
"url": "<CLOUDFLARE_STORAGE_URL>",
"content_type": "application/pdf",
"byte_size": 13264
}
}
}
Last modified: 22 days ago