Getting Started with User Context Service

Why User Context Service Employs GraphQL

We chose GraphQL for the User Context Service because it offers significantly more flexibility for our integrations. The ability to define precisely the data you want—and only the data you want—is a powerful advantage over the REST API endpoints. GraphQL lets you replace multiple REST requests with a single call to fetch the data you specify.

For an in-depth understanding of GraphQL concepts and terminology, please refer to Interacting with GraphQL.

The API Endpoint

  • Production https://cpce-user-context-service.us-west-2.prodp.gcotechp.expedia.com/graphql
  • Sandbox https://cpce-user-context-service-demo.us-west-2.test.gcotechp.expedia.com/graphql

API Reference

You can query and explore the User Context Service GraphQL schema definition.

Authentication

User Context Service GraphQL Endpoint expects Authorization in headers for authenticating the incoming requests. Please reach out to the Platform Team to get secrets for sandbox and production environment.

Once you have the secret, refer to the below sample to make a request.

POST {{ENDPOINT}}/graphql
Content-Type: application/json
Authorization: {{Secret}}

{ “query”: “query{retrieveUser(context:{ partnerId:\“39824e66-7eb1-4099-8110-ed41d7793f4d\“ businessSegmentId:\"4686b23c-3b0b-4abf-8baf-88da5b304cb5\" locale:""} identifier:{ identifierType:EMAIL identifierValue:\"abc@xyz.com\"}){userId}}” } 

Consuming the API

The following sample GraphQL queries correspond to common scenarios for extracting user and booking data from the User Context Service.

Retrieve Booking Details

Retrieve Booking details using Booking Identifiers

Input Mandatory Arguments

  1. partnerId Partner GUID the Booking belongs to. Default value "".
  2. businessSegmentId Business Segment GUID the Booking belongs to. Default value "".
  3. locale Locale information to localize response content. Default value "".
  4. identifierType Type of the input Booking Identifier. Valid Values ORDERNUMBER POINTOFSALEORDERREFERENCENUMBER.
  5. identifierValue Booking Identifier Value.

Input Optional Arguments

  1. filterArgs.email if response needs to be filtered based on email associated with the booking.
  2. filterArgs.phone if response needs to be filtered based on phoneNumber associated with the booking.
  3. filterArgs.last4digitOfCc if response needs to be filtered based on whether any of the payment instrumentation for the booking has used a credit card matching provided last 4 digits.

Sample Query

query {
  retrieveBooking(
    context: {
      partnerId: "bee71ae7-2a74-4d45-9817-c816784734e6"
      businessSegmentId: "4686b23c-3b0b-4abf-8baf-88da5b304cb5"
      locale: "en_US"
    }
    identifier: {
      identifierType: POINTOFSALEORDERREFERENCENUMBER
      identifierValue: "7552789044835"
    }
  ) {
    reservationUuid
    bookedDateTime
    bookedItems {
      status
      orderLineId
      productType
    }
    tripStage
    orderNumber
    orderStatus
    pointOfSaleOrderReferenceNumber
    tripStage
    tripStartDateTime
    tripEndDateTime
    stageOfTravel
    bookingUpdateDateTime
  }
}

Retrieve Bookings

Retrieve Bookings using user identifiers

Input Mandatory Arguments

  1. partnerId Partner GUID to define the scope of Bookings to be searched.
  2. businessSegmentId Business Segment GUID to define the scope of Bookings to be searched.
  3. locale Locale information to localize response content. Default value "".
  4. identifierType Type of the input User Identifier. Valid Values EMAIL PHONE ANI.
  5. identifierValue User Identifier Value.

Input Optional Arguments

  1. filterArgs.orderStatus if bookings need to be filtered based on status. Values BOOKED CANCELED
  2. filterArgs.stageOfTravel if bookings need to be filtered based on travel stage. Values COMPLETED NOT_COMPLETED
  3. filterArgs.last4digitOfCc if bookings need to be filtered based on whether any of the payment instrumentation for the booking has used a credit card matching provided last 4 digits.
  4. filterArgs.tripToEndWindow if bookings need to be filtered based on number of days for trip to end.

Sample Query

query {
  retrieveBookings: retrieveBookings(
    context: {
      businessSegmentId: "a0c41f1d-1309-427a-a1eb-746dbb6d9cba"
      partnerId: "33bea4ef-93c2-4166-b297-2b5e07b35235"
      locale: "en_US"
    }
    identifier: {
      identifierType: EMAIL
      identifierValue: "kkaneta@expedia.com"
    }
  ) {
    bookedItems {
      lodging {
        checkInDate
      }
      air {
        flightType
      }
    }
    bookedDateTime
    bookingUpdateDateTime
    isPackage
    orderNumber
    orderStatus
    tripStartDateTime
    tripEndDateTime
    tripStage
    stageOfTravel
    pointOfSaleOrderReferenceNumber
  }
}

Retrieve User Details

Retrieve User details using User Identifiers

Input Mandatory Arguments

  1. partnerId Partner GUID the Booking belongs to. Default value "".
  2. businessSegmentId Business Segment GUID the Booking belongs to. Default value "".
  3. locale Locale information to localize response content. Default value "".
  4. identifierType Type of the input Booking Identifier. Valid Values EMAIL CUSTOMERID PHONE.
  5. identifierValue Booking Identifier Value.

Sample Query

query {
  retrieveUser(
    context: {
      partnerId:"d8330dd6-a10b-49cc-a7ee-7217c2eb96b0",
      locale:"en_US",
      businessSegmentId:"0e9a4379-2497-42e0-9ba2-123aa59bd727"
    },
    identifier: {
      identifierType: EMAIL,
      identifierValue: "pgakhar@expediagroup.com"
    }
  ) {
    firstName
    lastName
    emailAddress
    attributes
  }