API – Notices
Creating notices
- To create an ad you need to send a POST request to the following URL /api/rest.php/notices
- The body of the request must contain a JSON object with information about the notice.
- The request must contain the headings Content-Type: application/json;charset=UTF-8 and Authorization: Bearer xxxxxx.
Request example:
curl 'https://your-domain.davintoo.com/api/rest.php/notices' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"type": "simple", "title":"LMSCollaboratorBot", "description":"LMSCollaboratorBot will help you to be aware of all important events", "is_published":"1"}'
Format of the object with with information about the ad
*Mandatory fields are marked with an asterisk
Field | Type | Description |
---|---|---|
type* | String | Notice type(there are three types: simple, free, required) |
title* | String | Notice title |
description* | String | Text |
is_published | Number | Check mark, 1 - announcement is published, 0 - news is NOT published |
date_begin | String | Publication date |
date_end | String | Completion date |
Answer
- In case of successful request (HTTP response code - 200), there will be a JSON response with information about the created notice:
{"data":{"id":105,"type": "simple", "title":"LMSCollaboratorBot", "description":"LMSCollaboratorBot will help you to be aware of all important events", "date_begin": null, "date_end": null, "is_published": true,...}
- In case of error (HTTP response code - 400) it returns JSON object with error information:
{"title":{"required":"Field cannot be empty"}}
Assigning notices to users
- To assign a notice to a user, you need to send a POST request to the following URL /api/rest.php/notices/{noticeId}?action=assign
- The request string must contain {noticeId} Id of the notice. The body of the request must contain a JSON object with the following fields:
- Id of the useruser_id
- truechecked
- The query must contain the headings Content-Type: application/json;charset=UTF-8 and Authorization: Bearer xxxxxx. Request example:
curl 'https://your-domain.davintoo.com/api/rest.php/notices/492?action=assign' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"user_id":5694, "checked":true}'
Answer
-
In case of successful request (HTTP response code - 200), the following result will be returned:
{"data": true}
-
In case of error (HTTP response code - 400) it returns JSON object with information about the error
List of notices
-
To get the list of created ads you need to send GET request to the following URI /api/rest.php/notices?sorting[created_at]=desc
-
The request must contain the headings Content-Type: application/json;charset=UTF-8 и Authorization: Bearer xxxxxx.
Request example:
curl 'https://your-domain.davintoo.com/api/rest.php/notices?sorting[created_at]=desc' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8'
The request supports filtering by the following fields:
- The name of the adtitle
- Ad type (simple, free, required)type
- Date of creationcreated_at
- Start datedate_begin
- Completion datedate_end
Example of a request with a search by ad type:
curl 'https://your-domain.davintoo.com/api/rest.php/notices?filter[type]=free&sorting[created_at]=desc' -H 'Authorization: Bearer xxxxxx' -H 'Content-Type: application/json;charset=UTF-8'
Answer
-
In case of successful request (HTTP response code - 200), the following result will be returned:
- ads arraydata
- pagination object (information about the number of pages, the current page, the number of ads)pager
-
In case of error (HTTP response code - 400) it returns JSON object with error information