Créer un plan tarifaire
const url = 'https://example.com/v1/rate-plans';const options = { method: 'POST', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"establishmentId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","code":"BAR","name":"example","baseRateRule":{"pricingUnit":"per_room","currency":"EUR","flatNightlyCents":12000,"derivedFromRatePlanId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","derivedBasisPoints":8000,"occupancy":{"baseUnitNightlyCents":1,"adultNightlyCents":1,"childTiers":[{"ageFrom":1,"ageTo":1,"nightlyCents":1}],"infantFreeUpToAge":1,"petNightlyCents":1,"extraVehicleNightlyCents":1,"includedVehicles":1,"electricityMode":"included","electricityFlatNightlyCents":1}}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/rate-plans \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "establishmentId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "code": "BAR", "name": "example", "baseRateRule": { "pricingUnit": "per_room", "currency": "EUR", "flatNightlyCents": 12000, "derivedFromRatePlanId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "derivedBasisPoints": 8000, "occupancy": { "baseUnitNightlyCents": 1, "adultNightlyCents": 1, "childTiers": [ { "ageFrom": 1, "ageTo": 1, "nightlyCents": 1 } ], "infantFreeUpToAge": 1, "petNightlyCents": 1, "extraVehicleNightlyCents": 1, "includedVehicles": 1, "electricityMode": "included", "electricityFlatNightlyCents": 1 } } }'Authorizations
Section intitulée « Authorizations »Request Body required
Section intitulée « Request Body required »Données du plan tarifaire. baseRateRule est une union discriminée sur le champ pricingUnit : - per_room : { pricingUnit, currency, flatNightlyCents } - per_person: { pricingUnit, currency, occupancy: { baseUnitNightlyCents, adultNightlyCents, … } } - derived : { pricingUnit, currency, derivedFromRatePlanId, derivedBasisPoints } Tous les montants sont en centimes entiers (jamais de float money).
object
Example
BARUnion discriminée sur pricingUnit.
object
Discriminant de la règle tarifaire.
(per_room uniquement) Tarif nuit forfaitaire en centimes entiers.
Example
12000(derived uniquement) ID du plan tarifaire source.
(derived uniquement) Pourcentage en points de base (ex: 8000 = 80 %).
Example
8000(per_person uniquement) Grille de tarification à l’occupant.
object
object
Responses
Section intitulée « Responses »Plan créé
object
object
Example generated
{ "data": { "ratePlanId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }}Corps invalide ou règle tarifaire invalide
object
Code machine de l’erreur
Message lisible
Origine domaine de l’erreur (optionnel)
object
Identifiant de corrélation pour le support
Example
{ "code": "RESERVATION_NOT_FOUND", "message": "Réservation introuvable", "status": 404}Non authentifié
object
Code machine de l’erreur
Message lisible
Origine domaine de l’erreur (optionnel)
object
Identifiant de corrélation pour le support
Example
{ "code": "RESERVATION_NOT_FOUND", "message": "Réservation introuvable", "status": 404}Permission refusée
object
Code machine de l’erreur
Message lisible
Origine domaine de l’erreur (optionnel)
object
Identifiant de corrélation pour le support
Example
{ "code": "RESERVATION_NOT_FOUND", "message": "Réservation introuvable", "status": 404}