Order message model

This feature is built to provide real-time communication between all the users involved in any order. It is used on our products as sort of a chat and orders timeline that we call messages, and it includes everything that happens in the order.

ActionMethodResourceDescription
Get allGET/orders/:order_id/messagesGet all messages of an order
CreatePOST/orders/:order_id/messagesAdd a new message to an order
ReadGET/orders/:order_id/messages/:message_id/readUse the last message_id to mark messages as read.

The order message model is composed of the following attributes:

AttribureTypeRequiredDescriptionWhereable
author_idintegerRequiredThe author Id, user who add the itemYes
order_idintegerRequiredThe order idNo
changeJSONnoshow the change in a json with old and newNo
sourcefilenoA file to add (Now working only for image)No
typeintegernoThe type of message:
- 1 order status change
- 2 comments
- 3 images
- 4 signature 1
- 5 signature 2
Yes
can_seestringnocontains levels of user which can see the messages separated by comma
EX: 0,2,3
Yes
commentstringIf type 2The text for the messageNo
driver_idintegernoThe driver id, if driver assigned to an orderYes
ipstringnoThe IP where the message is sent from, must be a valid IP.
Ex. '192.168.1.1'
Yes

📘

Order messages restrictions

  • User level 0 (Type: administrator) can write and read messages of any order.
  • Users level 2 (Type: business owner) can write and read messages of all orders related to his businesses.
  • Users level 3 and 4 (Type: customer and Driver) can write and read messages of orders related to this user.
  • users level 0, 2 and 4, can use mode dashboard to get message as their roll
  • Only users 0 an 2 can get private data which are "can_see", "ip", "user_agent" and "location"