Langkau ke kandungan

Hotel

Book a rate. Requires an `Idempotency-Key` header.

post/v1/hotels/bookings

  • Memerlukan pengesahan
  • Memerlukan Idempotency-Key

Badan permintaanHotelBookingCreateRequest

  • rateKeystring
  • BookingRoom[]
    • Guest[]
  • HolderInfo
    • firstNamestring
    • lastNamestring
    • emailstring
    • phonestring
  • specialRequestsstringboleh null
Contoh
{
  "rateKey": "string",
  "rooms": [
    {
      "guests": [
        {
          "type": "string",
          "gender": "string",
          "firstName": "string",
          "lastName": "string"
        }
      ]
    }
  ],
  "holder": {
    "firstName": "string",
    "lastName": "string",
    "email": "string",
    "phone": "string"
  },
  "specialRequests": "string"
}

Respons

201CreatedHotelBooking

  • bookingIdstring
  • bookingReferencestringboleh null
  • statusstring

    confirmed | pending | cancelled | unknown.

  • hotelCodestringboleh null
  • hotelNamestringboleh null
  • cityNamestringboleh null
  • roomTypestringboleh null
  • checkInstringboleh null
  • checkOutstringboleh null
  • Money

    Money on the wire: decimal string (never a float) + ISO 4217.

    • amountstring
    • currencystring
  • refundablebooleanboleh null
  • priceChangedboolean
  • HolderInfo
    • firstNamestring
    • lastNamestring
    • emailstring
    • phonestring
  • BookingRoom[]
    • Guest[]
  • specialRequestsstringboleh null
  • confirmedAtstring (date-time)boleh null
  • 402Payment RequiredButiran masalah RFC 7807
  • 409ConflictButiran masalah RFC 7807

Contoh kod

Program lengkap yang menandatangani permintaan mengikut cara gateway mengesahkannya. Gantikan YOUR_KEY_ID dan YOUR_SECRET.

# Sign the request: METHOD \n path+query \n unix time \n nonce \n sha256(body)
KEY_ID="YOUR_KEY_ID"
SECRET="YOUR_SECRET"
BODY='{
  "rateKey": "string",
  "rooms": [
    {
      "guests": [
        {
          "type": "string",
          "gender": "string",
          "firstName": "string",
          "lastName": "string"
        }
      ]
    }
  ],
  "holder": {
    "firstName": "string",
    "lastName": "string",
    "email": "string",
    "phone": "string"
  },
  "specialRequests": "string"
}'
TS=$(date +%s)
NONCE=$(openssl rand -hex 16)
BODY_HASH=$(printf '%s' "$BODY" | openssl dgst -sha256 | sed 's/^.* //')
CANON=$(printf 'POST\n/v1/hotels/bookings\n%s\n%s\n%s' "$TS" "$NONCE" "$BODY_HASH")
SIG=$(printf '%s' "$CANON" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')

curl -X POST "https://api.dubaitrip.com/v1/hotels/bookings" \
  -H "X-API-Key: $KEY_ID" \
  -H "X-Timestamp: $TS" \
  -H "X-Nonce: $NONCE" \
  -H "X-Signature: $SIG" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "$BODY"