
DEVELOPER AREA
Authentication
Authentication is used to identify the caller and secure communication for all requests both ways, to our servers and to partner servers. In order to be granted access, you will need to include in the auth header a JWT as Bearer token, generated as follows:
the header must be
{ "alg": "HS512", "typ": "JWT", "expiresIn": "1m" }
the payload must be
{ "sub": string, "exp": timestamp }
sub is the partner unique id will be a visibile on admina area (in the form of a uuid)
exp is a unix timestamp pointing to a minute from now (when the request is sent)
the signature must be
HMACSHA512( base64UrlEncode(header) + "." + base64UrlEncode(payload), secret-key )
secret-key will be a visibile on admina area
the algorithm is HS512;
The sub and secret-key are unique and serve to identify your company, therefore must be used for every property
- sub and secret key will remain the same in the production environment
- token expiration is mandatory and can be max 1 minute.
Example php code to get token
Library available on:
https://github.com/firebase/php-jwt
<?php
include ‘class/php-jwt-class/src/JWToken.php’;
$issuedAt = time();
$expirationTime = $issuedAt + 59;
$payload = array(
“sub” => strval($smartpricing_sub),
“exp” => $expirationTime
);
$token = JWToken::encode($payload, $okrate_secret_key,‘HS512’);
Send reservations to okrate
Endpoint
http://console.okrate.it/api/v1/partners/accommodations/{hotelid}/reservations
Where {hotelid} is the hotel id of hotel
Example php code
$json=‘{
“id”: “22807”,
“channel”: “Dirette”,
“rateDescription”: “RO”,
“checkinAt”: “2024-09-23”,
“checkoutAt”: “2024-09-29”,
“status”: “confirmed”,
“currency”: “EUR”,
“boardType”: “RO”,
“amountReservation”: 2060,
“bookedAt”: “2023-10-19T21:40:32Z”,
“rooms”: [
{
“id”: “Camera Doppia”,
“name”: “Camera Doppia”,
“numUnits”: 1,
“adults”: 2,
“children”: 0,
“amountRoom”: 1030,
“nights”: [
{
“price”: 172,
“date”: “2024-09-23”
},
{
“price”: 172,
“date”: “2024-09-24”
},
{
“price”: 172,
“date”: “2024-09-25”
},
{
“price”: 172,
“date”: “2024-09-26”
},
{
“price”: 172,
“date”: “2024-09-27”
},
{
“price”: 172,
“date”: “2024-09-28”
}
]
},
{
“id”: “Camera Doppia”,
“name”: “Camera Doppia”,
“numUnits”: 1,
“adults”: 2,
“children”: 0,
“amountRoom”: 1030,
“nights”: [
{
“price”: 172,
“date”: “2024-09-23”
},
{
“price”: 172,
“date”: “2024-09-24”
},
{
“price”: 172,
“date”: “2024-09-25”
},
{
“price”: 172,
“date”: “2024-09-26”
},
{
“price”: 172,
“date”: “2024-09-27”
},
{
“price”: 172,
“date”: “2024-09-28”
}
]
}
]
}
]‘;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => ‘http://console.okrate.it/api/v1/partners/accommodations/6/reservations’,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => ”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => ‘POST’,
CURLOPT_POSTFIELDS =>$json,
CURLOPT_HTTPHEADER => array(
‘Content-Type: application/json’,
‘Authorization: Bearer ‘.$token
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Json schema
id* | string id of the reservation on the partner system |
checkinAt* | string($date) Checkin date in the YYYY-MM-DD format |
checkoutAt* | string($date) Checkout date in the YYYY-MM-DD format |
status* | string on our systems the status of a reservations can be only confirmed or canceled; if your systems use a different categorization, please parse thoose statuses to one recognized by us Enum: |
partnerStatus | string The name of the status actually used by your system |
amountReservation* | number Total reservation amount |
bookedAt* | string($date-time) Booking datetime ISO UTC or ISO with timezone |
canceledAt | string($date-time) Cancellation datetime ISO UTC or ISO with timezone |
channel | string Reservation channel name (ie booking.com) |
rateDescription* | string description of the rate relative to the reservation |
segment | string Segment |
boardType | string Board type |
modifiedAt | string($date-time) Reservation modification date |
currency | string Currency |
rooms* |
| |||||||||
adults* | integer minimum: 1 example: 2 | |||||||||
children* | integer minimum: 0 example: 0 | |||||||||
amountRoom | number minimum: 0 example: 100 | |||||||||
nights* |
|
Reset (delete) reservations
Endpoint
http://console.okrate.it/api/v1/partners/accommodations/{hotelid}/reservations_reset
Where {hotelid} is the hotel id of the hotel
Example php code
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => ‘http://console.okrate.it/api/v1/partners/accommodations/6/reservations_reset’,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => ”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => ‘PATCH’,
CURLOPT_POSTFIELDS =>”,
CURLOPT_HTTPHEADER => array(
‘Content-Type: application/json’,
‘Authorization: Bearer ‘.$token
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;