POST
https://camping.care/api/v1/reservations/calculate_price
Authentication:
Get a price calculation of a specific accomodation and date. You need to have an accommodation id to get started. The specific id from a accommodation can be get by the function Get accommodations.
Parameters
Integer
Required - The id of the accommodation
Date
Required - Arrival date for the calculation (YYYY-MM-DD)
Date
Required - Departure date for the calculation (YYYY-MM-DD)
String
Required - The number of persons for the calculation. If the administration is using age tables the number of persons should be a calculation of all persons in the age tables.
String
Required (if age tables are available) - The age table input of persons for the reservation. The age table input is a JSON string. It should be in this format:
If the administration does not use any age tables this parameter is not required. Read more about age tables
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
[
{ "id": AGE_TABLE_ID, "count": AGE_TABLE_AMOUNT },
{ "id": AGE_TABLE_ID, "count": AGE_TABLE_AMOUNT }
]
If the administration does not use any age tables this parameter is not required. Read more about age tables
Integer
Optional: The id of an discount card. This id can be found with this function. get cards.
String
Optional: The promocode of a discount to check the promocode discount.
Response
201
application/json; charset=utf-8
Integer
The accommodation id of the calculation
Date
The arrival date for the calculated price
Date
TThe departure date for the calculated price
Double
The total price for the calculation
Double
The price for accommodation only
Double
The price for extra guests only
Array
A array with the specific found prices. A calculation can combine different prices. Each price in the array contains information:
- id: The price id for the given price
- name: The price it's name
- start_date: start date for the use of this price in this calculation
- end_date: The end date for the use of this price in this calculation
- type: The type for using in the reservation rows to determine if it is a accommodation, guest, tax or option price.
- price: The price for this accommodation.
- count: The number of times the price is used in this calculation
- total_price: The same as parameter "accommodation_price"
- name: The price it's name
- start_date: start date for the use of this price in this calculation
- end_date: The end date for the use of this price in this calculation
- type: The type for using in the reservation rows to determine if it is a accommodation, guest, tax or option price.
- price: The price for this accommodation.
- count: The number of times the price is used in this calculation
- total_price: The same as parameter "accommodation_price"
Array
A array with the specific found guest prices. A calculation can combine different guest prices. Each price in the array contains information:
- id: The accommodation guest id for the given guest price
- name: The guest it's name
- type: The type for using in the reservation rows to determine if it is a accommodation, guest, tax or option price.
- price: The price for this accommodation.
- guest_type: Whether the guest price is of the type price or percentage
- guest_type_pro: Whether the guest price is pro night or week
- guest_type_amount: The price or percentage for the given "guest_type_pro"
- price_id: The price id this guest price is based on
- count: The number of times the price is used in this calculation
- total_price: The same as parameter "guest_price"
- name: The guest it's name
- type: The type for using in the reservation rows to determine if it is a accommodation, guest, tax or option price.
- price: The price for this accommodation.
- guest_type: Whether the guest price is of the type price or percentage
- guest_type_pro: Whether the guest price is pro night or week
- guest_type_amount: The price or percentage for the given "guest_type_pro"
- price_id: The price id this guest price is based on
- count: The number of times the price is used in this calculation
- total_price: The same as parameter "guest_price"
Example
/*
* Example calculate_price - How to get calculated price for a
* specific accommodation between 2 dates from the Camping.care API
* https://camping.care/developer/reservations/calculate_price
*/
try {
/*
* Initialize the Camping.care API SDK with your API key.
*
* See: https://camping.care/settings/api
*/
require_once dirname(__FILE__) . '/../../src/campingcare/Autoloader.php';
$campingcare = new campingcare_api ;
$campingcare->set_api_key('YOUR API KEY');
/*
* Set your accommodation id. It can be found by using the function get_accommodations
* https://camping.care/developer/reservations/calculate_price
* Parameters:
* accommodation_id Accommodation ID (required)
* arrival Arrival date for the availability (required)
* departure Departure date for the availability (required)
* persons Number of persons. (required if no age tables)
* age_tables Array of age table data check https://camping.care/developer/reservations/calculate_price (required if age tables are used in a park)
* card_id Discount card id for calculating the price
* promocode Promocode for calculating the price
*
*/
$data = array();
$data['accommodation_id'] = 37 ; // Accommodation ID (required)
$data['arrival'] = "2018-06-10" ; //date YYYY-MM-DD
$data['departure'] = "2018-06-17" ; //date YYYY-MM-DD
$data["persons"] = "2"; // Number of persons for calcualtion
$data["promocode"] = "facebook"; // Promocode for the calculation
/*
* All data is returned as calculate price opject
* The structure can be found here: https://camping.care/developer/reservations/calculate_price.
*/
$calculated_price = $campingcare->calculate_price($data);
/*
* In this example we print the data in json format on the page
*/
echo "GET calculated price for a accommodation between dates";
echo "";
echo json_encode($calculated_price, JSON_PRETTY_PRINT);
echo "
";
} catch (Exception $e) {
echo "API call failed: " . htmlspecialchars($e->getMessage());
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using campingcare;
using Newtonsoft.Json.Linq;
namespace campingcare_csharp_sdk_tests
{
public static class calculate_price
{
/*
* Example get calculate_price - How to get calculated price for a specific accommodation between 2 dates from the Camping.care API
* https://camping.care/developer/accommodations/get_calculate_price
*/
public static async void get_calculate_price()
{
try
{
Console.WriteLine("*************************************");
Console.WriteLine("*** GET CALCULATE PRICE ***");
Console.WriteLine("*************************************");
/*
* Initialize the Camping.care API SDK with your API key.
*
* See: https://camping.care/settings/api
*/
campingcare_api camping_care = new campingcare_api();
camping_care.set_api_key("YOUR API KEY");
/*
* Parameters:
* accommodation_id Accommodation id which can be found in the function get_accommodations https://camping.care/developer/accommodations/get_accommodations
* arrival Arrival date for the availability (required)
* departure Departure date for the availability (required)
* persons Number of persons. (required if no age tables)
* age_tables Array of age table data check https://camping.care/developer/accommodations/get_calculate_price (required if age tables are used in a park)
* card_id Discount card id for calculating the price
* promocode Promocode for calculating the price
*
*/
var send_data = new List>();
send_data.Add(new KeyValuePair("accommodation_id", "36"));
send_data.Add(new KeyValuePair("arrival", "2018-03-01"));
send_data.Add(new KeyValuePair("departure", "2018-03-10"));
send_data.Add(new KeyValuePair("persons", "2"));
send_data.Add(new KeyValuePair("promocode", "facebook"));
/*
* All data is returned as calculate price opject
* The structure can be found here: https://camping.care/developer/accommodations/get_calculate_price.
*/
var data = await camping_care.calculate_price(send_data);
/*
* In this example we print the oprions in json format on the page
*/
JObject json = JObject.Parse(data.ToString());
foreach (var pair in json)
{
Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
}
}
catch (Exception ex)
{
LogData(ex.Message);
}
}
private static void LogData(string Message)
{
Console.WriteLine("Error: " + Message);
}
}
}
Response example
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"accommodation_id": 33,
"arrival": "2018-04-10",
"departure": "2018-04-16",
"total_price": 72,
"accommodation_price": 60,
"guest_price": 12,
"accommodation_price_rows": [
{
"id": 36,
"name": "Pre Season",
"start_date": "2018-04-10",
"end_date": "2018-04-16",
"type": "accommodation",
"price": 10,
"count": 6,
"total_price": 60
}
],
"guest_price_rows": [
{
"id": "39",
"name": "Extra Person",
"amount": 1,
"price": 12,
"guest_type": "price",
"guest_type_pro": "night",
"guest_type_amount": "2",
"price_id": 36,
"count": 1
}
],
,
"discount_price_rows": [
{
"id": "8",
"name": "Promocode",
"type": "procent",
"type_amount": "10",
"period": "price",
"apply_on": "total",
"price": 2,
"price_id": 622
}
]
}
Response Error
Returns an array with error information
230
application/json; charset=utf-8
Integer
The error code listed in a list below
String
The error message listed in a list below
Error Codes
1000
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1000
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024