Update Blight-API.md
This commit is contained in:
parent
27a44658e3
commit
56f4e66e68
180
Blight-API.md
180
Blight-API.md
@ -219,6 +219,186 @@ PUT /api/v1/items/{code}
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# Blight API
|
||||||
|
[<< Home](README.md)
|
||||||
|
|
||||||
|
For the currently available public FarmMaps API you can take a look at swagger: https://farmmaps.eu/swagger
|
||||||
|
|
||||||
|
## API flow
|
||||||
|
* Authenticate
|
||||||
|
* Create cropping scheme (if not exists)
|
||||||
|
* Create crop field (if not exists)
|
||||||
|
* Get blight advice
|
||||||
|
* Create blight advice
|
||||||
|
* Add spray
|
||||||
|
* Add irrigation
|
||||||
|
* Get predefined fungicides
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
### Authenticate
|
||||||
|
See [Authentication](Authentication.md)
|
||||||
|
|
||||||
|
### Create cropping scheme (if not exists)
|
||||||
|
See [Create Croppingscheme](Create-Croppingscheme.md)
|
||||||
|
|
||||||
|
### Create crop field (if not exists)
|
||||||
|
See [Create Cropfield](Create-b-cropfield.md)
|
||||||
|
|
||||||
|
### <a name="create-advice"></a>Get blight advice
|
||||||
|
|
||||||
|
Blight is only available for potato fields.
|
||||||
|
The advice is automatically created when new potato fields are added and is scheduled to be updated at configured times.
|
||||||
|
It is also possible to create a new advice at any time, see [Create blight advice](#create-advice).
|
||||||
|
|
||||||
|
A blight advice is a child record of a crop field.
|
||||||
|
Use the crop field code to get the latest blight advice.
|
||||||
|
|
||||||
|
#### 1. get the blight item code
|
||||||
|
|
||||||
|
> Request
|
||||||
|
```javascript
|
||||||
|
GET /api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.blight
|
||||||
|
```
|
||||||
|
> Response 200 OK
|
||||||
|
```javascript
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"parentCode": "string",
|
||||||
|
"geometry": ...
|
||||||
|
"url": ...
|
||||||
|
"code": ...
|
||||||
|
"size": ...
|
||||||
|
"data": {
|
||||||
|
"itemtask": {
|
||||||
|
"runs": {
|
||||||
|
"last": "2023-02-22T03:02:01.8775194Z",
|
||||||
|
"success": "2023-02-22T03:02:01.8775194Z"
|
||||||
|
},
|
||||||
|
"state": "ok",
|
||||||
|
"messages": []
|
||||||
|
},
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
> Response 404 Not Found
|
||||||
|
|
||||||
|
There is no advice available, try to create a new advice, see [Create blight advice](#create-advice).
|
||||||
|
|
||||||
|
Check the data field for itemtask/state. If state is "ok" there should be an advice.
|
||||||
|
|
||||||
|
|
||||||
|
#### 2. get advice for the blight item
|
||||||
|
Use the code found in the previous call (or use url) to get the advice.
|
||||||
|
> Request
|
||||||
|
```javascript
|
||||||
|
GET /api/v1/items/{code}/data
|
||||||
|
```
|
||||||
|
> Response 200 OK
|
||||||
|
```javascript
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"sprayTime": null,
|
||||||
|
"date": "2022-03-01T00:00:00",
|
||||||
|
"weather": [
|
||||||
|
{
|
||||||
|
"temperature": 3.0,
|
||||||
|
"precipitation": 0.0,
|
||||||
|
"rain": 0.0,
|
||||||
|
"irrigation": 0.0,
|
||||||
|
"humidity": 71.0,
|
||||||
|
"hh": 0,
|
||||||
|
"leafwetnessmm": null
|
||||||
|
},...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
> Response 404 Not Found
|
||||||
|
|
||||||
|
|
||||||
|
### <a name="create-advice"></a>Create blight advice
|
||||||
|
Task 'vnd.farmmaps.task.blight' must be executed to create an advice.
|
||||||
|
This task is automatically created for potato fields and is scheduled to run at configered times to keep the advice updated. But it is possible to create this task at any time.
|
||||||
|
|
||||||
|
Add the crop field code to the URL and execute the following request.
|
||||||
|
|
||||||
|
> Request
|
||||||
|
```javascript
|
||||||
|
POST /api/v1/items/{code}/tasks
|
||||||
|
{
|
||||||
|
"TaskType": "vnd.farmmaps.task.blight",
|
||||||
|
"Delay": null,
|
||||||
|
"attributes": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> Response 200
|
||||||
|
```javascript
|
||||||
|
{
|
||||||
|
"code": "{code}",
|
||||||
|
"taskType": "vnd.farmmaps.task.blight",
|
||||||
|
"attributes": {
|
||||||
|
"messagePriority": "10"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
With the code in the response message and the code of the crop field, it is possible to check the task's state (error/ok/scheduled/processing). See [Check task status](Polling-task-status.md).
|
||||||
|
|
||||||
|
|
||||||
|
### Late Blight Foliage Resistance settings
|
||||||
|
It is possible to delay the first spray application based on the cultivar resistance level (8 and 9).
|
||||||
|
These settings are stored on the user input item.
|
||||||
|
|
||||||
|
Get the blight advice code from [Get blight advice](#create-advice)
|
||||||
|
Use this code in the following request.
|
||||||
|
|
||||||
|
> Request
|
||||||
|
```javascript
|
||||||
|
GET api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.user.input
|
||||||
|
```
|
||||||
|
|
||||||
|
> Response 200
|
||||||
|
```javascript
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "{code}",
|
||||||
|
// ....
|
||||||
|
"data": {
|
||||||
|
"sprays": [],
|
||||||
|
"phytoPressure": 0,
|
||||||
|
"ignoreOoSpores": true,
|
||||||
|
"ignoreTuberRisk": true,
|
||||||
|
"haulmKillingDate": null,
|
||||||
|
"suppressSprayAdvice": false,
|
||||||
|
"infectionDate": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Set the suppressSprayAdvice to true and enter the infectionDate when an infection in the region has spotted.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
PUT /api/v1/items/{code}
|
||||||
|
{
|
||||||
|
"parentCode": "....",
|
||||||
|
// ....
|
||||||
|
"data": {
|
||||||
|
// ....
|
||||||
|
"suppressSprayAdvice": true,
|
||||||
|
"infectionDate": "2024-09-02T22:00:00Z"
|
||||||
|
},
|
||||||
|
// ....
|
||||||
|
}
|
||||||
|
```
|
||||||
|
> Response 200
|
||||||
|
```javascript
|
||||||
|
{
|
||||||
|
"parentCode": "....",
|
||||||
|
// ....
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Add irrigation
|
### Add irrigation
|
||||||
Irrigations are stored as child item of a crop recording item.
|
Irrigations are stored as child item of a crop recording item.
|
||||||
First step is to get the crop recording item for the crop field.
|
First step is to get the crop recording item for the crop field.
|
||||||
|
Loading…
Reference in New Issue
Block a user