Home Features Pricing Contact Login

REST API

Update reservation

POST
https://camping.care/api/v1/reservations/id

Autorisation: API Key

Once you've created a reservation you are able to update the reservation. You can use this function to add options, contact data etc. The only thing you need is the reservation id

If the reservation is complete you can update the status and make it final.

Parameters

contact_id
Integer
The id of a contact
options
String
The options that are selected by the guest.
It should be in this format:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[ 
	{ "id": OPTION_ID, "count": OPTION_COUNT }, 
	{ "id": OPTION_ID, "count": OPTION_COUNT } 
]


You can get the available options with this function get options
finish
Bool
Finished the reservation? Make it final by setting this variable to true. The reservation will get the status 'pending', this means the reservation is done. Once the reservation has the status 'pending' you're not able to update it anymore. If finish is set to true, the contact_id is required. Default this variable is set to false

Response

201
application/json; charset=utf-8
id
Integer
The id of the reservation
reservation_id
Integer
The reservation id of the administration. This is the ID that is communicated to the guest.
contact_id
Integer
The id of the contact for this reservation.
place_id
Integer
The place id of the accommodation for this reservation
status
String
The status of the reservation in a string: with status 'draft', 'pending', 'option', 'confirmed', 'checkedin', 'checkedout' or 'deleted'
payment
String
The payment of the reservation in a string: with payment status 'unpaid', 'partly_paid' or 'paid'
arrival
Date
Arrival date of the reservation
departure
Date
Departure date of the reservation
departure
Date
Departure date of the reservation
create_date
Date
Creation date of the reservation
total
Date
Total price of the reservation
rows
ARRAY
Reservation rows
accommodation_id
Integer
The id of the accommodation for this reservation

Example


/*
* Example create reservation - How to create a reservation calculated price for a 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 price id. It can be found by using the function get_reservations
    * http://camping.care/developer/reservations/get_reservations
    */

    $id = 657 ; // this is the id of the reservation, not the reservation_id (Required)

    /*
    * Parameters:
    *   contact_id:     The id of a contact (required)
    *   options:        he options that are selected by the guest. You can get the available options with this function get options
    *   finish:         Make it final by setting this variable to true. The reservation will get the status 'pending', this means the reservation is done.
    */

    $data = array();

    // the contact_id id, this can be found with the function get_contacts (Required)
    // if you don't have a contact id you can create a contact with Create contact
    $data["contact_id"] = 192 ;

    // if options are selected, sent them to the server
    // More information about options can be found in the 'Get options' function
    $data["options"] = array(
        array(
            "id" => 51, // the id of the option (Babyseat for example)
            "count" => 1 // The number of 'Babyseats'
        ),

        array(
            "id" => 53, // the id of the option (Insurance for example)
            "count" => 2 // The number of 'Insurances'
        )
    );

    // finished the reservation? Make it final by setting this variable to true
    // the reservation will get the status 'pending', this means the reservation is done
    // Once the reservation has the status 'pending' you're not able to update it anymore.

    // if finish is set to true, the contact_id is required

    $data["finish"] = false ; 


    /*
    * All data is returned in a reservation object
    * The structure can be found here: https://camping.care/developer/reservations/get_reservation.
    */

    $reservation = $campingcare->update_reservation($id, $data);


  /*
    * In this example we print the data in json format on the page
    */
    echo "Reservation";
    echo "
";
    echo json_encode($reservation, 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;
using Newtonsoft.Json;

namespace campingcare_csharp_sdk_tests
{
    public static class reservation_update
    {

        /*
        * Example update reservation - How to create a reservation from the Camping.care API
        * https://camping.care/developer/reservations/create_reservation
        */
        public static async void update_reservation()
        {
            try
            {
                Console.WriteLine("*************************************");
                Console.WriteLine("***       UPDATE RESERVATION      ***");
                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");

                int id = 1; // this is the id of the reservation, not the reservation_id (Required)

                /*
                * Parameters:
                *   contact_id:     The id of a contact (required)
                *   options:        he options that are selected by the guest. You can get the available options with this function get options
                *   finish:         Make it final by setting this variable to true. The reservation will get the status 'pending', this means the reservation is done.
                */


                var send_data = new List>();
                send_data.Add(new KeyValuePair("contact_id", "192"));

                // Create a age table array and genreate age table JSON data
                var options = new List();

                campingcare.option_struct option0 = new option_struct();
                option0.id = 29;
                option0.count = 3;

                campingcare.option_struct option1 = new option_struct();
                option1.id = 30;
                option1.count = 2;

                options.Add(option0);
                options.Add(option1);

                string option_json_string = JsonConvert.SerializeObject(options);

                send_data.Add(new KeyValuePair("options", option_json_string));

                send_data.Add(new KeyValuePair("finish", "0"));


                /*
                * All data is returned in a reservation object
                * The structure can be found here: https://camping.care/developer/reservations/get_reservation.
                */

                var data = await camping_care.update_reservation(id, send_data);


                /*
                * In this example we print the data in json format in the console
                */

                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

{
    "id": "457",
    "reservation_id": "205",
    "contact_id": "154",
    "accommodation_id": "33",
    "place_id": "0",
    "status": "draft",
    "payment": "unpaid",
    "arrival": "2018-04-10",
    "departure": "2018-04-12",
    "create_date": "2017-11-18 20:59:53",
    "total": "28",
    "persons": "2",
    "discount_card": "0",
    "age_table_input": "[{\"id\":1,\"count\":2}]",
    "rows": [
        {
            "id": "4248",
            "row_id": "457",
            "type": "product_id",
            "type_id": "33",
            "description": "",
            "amount": "1",
            "total": "0",
            "data": null
        },
        {
            "id": "4249",
            "row_id": "457",
            "type": "product_price",
            "type_id": "36",
            "description": "Pre Season",
            "amount": "2",
            "total": "10",
            "data": "{\"start_date\":\"2018-04-10\",\"end_date\":\"2018-04-12\"}"
        },
        {
            "id": "4250",
            "row_id": "457",
            "type": "product_tax",
            "type_id": "34",
            "description": "Tourist tax",
            "amount": "2",
            "total": "4",
            "data": null
        }
    ]
}



Response Error

Returns an array with error information

230
application/json; charset=utf-8
code
Integer
The error code listed in a list below
message
String
The error message listed in a list below

Error Codes

3000
No valid API key
3010
No new reservation made
3011
No admin ID found
3012
Not a valid arrival date
3013
Not a valid departure date
3014
No valid reservation status
3015
The contact id is not in your administration
3016
No contact found with this id
3017
A reservation needs at least a last name
0%
()

Cancel upload