Tasks
Tasks are activities that a twin can perform. An example of a task may be:
List All Publicly Available Tasks
Add an Existing Task to a Quest
§List All Publicly Available Tasks
To get a list of all tasks publicly available:
curl --location --request GET 'http://<API_URL>/tasks/' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>'
Your response will be similar to the following:
{
"data": [
{
"type": "tasks",
"id": "<TASK_ID>",
"attributes": {
"created": "2022-06-21T09:09:57.557598Z",
"modified": "2022-06-21T10:58:06.253767Z",
"name": "test",
"description": "this is a test",
"status": "Yet To Start",
"rating": 0,
"public": false
},
"relationships": {
"summary-image": {
"data": {
"type": "images",
"id": "<IMG_ID>"
}
},
"quest": {
"data": {
"type": "quests",
"id": "<QUEST_ID>"
}
},
"asset": {
"data": null
},
"images": {
"data": [
{
"type": "images",
"id": "<IMG_ID>"
}
],
"meta": {
"count": 1
}
}
}
},
{ ... },
...
]
}
Query Parameters
Query Parameters | Expected Input | Description |
---|---|---|
owned_by | ID of Twin | Filter by the creator of the Task |
quest | ID of Quest | Filter tasks by the Quest they are associated with. |
status | Status | "Yet To Start", "Completed", "Pending", "Expired" |
name | String | Filter tasks by names containing the provided string. |
description | String | Filter tasks by descriptions containing the provided string. |
§Add a Task
Below is an example request to create a new task. In this particular example, we add a name, description, and have added a summary image. A summary image is an image associated with the task that will display in the discovery feed of the mobile app.
curl --location --request POST '<API_URL>/tasks/' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>' \
--data-raw '{
"data": {
"type": "tasks",
"attributes": {
"name" : "test",
"description" : "this is a test",
"summary-image" : "<IMG_ID>"
}
}
}'
This is an example of the response you’ll get.
{
"data": {
"type": "tasks",
"id": "<TASK_ID>",
"attributes": {
"created": "2022-06-21T15:20:43.449168Z",
"modified": "2022-06-21T15:20:43.449168Z",
"name": "test",
"description": "this is a test",
"status": "Yet To Start",
"rating": 0,
"public": false
},
"relationships": {
"summary-image": {
"data": {
"type": "images",
"id": "<IMG_ID>"
}
},
"quest": {
"data": null
},
"asset": {
"data": null
},
"images": {
"data": [],
"meta": {
"count": 0
}
}
}
}
}
§Add an Existing Task to a Quest
§List All of My Tasks
curl --location --request GET '<API_URL>/my/tasks/' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>'
§Details About My Task
curl --location --request GET '<API_URL>/my/tasks/<TASK_ID>' \
--header 'Content-Type: application/vnd.api+json' \
--header 'X-Organization: <ORG_ID>' \
--header 'X-Twin: <TWIN_ID>' \
--header 'Authorization: Token <ACCESS_TOKEN>'
The response will look like the following. The twin-metadata attribute will have business details such as lat/long attributes, opening hours and other information that can be utilized within your task.
{
"data": {
"type": "tasks",
"id": "<TASK_ID>",
"attributes": {
"created": "2022-06-21T15:20:43.449168Z",
"modified": "2022-06-21T15:20:43.449168Z",
"name": "test",
"description": "this is a test",
"summary-image-url": null,
"public": false,
"twin-metadata": {},
"original-twin-metadata": null,
"status": "Yet To Start",
"rating": 0
},
"relationships": {
"images": {
"data": [],
"meta": {
"count": 0
}
},
"summary-image": {
"data": {
"type": "images",
"id": "<IMG_ID>"
}
},
"twin": {
"data": {
"type": "twins",
"id": "<TWIN_ID>"
}
},
"original": {
"data": null
},
"quest": {
"data": null
},
"asset": {
"data": null
}
}
}
}
Query Parameters
Query Parameters | Expected Input | Description |
---|---|---|
owned_by | ID of Twin | Filter by the creator of the Task |
quest | ID of Quest | Filter tasks by the Quest they are associated with. |
is_original | Boolean | Filter on whether task is original or not |
original | ID of Original Quest | Filter tasks by the original they were copied from |
status | Status | "Yet To Start", "Completed", "Pending", "Expired" |
name | String | Filter tasks by names containing the provided string. |
description | String | Filter tasks by descriptions containing the provided string. |