Przejdź do głównej zawartości

createProduct

Dla: Programista

MutacjaBetaMutation.createProduct

Adds a product to an existing order that is not archived. It starts as NO_FILES, before any print file. Elements and operations are entered with the order (createOrder) or by the print shop.

Wymagany zakresorders:write
Dostępne odPrynt 0.28.0
StabilnośćBeta (co to znaczy)
PonawianieWysyłaj nagłówek Idempotency-Key, żeby ponowienie nie wykonało zapisu drugi raz. Zapisy i idempotencja

Argumenty

NazwaTypOpis
inputwymaganeCreateProductInput!

The new product.

Zwraca

Product!

Przykład

Mutacja
mutation AddProduct($input: CreateProductInput!) {
createProduct(input: $input) {
id
orderId
number
name
status
}
}
Zmienne
{
"input": {
"orderId": "4b0d2a63-8e5f-4c9b-8f32-6d7e8f9a0b12",
"number": 3,
"name": "Wizytówki",
"quantity": 500,
"unit": "PIECES",
"price": 120,
"priceMarkup": 0,
"taxRate": 23,
"weight": 1.2
}
}
Wywołanie (curl)
IDEMPOTENCY_KEY=$(uuidgen) # ponawiaj z tym samym kluczem
curl -sS https://twoja-drukarnia.prynt.pl/api/v1/graphql \
-H "Authorization: Bearer $PRYNT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
--data-binary @- <<'JSON'
{
"query": "mutation AddProduct($input: CreateProductInput!) {\n createProduct(input: $input) {\n id\n orderId\n number\n name\n status\n }\n}",
"variables": {
"input": {
"orderId": "4b0d2a63-8e5f-4c9b-8f32-6d7e8f9a0b12",
"number": 3,
"name": "Wizytówki",
"quantity": 500,
"unit": "PIECES",
"price": 120,
"priceMarkup": 0,
"taxRate": 23,
"weight": 1.2
}
}
}
JSON
Odpowiedź
{
"data": {
"createProduct": {
"id": "be5a7192-4d6f-4a81-9cad-2e3f4a5b6c74",
"orderId": "4b0d2a63-8e5f-4c9b-8f32-6d7e8f9a0b12",
"number": 3,
"name": "Wizytówki",
"status": "NO_FILES"
}
}
}