Sarcini cu aprobare
Pregătește o ofertă, verifică pozițiile și consemnează decizia.
Pe această pagină
Pregătește proiectul
Identifică cererea din CRM și alege un identificator nou pentru execuție. După încheierea operației, citește execuția. În starea waiting_for_approval, proiectul conține cantitățile, prețurile unitare din ERP și totalul net.
curl
curl -X POST "$RDC_BASE_URL/ai/v1/tasks/runs" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
"expectedRevision": 0,
"runId": "run-1042",
"requestId": "CV-1042"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/ai/v1/tasks/runs`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
"expectedRevision": 0,
"runId": "run-1042",
"requestId": "CV-1042"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/ai/v1/tasks/runs',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '1b5201ad-39eb-4cc1-889c-2dd2d43ffc57',
'expectedRevision': 0,
'runId': 'run-1042',
'requestId': 'CV-1042',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
"expectedRevision": 0,
"runId": "run-1042",
"requestId": "CV-1042"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/ai/v1/tasks/runs');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/ai/v1/tasks/runs");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
"expectedRevision": 0,
"runId": "run-1042",
"requestId": "CV-1042"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "1b5201ad-39eb-4cc1-889c-2dd2d43ffc57",
"status": "accepted",
"aggregateRevision": 1
} curl
curl "$RDC_BASE_URL/ai/v1/tasks/runs/run-1042" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/ai/v1/tasks/runs/run-1042`, {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
},
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'GET',
f'{os.environ["RDC_BASE_URL"]}/ai/v1/tasks/runs/run-1042',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/ai/v1/tasks/runs/run-1042');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/ai/v1/tasks/runs/run-1042");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"status": "waiting_for_approval",
"draft": {
"net": "399.81",
"lines": [
{
"sku": "DT-0412",
"name": "Dishwashing liquid, 5 l",
"quantity": "12",
"unitPrice": "23.47",
"net": "281.64"
},
{
"sku": "AM-0518",
"name": "Paper bags, pack of 100",
"quantity": "9",
"unitPrice": "13.13",
"net": "118.17"
}
]
},
"revision": 2,
"steps": [
{
"id": "read_request",
"tool": "CRM",
"status": "done",
"output": "CV-1042"
},
{
"id": "price_offer",
"tool": "ERP",
"status": "done"
},
{
"id": "send_offer",
"tool": "CRM",
"status": "waiting_for_approval"
}
],
"id": "run-1042"
} Modifică, aprobă sau respinge
Un utilizator cu rolul finance poate modifica o cantitate, iar totalul se recalculează. Citește revizia după fiecare modificare. Când aprobi sau respingi oferta, trimite revizia citită și un UUID nou pentru operație.
curl
curl -X PATCH "$RDC_BASE_URL/ai/v1/tasks/runs/run-1042/draft" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
"expectedRevision": 2,
"sku": "DT-0412",
"quantity": "7"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/ai/v1/tasks/runs/run-1042/draft`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
"expectedRevision": 2,
"sku": "DT-0412",
"quantity": "7"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'PATCH',
f'{os.environ["RDC_BASE_URL"]}/ai/v1/tasks/runs/run-1042/draft',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '68549b88-bb2a-449e-a341-79d16f31f897',
'expectedRevision': 2,
'sku': 'DT-0412',
'quantity': '7',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
"expectedRevision": 2,
"sku": "DT-0412",
"quantity": "7"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/ai/v1/tasks/runs/run-1042/draft');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Patch, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/ai/v1/tasks/runs/run-1042/draft");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
"expectedRevision": 2,
"sku": "DT-0412",
"quantity": "7"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "68549b88-bb2a-449e-a341-79d16f31f897",
"status": "accepted",
"aggregateRevision": 3
} curl
curl -X POST "$RDC_BASE_URL/ai/v1/tasks/runs/run-1042/decision" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
"expectedRevision": 2,
"decision": "approved"
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/ai/v1/tasks/runs/run-1042/decision`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
"expectedRevision": 2,
"decision": "approved"
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/ai/v1/tasks/runs/run-1042/decision',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '423a61ed-2ea7-40fd-a31e-da3baa387eac',
'expectedRevision': 2,
'decision': 'approved',
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
"expectedRevision": 2,
"decision": "approved"
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/ai/v1/tasks/runs/run-1042/decision');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/ai/v1/tasks/runs/run-1042/decision");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
"expectedRevision": 2,
"decision": "approved"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "423a61ed-2ea7-40fd-a31e-da3baa387eac",
"status": "accepted",
"aggregateRevision": 3
} Verifică trimiterea
Citește din nou execuția. Trimiterea confirmată are starea done și câmpul receiptId. Dacă oferta a fost respinsă, rămân proiectul și decizia. Dacă trimiterea a eșuat, aprobarea rămâne în jurnal, iar execuția indică dispatch_failed și nu conține o confirmare.