Содержание
$template_id = 123;
$link = "https://docs.f5api.ru/api/v1/templates/$template_id";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer <your_token>'
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"id": 123,
"name": "Договор аренды",
"content": "<html>...шаблон документа...</html>",
"created_at": "2023-01-15T10:00:00Z"
}
fetch(`https://docs.f5api.ru/api/v1/documents/456`, {
method: 'GET',
headers: {
'Authorization': 'Bearer <your_token>',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));
{
"id": 456,
"template_id": 123,
"status": "generated",
"download_url": "https://docs.f5api.ru/download/456.pdf",
"created_at": "2023-01-20T14:30:00Z"
}
{
"template_id": 123,
"variables": {
"client_name": "ООО 'Ромашка'",
"contract_date": "2023-12-31",
"amount": 150000
}
}
{
"id": 789,
"status": "processing",
"message": "Document generation started"
}
$document_id = 789;
$link = "https://docs.f5api.ru/api/v1/documents/refresh/$document_id";
$body = [
"variables" => [
"amount" => 175000
]
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
// ... остальные настройки curl как в предыдущих примерах
{
"id": 789,
"status": "updated",
"download_url": "https://docs.f5api.ru/download/789.pdf"
}
fetch(`https://docs.f5api.ru/api/v1/documents/remove/789`, {
method: 'DELETE',
headers: {
'Authorization': 'Bearer <your_token>'
}
})
.then(response => response.json())
.then(data => console.log(data));
{
"success": true,
"message": "Document 789 deleted"
}