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.

Action

Method

Resource

Description

Get all

GET

/orders/:order_id/messages

Get all messages of an order

Create

POST

/orders/:order_id/messages

Add a new message to an order

Read

GET

/orders/:order_id/messages/:message_id/read

Use the last message_id to mark messages as read.

The order message model is composed of the following attributes:

Attribure

Type

Required

Description

Whereable

author_id

integer

Required

The author Id, user who add the item

Yes

order_id

integer

Required

The order id

No

change

JSON

no

show the change in a json with old and new

No

source

file

no

A file to add (Now working only for image)

No

type

integer

no

The type of message:

  • 1 order status change
  • 2 comments
  • 3 images
  • 4 signature 1
  • 5 signature 2

Yes

can_see

string

no

contains levels of user which can see the messages separated by comma
EX: 0,2,3

Yes

comment

string

If type 2

The text for the message

No

driver_id

integer

no

The driver id, if driver assigned to an order

Yes

ip

string

no

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