CommunicationAPI Documentation
Base URL: http://thruxion.com:3001/api/
This API allows to register all kind of messages exchange between humans and/or machines based on the communication logic of sender/reciever.
CreateCommunication
Method: POST
URL: http://thruxion.com:3001/api/communication
Description: Creates a new communication record. Optionally inserts space_time
and file
data before linking them to the communication record via foreign keys.
Request Body
{
"sender": "string (required)",
"receiver": "string (required)",
"channel": "string (required)",
"code": "string (required)",
"message": "string (required)",
"feedback": "string (required)",
"space_time": {
"longitude": "double (optional)",
"latitude": "double (optional)",
"date_time": "string (format: YYYY-MM-DD HH:MM:SS, optional)"
},
"file": {
"file_path": "string (optional)"
}
}
Response
- Status 200
{
"id": "integer",
"message": "Communication record created successfully"
}
- Status 500
{
"error": "Error message",
"details": "Detailed error information"
}
Request Body:
{
"sender": "Alice",
"receiver": "Bob",
"channel": "Email",
"code": "MSG001",
"message": "Hello, Bob!",
"feedback": "Positive",
"space_time": {
"longitude": 100.123,
"latitude": 20.567,
"date_time": "2024-11-24 12:00:00"
},
"file": {
"file_path": "/files/document.pdf"
}
}
Example Responses:
CreateCommunication (No status - No code)
json
{}
GetAllCommunications
Method: GET
URL: http://50.192.137.250:3001/api/communication
Description: Retrieves all communication records, including linked space_time
and file
data.
Response
- Status 200
[
{
"id": "integer",
"sender": "string",
"receiver": "string",
"channel": "string",
"code": "string",
"message": "string",
"feedback": "string",
"space_time_id": "integer (nullable)",
"file_id": "integer (nullable)",
"longitude": "double (nullable)",
"latitude": "double (nullable)",
"date_time": "string (nullable)",
"file_path": "string (nullable)"
}
]
- Status 500
{
"error": "Error retrieving communication records",
"details": "Detailed error information"
}
Example Responses:
GetAllCommunications (No status - No code)
json
{}
GetCommunicationByID
Method: GET
URL: http://thruxion.com:3001/api/communication/2
Description: Retrieves a single communication record by its ID, including linked space_time
and file
data.
Path Parameters
id
(integer, required): The ID of the communication record.
Response
- Status 200
{
"id": "integer",
"sender": "string",
"receiver": "string",
"channel": "string",
"code": "string",
"message": "string",
"feedback": "string",
"space_time_id": "integer (nullable)",
"file_id": "integer (nullable)",
"longitude": "double (nullable)",
"latitude": "double (nullable)",
"date_time": "string (nullable)",
"file_path": "string (nullable)"
}
- Status 404
{
"message": "Communication record not found"
}
- Status 500
{
"error": "Error retrieving communication record",
"details": "Detailed error information"
}
UpdateCommunicationByID
Method: PUT
URL: http://thruxion.com:3001/api/communication/4
Description: Updates a communication record by its ID. Does not modify linked space_time
or file
data.
Path Parameters
id
(integer, required): The ID of the communication record.
Request Body
{
"sender": "string (required)",
"receiver": "string (required)",
"channel": "string (required)",
"code": "string (required)",
"message": "string (required)",
"feedback": "string (required)"
}
Response
- Status 200
{
"message": "Communication record updated successfully"
}
- Status 404
{
"message": "Communication record not found"
}
- Status 500
{
"error": "Error updating communication record",
"details": "Detailed error information"
}
Request Body:
{
"sender": "Alice Updated 4",
"receiver": "Bob",
"channel": "Chat",
"code": "Written",
"message": "Updated Message",
"feedback": "Neutral"
}
DeleteCommunicationByID
Method: DELETE
URL: http://thruxion.com:3001/api/communication/2
Description: Deletes a communication record by its ID.
Path Parameters
id
(integer, required): The ID of the communication record.
Response
- Status 200
{
"message": "Communication record deleted successfully"
}
- Status 404
{
"message": "Communication record not found"
}
- Status 500
{
"error": "Error deleting communication record",
"details": "Detailed error information"
}