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": null
}

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:

  1. 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": ""
    }
    
  2. 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"
    }
  3. If the field was not changed during this event,

    The polling API returns:

    {
       "elementName": "First Name",
       "newValue": "MyFirstName",
       "oldValue": "MyFirstName"
    }
    By default, the streaming API returns the same fields. However, if the "delta" input variable is set to true, the streaming API returns only fields whose value has changed. In this scenario, the elementName "First Name" would not be sent by the streaming API.

Removed Fields

If a field has been removed, this is reflected as:

{
   "elementName": "First Name",
   "oldValue": "OldFirstNameValue"
}

Retrieving Unchanged Fields

As you can see in Updated records, if a field remains unchanged neither the "oldValue" nor "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
        }
      ]
    }
  }
}

Table 13-3 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 are needed.

Header

actionType

Event Header

eventName

Name of the event that occurred.

Header

actionId

Number of the event emitted from OPERA.

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

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.

Subscription

chainCode

OPERA Shared Security Domain organization code within which the event occurred.

Metadata

offset

Offset number of the event emitted from OHIP.

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 notes in the ‘Determining Changes’ section)

Detail

newValue

Detail

newValue

New value of the field that changed (see notes in the ‘Determining Changes’ section)

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.