Retrieve Batch Information for Farmer in Trade
GET /api/v1/trades/{tradeId}/farmer/{farmerId}/batch
Description
Retrieves detailed batch information for a specific farmer within a trade, allowing for analysis based on quantity, delivery details, and date ranges. This endpoint supports extensive filtering and sorting to provide tailored insights into the agricultural products supplied by each farmer, including their delivery and quality testing details.
URL Parameters:
tradeId(required): The unique identifier of the trade associated with the farmer.farmerId(required): The unique identifier of the farmer whose batch information is being queried.
Headers:
tenantId(required): The tenant ID under which the trade and farmer details are registered. This should be included as a header.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 requesting the batch information.
Query Parameters:
tradeFarmerBatchDateRange(optional): Filters the batches by a specific date range. Format:start_date,end_date(e.g.,2020-11-12,2022-11-15).farmerBatchIds(optional): Filters the list by specific batch IDs.order(optional): Specifies the order of the results. Available values:ASC,DESC.page(optional): Specifies the pagination page.limit(optional): Specifies the number of results per page.
Example Request:
curl -G "http://[base_url]/api/v1/trades/{tradeId}/farmer/{farmerId}/batch" \
-H "Authorization: Bearer [access_token]" \
-H "tenantId: TEN123" \
-H "countryCode: US" \
-H "userId: USR456" \
-d "tradeFarmerBatchDateRange=2020-11-12,2022-11-15" \
-d "farmerBatchIds=101,102" \
-d "order=ASC" \
-d "page=1" \
-d "limit=10"
Responses:
- 200 OK: Successfully retrieved the list of batches. The response includes detailed information about each batch that matches the specified criteria, such as quantity, offload date, and any associated documentation.
Example Response:
{
"batches": [
{
"batchId": "101",
"quantity": 1000,
"unit": "Kilograms",
"offloadDate": "2021-12-01",
"offloadPersonnelName": "John Smith"
},
{
"batchId": "102",
"quantity": 1500,
"unit": "Kilograms",
"offloadDate": "2021-12-15",
"offloadPersonnelName": "Jane Doe"
}
],
"totalItems": 20,
"totalPages": 2,
"currentPage": 1
}
Error Responses:
- 400 Bad Request: Incorrect or incomplete query parameters.
- 404 Not Found: No batches found based on the provided criteria.
- 403 Forbidden: The user does not have permission to view the batch details.
LANGUAGE
CURL REQUEST
curl --request GET \
--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!