Interpreting the Event

Determining Changes

Three key fields are used to determine what has changed:
  • elementName
  • oldValue
  • newValue

New Records

When receiving the record of a new Reservation, the payload will include the following for each field in the Reservation:
{
    "elementName": "First Name",
    "newValue": "NewFirstName"
    "oldValue": ""
}

Note:

For the polling API, the "oldValue" will not be in the payload.

Updated Records

The following scenarios reflect when a record is updated and a field is changed:

  • If a field was blank before the update, the polling API returns:
{
    "dataElement": "First Name",
    "newValue": "NewFirstName"
}
The streaming API returns:
{
    "elementName": "First Name",
    "newValue": "NewFirstName",
    "oldValue": ""
}
  • If the field is updated with a blank value, the polling API returns:
{
    "dataElement": "First Name",
    "oldValue": "TheOldFirstNameValue"
}
The streaming API returns:
{
    "elementName": "First Name",
    "newValue": "",
    "oldValue": "OldFirstName"
}
  • If the field was not changed during this event, the polling API returns:
{
    "elementName": "First Name",
    "newValue": "MyFirstName",
    "oldValue": "MyFirstName"
}
Removed Fields
If a field has been removed, this is reflected as:
{
    "elementName": "First Name",
    "oldValue": "OldFirstNameValue",
    "newValue": ""
}

Retrieving Unchanged Fields

As you can see in updated records, if a field remains unchanged neither the "oldValue" nor the "newValue" is sent. To retrieve the current (unchanged) value, make a GET call to the resource using the "primaryKey" field that is sent in the event payload. For example, if the event is UPDATE RESERVATION, the primaryKey will be a reservationId, so the full resource can be obtained using the getReservation API.

Comparing the Event Payload from Polling and Streaming APIs

Polling API Business Event payload
{
    "businessEventData": [
        {
            "businessEvent": {
                "header": {
                    "moduleName": "Reservation",
                    "actionType": "NEW RESERVATION",
                    "actionId": "1234567",
                    "primaryKey": "987654",
                    "publisherId": "15951",
                    "createdDateTime": "2021-06-03 16:45:48.0",
                    "hotelId": "ABC123"
                },
                "detail": [                    {
                        "dataElement": "FIRST NAME"
                    },
                    {
                        "dataElement": "CONFIRMATION NO",
                        "newValue": "123456789"
                    }
                ]
            },
            "businessEventId": {
                "id": "1234567"
            }
        }
    ]
}
Streaming API Business Event payload
{
    "data": {
        "newEvent": {
        "metadata": {
            "offset": 100,
            "uniqueEventId": "0ed06ced-843e-4e35-86ec-e2564cf495ee"
        },
        "moduleName": "Reservation",
        "eventName": "NEW RESERVATION",
        "primaryKey": "123456",
        "timestamp": "2021-06-03 16:45:48.000",
        "hotelId": "ABC123",
        "publisherId": "15951",
        "actionInstanceId": "222222",
        "detail": [
            {
            "newValue": "NewFirstNameValue",
            "oldValue": "",
            "elementName": "FIRST NAME",
            "scopeFrom": "",
            "scopeTo": "",
            "elementType": null,
            "elementRole": null,
            "elementSequence": null
            },
            {
            "newValue": "123456789",
            "oldValue": "",
            "elementName": "CONFIRMATION NO",
            "scopeFrom": "",
            "scopeTo": "",
            "elementType": null,
            "elementRole": null,
            "elementSequence": null
            }
        ]
        }
    }
}

Comparing Fields in the Polling and Streaming APIs

Section Field Name in Polling Section Field Name in Streaming Use
Header moduleName Event Header moduleName Grouping of events, useful guide to which API to use if unchanged data is needed.
Header actionType Event Header eventName Name of the event that occurred.
Header actionId Event Header actionInstanceId Number of the event emitted from OPERA.
Header primaryKey Event Header primaryKey OPERA internal ID of the resource on which the event occurred. For example, an UPDATE RESERVATION event occurs on a reservation resource, so the primaryKey is the reservationId.
Header parentActionId n/a n/a n/a
Header publisherId Event Header publisherId User reference Id of the user who created the transaction in OPERA.
Header createdDateTime Event Header timestamp Date and time the event occurred.
Header hotelId Event Header hotelId OPERA internal Id of the hotel in which the event occurred.
n/a n/a Subscription chainCode OPERA Shared Security Domain organization code within which the event occurred.
n/a n/a Metadata offset Offset number of the event emitted from OHIP.
n/a n/a Metadata uniqueEventId Unique identifier for the event emitted from OHIP.
Detail dataElement Detail elementName Name of the field that changed.
Detail oldValue Detail oldValue Old value of the field that changed (see the Determining Changes section above).
Detail newValue Detail newValue New value of the field that changed (see the Determining Changes section above).
Detail scopeFrom Detail scopeFrom Beginning of the data range for which the business event is valid. For example, if a rate code or rate amount is different for different stay dates and the rate is updated, the scopeFrom determines the start of the stay date range that was updated.
Detail scopeTo Detail scopeTo End of the data range for which the business event is valid. For example, if a rate code or rate amount is different for different stay dates and the rate is updated, the scopeTo determines the end of the stay date range that was updated.