Gobierto Plans / Projects
Create plan projects
POST
/api/v1/plans//projects
Creates and updates the projects of a plan. The request must include a valid token of an authorized admin.
The body of the request should include only the attributes that needs to be created or updated. Any attribute in the body will be updated.
If the terms are included in the request, they will be updated also, following these rules:
- if the project has
external_id
will search for existing projects to update it - if it doesn't exist, the project will be created
For deleting existing projects refer to the project deletion endpoint.
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
Body:
It's expected to be in JSON format with the following structure:
{
"data": {
"attributes": {
// ...
}
}
}
Attributes:
name_translations | mandatory | a JSON with the different locales and the names on each locale. Available locales are es , en and ca |
external_id | this field can be used to store the identifier in the integrating system. The value must be unique. | |
visibility_level | published or draft . By default is draft | |
moderation_stage | not_sent , sent , in_review , approved or rejected . By default is not_sent | |
progress | a float between 0 and 100 with the percentage of progress | |
position | an integer representing the position of the project in the category projects. | |
starts_at | a date in format YYYY-MM-DD with the start date of the project | |
ends_at | a date in format YYYY-MM-DD with the end date of the project | |
category_external_id | the internal id or external_id of the category the project belongs to | |
status_external_id | the internal id or the external_id of the status the project has |
The list of attributes might include more vocabularies, which can be defined as projects custom fields (see Campos Personalizados for more detail). In that case, the rule of these dynamic attributes is very simple:
custom_field_<type>_<uid>
,
where the type is one of the following supported types:
vocabulary_options
string
paragraph
date
and the uid is the custom field identifier.
In all the cases the expected value is a string, but depending on the type the value can have some differences:
- string: A plain string which will be treated without transformations
- paragraph: The string will be parsed as a markdown formatted document
- date: A string containing a date with format YYYY-MM-DD
- vocabulary_options: The text of a valid option of the vocabulary custom field. If the custom field has multiple translations use the value in the default language of the site
Example of request body. The projects
entry is an array of projects:
{
"projects": [
"name_translations": {
"en": "New proyecto",
"es": "Nuevo pn"
},
"external_id": "P0001",
"visibility_level": "visible",
"progress": 75.3,
"position": 2,
"starts_at": "2022-10-01",
"ends_at": "2023-10-01",
"custom_field_vocabulary_options_department": "Zonas verdes: Parques y Jardines",
"custom_field_string_code": "AZ-00046",
"custom_field_paragraph_activities_list": "* Poda\n* Riego\n* Limpieza de zonas verdes",
"custom_field_date_revision_date": "2023-01-15"
},
{ ... }
]
}
Response:
- If the token is invalid or the admin is not allowed to create term: JSON with
Unauthorized
orModule not allowed
with status401 Unauthorized
- If the resource could be created or already existing: JSON with the complete list of projects.
List plan projects
GET
/api/v1/plans/<plan_id>/projects
Lists the projects included in a plan. The request must include a valid token of an authorized admin.
The plan identifier of the URL can be both:
- the plan internal
id
- the plan
slug
if exists
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
Delete a plan projects
DELETE
/api/v1/plans/<plan_id>/projects/
Deletes a project in a plan. The request must include a valid token of an authorized admin.
The plan identifier of the URL can be both:
- the plan internal
id
- the plan
slug
if exists
The project identifier of the URL can be both:
- the project internal
id
- the project
external_id
if exists
Headers:
Authorization
:Bearer TOKEN
A valid token of an admin with permissions to create terms must be provided
The request does not include a body.
Response:
- If the token is invalid or the admin is not allowed to create term: JSON with
Unauthorized
orModule not allowed
with status401 Unauthorized
- If the resource could be deleted it returns a successfull status code.
Updated 10 months ago