Server side of My Land App
Path | Method | Description |
---|---|---|
/user |
POST | Registers a new user |
/user |
GET | Logs the user in |
/user |
DELETE | Deletes a user |
POST /user
Endpoint used to register a new user. Requires a payload with the user's credentials
{
"username": "david",
"password": "password123"
}
GET /user
Endpoint to log in the user through basic authentication.
Returns a JWT token in the header Access-Token
.
The token is valid for 30 days.
DELETE /user
Endpoint to delete the current user.
Request must have a valid token
All requests (besides login and register) must send a valid JWT token to the server.
Either in the header Authorization
as: Bearer {JWT-token}
.
Or in the parameter access_token
.
Entity:
Field | Type | Description |
---|---|---|
id | number | identifier |
name | string | name of the land |
description | string | description or state of the land |
area | number | calculation of the area value |
lat | number | latitude of the visualization point |
lon | number | longitude of the visualization point |
zoom | number | zoom of the camera in the visualization point |
bearing | number | bearing of the camera in the visualization point |
createdAt | Date | timestamp of the type's creation |
modifiedAt | Date | timestamp of the type's last change |
Path | Method | Parameters | Description |
---|---|---|---|
/land |
GET | Gets all lands from user | |
/land |
POST | Creates a new land | |
/land |
PATCH | Patches a land | |
/land |
GET | id={landId} |
Fetches a single land |
/land/{landId} |
GET | Fetches a single land | |
/land/{landId} |
DELETE | Deletes a land | |
/land/{landId}/object |
Land objects endpoints | ||
/land/{landId}/objectType |
Object type endpoints | ||
/land/{landId}/taskType |
Task type endpoints | ||
/land/{landId}/task |
Task endpoints |
Fetches all the lands from the user
Request must have a valid token
Creates a new land
Request must have a valid token
Requires a payload with the new land
{
"name": "example land name",
"description": "some description",
"area": 123.45,
"lat": 12.34,
"lon": 12.34,
"zoom": 5,
"bearing": 123.45,
"polygon": "some GeoJSON polygon"
}
returns the created land (payload + id)
Changes either the description or the polygon and values associated with it.
Request must have a valid token
Requires one of the following payloads
{
"id": 1,
"description": "some description"
}
{
"id": 1,
"area": 123.45,
"lat": 12.34,
"lon": 12.34,
"zoom": 5,
"bearing": 123.45,
"polygon": "some GeoJSON polygon"
}
Fetches a single land
Request must have a valid token
The id can be in the path or as a parameter
Deletes a single land
Request must have a valid token
Entity:
Field | Type | Description |
---|---|---|
id | number | identifier |
element | string | GeoJSON string describing the element |
status | string | description of state of the object |
typeId | number | identifier of the object type |
Path | Method | Parameters | Description |
---|---|---|---|
/land/{landId}/object |
GET | Gets all objects from land | |
/land/{landId}/object |
POST | Creates a new object | |
/land/{landId}/object |
DELETE | type={id} |
Deletes all objects of a type |
/land/{landId}/object/{id} |
PUT | Edits an object | |
/land/{landId}/object/{id} |
DELETE | Deletes an object |
Fetches all objects from a land
Request must have a valid token
Creates a new object in the given land
Request must have a valid token
Requires a payload with the new object
{
"element": "Some GeoJSON",
"status": "Some status",
"typeId": 1
}
Edits the data of a land object
Request must have a valid token
Requires a payload with the new data
{
"element": "Some GeoJSON",
"status": "Some status",
"typeId": 1
}
Deletes an existing object
Request must have a valid token
Requires an id as a path parameter
Deletes all objects of a given type
Request must have a valid token
Requires a type as a query parameter
Entity:
Field | Type | Description |
---|---|---|
id | number | identifier |
name | string | name of the object type |
color | string | hex color of the object |
icon | string | icon representing the object type |
createdAt | Date | timestamp of the type's creation |
modifiedAt | Date | timestamp of the type's last change |
Path | Method | Description |
---|---|---|
/land/{landId}/objectType |
GET | Gets all object types |
/land/{landId}/objectType |
POST | Creates new object type(s) |
/land/{landId}/objectType/{id} |
PUT | Edits an object type |
/land/{landId}/objectType/{id} |
DELETE | Deletes an object type |
Fetches all object types for a land
Request must have a valid token
Creates one or multiple object types in the given land
Request must have a valid token
Requires one of the following payloads
{
"name": "example",
"color": "#ffffff",
"icon": "some icon name"
}
[
{
"name": "example",
"color": "#ffffff",
"icon": "some icon name"
},
"..."
]
Edits the data of an object type
Request must have a valid token
Requires an id as a path parameter
Requires a payload with the new object type
{
"name": "example",
"color": "#ffffff",
"icon": "some icon name"
}
Deletes an existing object type
Request must have a valid token
Requires an id as a path parameter
Entity:
Field | Type | Description |
---|---|---|
id | number | identifier |
name | string | name of the task type |
description | string | description of the task |
Path | Method | Description |
---|---|---|
/land/{landId}/taskType |
GET | Gets all task types from land |
/land/{landId}/taskType |
POST | Creates new task type(s) |
/land/{landId}/taskType/{id} |
PUT | Edits a task type |
/land/{landId}/taskType/{id} |
DELETE | Deletes a task type |
Fetches all task types for a land
Request must have a valid token
Creates one or multiple task types in the given land
Request must have a valid token
Requires one of the following payloads
{
"name": "Planting",
"description": "planting seeds for some crops"
}
[
{
"name": "Planting",
"description": "planting seeds for some crops"
},
"..."
]
Edits the data of a task type
Request must have a valid token
Requires an id as a path parameter
Requires a payload with the new task type
{
"name": "Planting",
"description": "planting seeds for some crops"
}
Deletes an existing task type
Request must have a valid token
Requires an id as a path parameter
Entity:
Field | Type | Description |
---|---|---|
id | number | identifier |
landId | number | identifier of the land |
objectId | number | identifier of the object |
taskTypeId | number | identifier of the task type |
priority | number | priority of the task (1 to 5) |
notes | string | any notes about the task |
createdAt | Date | timestamp with creation time |
modifiedAt | Date | timestamp with change time |
completedAt | Date/null | timestamp with completion time |
archivedAt | Date/null | timestamp with archiving time |
Path | Method | Parameters | Description |
---|---|---|---|
/task/{id} |
GET | (optional) query=all\season\open |
Gets all user tasks |
/land/{landId}/task |
GET | (optional) objectId={id} |
Gets all land/object tasks |
/land/{landId}/task |
POST | Creates new task(s) | |
/task/{id} |
PUT | Edits a task | |
/task/{id}/complete |
PUT | Completes a task | |
/task/{id}/archive |
PUT | Archives a task | |
/task/{id} |
DELETE | Deletes a task |
Fetches user tasks
The default value for the query parameter is all
.
The possible values for the query parameter are:
all
: fetches all user tasks, in any stateseason
: fetches only tasks that are not archivedopen
: fetches only tasks that are neither completed nor archived
Request must have a valid token
Fetches all tasks from the land. If the parameter objectId is set, only fetches tasks for the specified object
Request must have a valid token
Creates one or multiple tasks in the given land
Request must have a valid token
Requires one of the following payloads
{
"objectId": 1,
"taskTypeId": 2,
"priority": 3,
"notes": "some notes about the task"
}
[
{
"objectId": 1,
"taskTypeId": 2,
"priority": 3,
"notes": "some notes about the task"
},
"..."
]
Edits the data of a task
Request must have a valid token
Requires an id as a path parameter
Requires a payload with the new task type
{
"objectId": 1,
"taskTypeId": 2,
"priority": 3,
"notes": "some notes about the task"
}
Sets a task as completed
Request must have a valid token
Requires an id as a path parameter
Sets a task as archived
Request must have a valid token
Requires an id as a path parameter
Deletes a task
Request must have a valid token
Requires an id as a path parameter
Object template entity
Field | Type | Description |
---|---|---|
default | Map[string, List[ObjectType]] | default object templates |
fromLands | List[List[ObjectType]] | object templates in use by lands |
Task template entity
Field | Type | Description |
---|---|---|
default | Map[string, List[TaskType]] | default task templates |
fromLands | List[List[TaskType]] | task templates in use by lands |
Path | Method | Parameters | Permissions | Description |
---|---|---|---|---|
/template/object |
GET | locale |
User | Gets all object templates for locale |
/template/object |
POST | Admin | Creates a new object template | |
/template/object |
PUT | Admin | Edits an existing object template | |
/template/object |
DELETE | locale , name |
Admin | Deletes an object template |
/template/task |
GET | locale |
User | Gets all task templates for locale |
/template/task |
POST | Admin | Creates a new task template | |
/template/task |
PUT | Admin | Edits an existing task template | |
/template/task |
DELETE | locale , name |
Admin | Deletes a task template |
Fetches all object templates for the provided locale
Request must have a valid token
Creates a new object template
Requires a payload with the new data
{
"locale": "en",
"name": "some name",
"objTypes": [
{
"name": "example",
"color": "#ffffff",
"icon": "some icon name"
},
"..."
]
}
Only admin users can make this request.
Edits the data of an object template.
Requires a payload with the new data
{
"locale": "en",
"name": "some name",
"objTypes": [
{
"name": "example",
"color": "#ffffff",
"icon": "some icon name"
},
"..."
]
}
Only admin users can make this request.
Deletes an object template
Requires both locale and name as a query parameters
Only admin users can make this request.
Fetches all task templates for the provided locale
Request must have a valid token
Creates a new task template
Requires a payload with the new data
{
"locale": "en",
"name": "some name",
"taskTypes": [
{
"name": "example",
"description": "some description"
},
"..."
]
}
Only admin users can make this request.
Edits the data of a task template.
Requires a payload with the new data
{
"locale": "en",
"name": "some name",
"taskTypes": [
{
"name": "example",
"description": "some description"
},
"..."
]
}
Only admin users can make this request.
Deletes a task template
Requires both locale and name as a query parameters
Only admin users can make this request.