NAV

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

{
  "id": "integer",
  "message": "Communication record created successfully"
}

{
  "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

[
  {
    "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)"
  }
]

{
  "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

Response

{
  "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)"
}

{
  "message": "Communication record not found"
}

{
  "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

Request Body

{
  "sender": "string (required)",
  "receiver": "string (required)",
  "channel": "string (required)",
  "code": "string (required)",
  "message": "string (required)",
  "feedback": "string (required)"
}

Response

{
  "message": "Communication record updated successfully"
}

{
  "message": "Communication record not found"
}

{
  "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

Response

{
  "message": "Communication record deleted successfully"
}

{
  "message": "Communication record not found"
}

{
  "error": "Error deleting communication record",
  "details": "Detailed error information"
}