Skip to main content

Add Batch Information for Farmer in Trade

POST /api/v1/trades/{tradeId}/farmer/{farmerId}/batch

Description

This endpoint is used to add batch details for a specific farmer within a trade, recording critical information such as the quantity and weight of the products, the units of measurement, details about the offloading process, and whether the batch has been covered by tests. This information is vital for tracking the agricultural products supplied by each farmer and managing quality control and delivery timelines.

URL Parameters:

  • tradeId (required): The unique identifier of the trade associated with the batch information.
  • farmerId (required): The unique identifier of the farmer for whom the batch information is being added.

Headers:

  • countryCode (required): The country code where the trade is taking place. This should be included as a header.
  • userId (required): The user ID of the individual responsible for adding the batch information.
  • tenantId (required): The tenant ID under which the batch information is being added.

Request Body (application/json): Required. The body should include detailed information about the batch:

{
"quantity": 0,
"weight": 0,
"unit": "Barrels",
"offloadDate": "string",
"offloadPersonnelPhone": "string",
"offloadPersonnelName": "string",
"testCoverage": false
}

Example Request:

curl -X POST "http://[base_url]/api/v1/trades/{tradeId}/farmer/{farmerId}/batch" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer [access_token]" \
-H "countryCode: US" \
-H "userId: USR123" \
-H "tenantId: TEN123" \
-d '{
"quantity": 100,
"weight": 200,
"unit": "Barrels",
"offloadDate": "2024-04-01",
"offloadPersonnelPhone": "+1234567890",
"offloadPersonnelName": "John Doe",
"testCoverage": true
}'

Responses:

  • 201 Created: Indicates that the batch information has been successfully added. The response typically includes details of the newly added batch.

Example Response:

{
"message": "Batch information added successfully.",
"batchId": "batch123"
}

Error Responses:

  • 400 Bad Request: Incorrect or incomplete data for the batch addition.
  • 404 Not Found: No trade or farmer found with the provided IDs.
  • 403 Forbidden: The user does not have permission to add batch information.

LANGUAGE

AUTHORIZATION

Bearer

CURL REQUEST


curl --request POST \ 
--url /api/v1/trades/{tradeId}/farmer/{farmerId}/batch \
--header 'accept: application/json' \
--header 'content-type: application/json'

RESPONSE


Click Try It! to start a request and see the response here!