Passer au contenu

Limited
Replace library production chapter

Requête

Full replace of the chapter's active published version, IN PLACE — no new version is created. Every linked specification reads this same version, so all of them see the update immediately. The caller must be the chapter's owner company. When the chapter is locked (a linked specification entered signature) content can no longer change in place — the write returns 422 INVALID_RESOURCE_STATE with no paramName, since nothing in the payload is at fault; adopting a NEW version created in the product is per-spec, via the .../link endpoints.

Sécurité
oauth2(Portées requises: t1_api)
Chemin
chapterIdstring, (uuid)obligatoire

The unique identifier of the library chapter

En-têtes
If-Matchstring

Optional optimistic concurrency: the ETag returned by the chapter GET. When provided, the write is rejected with 412 if the specification changed since the chapter was read (anything on it: another chapter, a contact, a share), or, for a library chapter, if the chapter changed. Guards against concurrent writers within the same owner company (cross-company overwrite is already impossible — the chapter is the ownership boundary).

Corpsapplication/jsonobligatoire
namestringobligatoire

Library display name of the chapter, shown in the Library screen. Unique among the owner company's library chapters — a duplicate is a 422 with errorCode NAME_ALREADY_USED (paramName name).

sitesArray of objects or null(ProductionSite)

Replaces the chapter's site list in full. null or absent leaves it unchanged; send [] to clear it.

recipeobject(RecipeWrite)

The chapter's recipe, written on the chapter update only (not on the create - see FoodProductionChapterCreateRequest). The ingredients go into the chapter's OWN composite, the one created with the chapter; the chapter cannot be pointed at another composite, so compositeId is read-only (RecipeRead). Writing the ingredients re-derives the allergen sections. The three other blocks belong to the chapter itself.

nutritionobject(NutritionalInformationWrite)

WRITE shape of the nutrition section. Writes carry the INPUTS only: the nutrient values as entered, the serving size and the two automatic flags. The rendered and computed values of NutritionalInformation (per100g / perServing strings, referenceIntakePercentage, nutriScore) are read-only and computed server-side from these inputs. On the update, full replace within the section: an omitted nutrient is removed, and omitting a mandatory nutrient is a 422 naming nutrition. On the create, the sent nutrients are added to the mandatory ones (see FoodProductionChapterCreateRequest.nutrition).

allergensobject(AllergenDeclarationWrite)

Qualifies allergens the chapter already carries. The allergen SET is not writable: an allergenId that the derived list does not contain is a 422 naming the entry, because there is nothing to qualify. rawMaterialAllergens has no write shape at all - it is pure derivation.

The cross-contamination entries come from two sources: the recipe's composite, and the allergens the chapter's SITES declare; an entry left with no ingredient behind it is dropped. The set is the union of the two, recomputed on each write to either section - which is why a caller can qualify an entry but never create or remove one.

curl -i -X PUT \
  'https://apis.traceone.com/spec/v2/library/food/production-chapters/{chapterId}' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -H 'If-Match: string' \
  -d '{
    "name": "string",
    "sites": [
      {
        "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1"
      }
    ],
    "recipe": {
      "ingredients": [
        {
          "materialId": "30cdab3c-3e2b-44f4-8415-c6dd88ed4261",
          "percentage": 0,
          "minPercentage": 0,
          "maxPercentage": 0,
          "functionId": "88c30c0d-0919-4072-a552-9669be152724"
        }
      ],
      "manufacturingDiagramFileIds": [
        "497f6eca-6276-4993-bfeb-53cbbbba6f08"
      ],
      "calculationOfYield": {
        "percentage": 0.1,
        "method": "string"
      },
      "recycledProductQuantity": {
        "minimumValue": 0.1,
        "targetValue": 0.1,
        "maximumValue": 0.1,
        "unitId": "b3eb5f92-604a-46b9-9881-9d84000fd7ed"
      }
    },
    "nutrition": {
      "nutrients": [
        {
          "nutrientId": "ce8c0866-b8a2-4223-9b70-6737aeeac3f5",
          "unitId": "b3eb5f92-604a-46b9-9881-9d84000fd7ed",
          "unroundedValue": 0
        }
      ],
      "servingSize": {
        "value": 0,
        "massUnitId": "63feeca3-19ff-4722-8955-6713ff5719ce",
        "volumeUnitId": "9c8961f2-1e43-4bc8-95fa-bac5491cc67e",
        "servingTypeCode": "string",
        "servingTypeDescription": "string"
      },
      "automaticCalculation": true,
      "automaticConversion": true
    },
    "allergens": {
      "crossContaminationAllergens": [
        {
          "allergenId": "0f0d32f3-73a4-4072-8a85-b17e6b593524",
          "controlledRisk": true
        }
      ],
      "freeFromAllergens": [
        {
          "allergenId": "0f0d32f3-73a4-4072-8a85-b17e6b593524",
          "proofFileId": "46f65a7a-5324-45ae-8cb6-4d1544b0c003"
        }
      ]
    }
  }'

Réponses

The chapter was replaced in place (active version). Read it back, with its new ETag, from the chapter GET.

Réponse
Aucun contenu