Real-time Communication

Real-time updates are faciliated using Pusher. Please see their documentation for full details on receiving the following events.

Orders

Real-time events are used to keep customers updated with the latest order information, such as status updates or confirmation messages from the restaurant. These events would be used by a third-party ordering/customer-facing application.

Channel Name

The channel name will be: private-o-{order_id}, such as private-o-52a7289e96ba1c6209000003

Events

The following events will be used:

Order Confirmation Update

Sent when a restaurant confirms, adjusts, or rejects an order. Pusher event: order_confirmation

Property Type Description
confirmation integer A code indicating what action was taken, either 1, 2, or 3.
  • 1: The order was confirmed without any adjustments
  • 2: The order was adjusted (an order_adjustment event will contain the adjustment details)
  • 3: The order was rejected
reason string The rejection reason, if confirmation = 3 (rejected)

Order Adjustment

Sent when a restaurant adjusts an order (contains adjustment details). Pusher event: order_adjustment

Property Type Description
time integer For non-advance (ASAP) orders, this contains the adjusted time, in minutes. Example: 45, would indicate a new time of 45 minutes
order_date string For advance orders, this contains the adjusted date, in MM/DD/YYYY format
eta For advance orders, this contains the adjusted time, in H:MM AM format, like 9:45 PM
items array of strings Array of ordered item IDs (not menu item IDs, but the ID of the item in a given order) that were removed from the order by the restaurant
options array of strings Array of option names that were removed from the order by the restaurant

Order Status Updates

Sent when a restaurant updates an order status. These status updates occur after the order is confirmed, with status names like "Out for Delivery" or "Delivered." Pusher event: order_tracker

Property Type Description
time date/time string The status update timestamp
status string The new status, like "Out for Delivery"

Restaurants

Real-time events are used to notify restaurants of a variety of events, like new order arrivals and customer confirmations. These events are built into Open Dining's order management applications, but documented here for potential third-party use.

Channel Name

The channel name will be: presence-r-{restaurant_id}, such as presence-r-52a7289e96ba1c6209000003

Events

The following events will be used:

New Orders

Sent when a restaurant receives a new order. Pusher event: new_order

Property Type Description
order_id string The Mongo ID of the new order

Order Confirmation Update

Sent when a customer confirms, adjusts, or rejects an order. This usually occurs after a restaurant adjusts an order, but may also occur if a customer cancels an order before it has been confirmed. Pusher event: order_user_confirmation

Property Type Description
order_id string The Mongo ID of the order
confirmation integer A code indicating what action was taken, either 1, 2, or 3.
  • 1: The order was confirmed without any adjustments
  • 2: The order was adjusted (an order_adjustment event will contain the adjustment details)
  • 3: The order was rejected

Authorization

To access the private Pusher channels, you will need an auth token. See the Pusher client documentation for more details. Depending on the channel type, various forms of authentication can be used:

The Authorization Endpoint URL to use in Pusher is https://opendining.net/api/v1/pusher/auth. It can be called via HTTP GET or POST for client flexibility.

API Parameters - Secret Key Authorization

Property HTTP Method Type Description
key GET string The API Key of the application developer
secret GET or POST string The API Secret for the given restaurant

API Parameters - Access Token Authorization

Property HTTP Method Type Description
key GET string The API Key of the application developer
access_token GET or POST string The Access Token for a given customer/user account

Examples

JavaScript Pusher client auth with a restaurant's secret key:

var options = { authEndpoint: 'https://opendining.net/api/v1/pusher/auth?key=API_KEY&secret=API_SECRET' };
var pusher = new Pusher('app_key', options);
var restaurantChannel = pusher.subscribe('presence-r-RESTAURANT_ID');

JavaScript Pusher client auth with a user's access token:

var options = { authEndpoint: 'https://opendining.net/api/v1/pusher/auth?key=API_KEY&access_token=ACCESS_TOKEN' };
var pusher = new Pusher('app_key', options);
var restaurantChannel = pusher.subscribe('private-o-ORDER_ID');