Availability, Rates Retrieval / Set And Booking Notification API`s


  • 1. Property Information Retrieval API

    2. Retrieval Inventory API

    3. Retrieval Room Rates API

    4. Set Inventory API

    5. Set Room Rates API

    6. Booking Notification API

    7. Include Class


    Property Information Retrieval API

    The Property API is used to onboard property name, address, contact details, and room type details. The quickest way to get started is to review the Supported Features and review the API Definition. The requests can be posted directly to the interface at http://www.24beds.com/apieqc/pd to get Property details. Make sure to include below xml in your http header.

    XML Request
    
        <?xml version="1.0" encoding="UTF-8"?>
        <PropertyDetailsRQ>
            <Authentication username="{User Name}" password="{Password}"/>
            <Hotel id={Hotelid}/>
        </PropertyDetailsRQ>
    
                                                
    Post Request
       URL : http://www.24beds.com/apieqc/pd
    
        'datas' => {
            "PropertyDetailsRQ" : [
                "Authentication" : [ 
                    "attr" : [ 
                        "username" : "user@mail.com",
                        "password" : "PASSWORD"
                    ],
                "Hotel" : [ 
                    "attr" : [ 
                        "id" : "Hotel id"
                    ]
                ]
            ]
        }
    
                                                
    Parameters
    Name Type Description
    datasarray
    Array of JSON serializable hashes representing requested hotels.
    key description type
    username 24beds API login name string
    password 24beds API login password string
    id 24beds hotel id integer

    Example: datas => '{"PropertyDetailsRQ":{"Authentication":{"attr":{"username":"user@domainname.com","password":"12345678"}},"Hotel":{"attr":{"id":"555"}}}}'


    Object for Class beds24 (PHP)
    
        $obj_24beds = new Beds24({Hotel id}, '{User Email Id}', '{Password}');
    
                                                
    Call Function
    
        $xml = $obj_24beds->getPropertyDetails();
    
                                                
    XML Response
    
    <?xml version="1.0" encoding="UTF-8"?>
    <PropertyDetailsRS>
        <PropertyNameContact>
    	<propertyname>{Property Name}</propertyname>
    	<propertyadd1>{Property Address 1}</propertyadd1>
    	<propertyadd2>{Property Address 2}</propertyadd2>
    	<propertycountry>{Country}</propertycountry>
    	<propertystate>{State}</propertystate>
    	<propertyarea>{Area}</propertyarea>
    	<propertycity>{City}</propertycity>
    	<propertypin>{Pincode}</propertypin>
    	<propertyphone1>{Phone no 1}</propertyphone1>
    	<propertyphone2>{Phone no 2}</propertyphone2>
    	<propertyfax>{Fax}</propertyfax>
    	<propertymobile>{Mobile No}</propertymobile>
    	<propertyemail>{Email Id}</propertyemail>
    	<propertyweb>{Site Id}</propertyweb>
    	<propertyowner>{Owner Name}</propertyowner>
        </PropertyNameContact>
        <PropertyRoomtypes>
            <Roomtype RoomtypeId="{Room Type Id 1}">{Room Type Name 1}</Roomtype>
            <Roomtype RoomtypeId="{Room Type Id 2}">{Room Type Name 2}</Roomtype>
        </PropertyRoomtypes>
    </PropertyDetailsRS>
            
                                                            

    Retrieval Inventory API        Top

    The Room availability API was designed for any partner that needs to connect 24beds to retrieve the current Hotel configuration, as well as the current availability loaded in the system. The requests can be posted directly to the interface at http://www.24beds.com/apieqc/in. Make sure to include below xml in your http header.

    XML Request
    
        <?xml version="1.0" encoding="UTF-8"?>
        <ProductAvailRetrievalRQ>
            <Authentication username="{User Name}" password="{Password}"/>
            <Hotel id={Hotelid}/>
            <ParamSet>
                <ProductRetrieval RoomtypeId="{Room Type Id}" from="{From Date}" to="{To Date}"/>
            </ParamSet>
        </ProductAvailRetrievalRQ>
    
                                                                
    Post Request
       URL : http://www.24beds.com/apieqc/in
    
        'datas' => {
            "ProductRateRetrievalRQ" : [
                "Authentication" : [ 
                    "attr" : [ 
                        "username" : "user@mail.com",
                        "password" : "PASSWORD"
                    ],
                "Hotel" : [ 
                    "attr" : [ 
                        "id" : "Hotel id"
                    ]
                ],
                "ParamSet" : [
                    "ProductRetrieval" : [
                        "attr":  [
                            "RoomtypeId" : "Room Type id",
                            "from" : "From Date",
                            "to" : "To Date"
                        ]
                    ]
                ]
            ]
        }
    
                                                                
    Parameters
    Name Type Description
    datasarray
    Array of JSON serializable hashes representing requested hotels.
    key description type
    username 24beds API login name string
    password 24beds API login password string
    id 24beds hotel id integer
    RoomtypeId 24beds room type id integer
    from Search Starting date date
    to Search End date date

    Example: datas => '{"ProductRateRetrievalRQ":{"Authentication":{"attr":{"username":"user@domainname.com","password":"12345678"}},"Hotel":{"attr":{"id":"555"}},"ParamSet":{"ProductRetrieval":{"attr":{"RoomtypeId":"1234","from":"2017-07-21","to":"2017-08-05"}}}}}'


    Call Function
    
        $xml = $obj_24beds->getInventoryList({Room Type Id}, '{From Date}', '{To Date}');
    
                                                                
    XML Response
    
    <?xml version="1.0" encoding="UTF-8"?>
    <ProductAvailRetrievalRS>
        <Inventory RoomtypeId="{Room Type Id}">
            <DateRange from="{From Date 1}" to="To Date 1">{No of Rooms 1}</DateRange>
            <DateRange from="{From Date 2}" to="To Date 2">{No of Rooms 2}</DateRange>
        </Inventory>
    </ProductAvailRetrievalRS>
    
                                                                

    Retrieval Room Rates API        Top

    The Room rate API was designed for any partner that needs to connect 24beds to retrieve the current Hotel configuration, as well as the current rates loaded in the system. The requests can be posted directly to the interface at http://www.24beds.com/apieqc/gt. Make sure to include below xml in your http header.

    XML Request
    
        <?xml version="1.0" encoding="UTF-8"?>
        <ProductRateRetrievalRQ>
            <Authentication username="{User Name}" password="{Password}"/>
            <Hotel id={Hotelid}/>
            <ParamSet>
                <ProductRetrieval RoomtypeId="{Room Type Id}" from="{From Date}" to="{To Date}"/>
            </ParamSet>
        </ProductRateRetrievalRQ>
    
                                                                
    Post Request
       URL : http://www.24beds.com/apieqc/gt
    
        'datas' => {
            "ProductAvailRetrievalRQ" : [
                "Authentication" : [ 
                    "attr" : [ 
                        "username" : "user@mail.com",
                        "password" : "PASSWORD"
                    ],
                "Hotel" : [ 
                    "attr" : [ 
                        "id" : "Hotel id"
                    ]
                ],
                "ParamSet" : [
                    "ProductRetrieval" : [
                        "attr":  [
                            "RoomtypeId" : "Room Type id",
                            "from" : "From Date",
                            "to" : "To Date"
                        ]
                    ]
                ]
            ]
        }
    
                                                                
    Parameters
    Name Type Description
    datasarray
    Array of JSON serializable hashes representing requested hotels.
    key description type
    username 24beds API login name string
    password 24beds API login password string
    id 24beds hotel id integer
    RoomtypeId 24beds room type id integer
    from Search Starting date date
    to Search End date date

    Example: datas => '{"ProductAvailRetrievalRQ":{"Authentication":{"attr":{"username":"user@domainname.com","password":"12345678"}},"Hotel":{"attr":{"id":"555"}},"ParamSet":{"ProductRetrieval":{"attr":{"RoomtypeId":"1234","from":"2017-07-21","to":"2017-08-05"}}}}}'


    Call Function
    
        $xml = $obj_24beds->getRoomTariff({Room Type Id}, '{From Date}', '{To Date}');
    
                                                                
    XML Response
    
    <?xml version="1.0" encoding="UTF-8"?>
    <ProductRateRetrievalRS>
        <RoomTariff RoomtypeId="{Room Type Id}">
            <DateRange from="{From Date 1}" to="To Date 1">
                <Rates nop="{No of Persons 1}" rate="{Rate 1}" grate="{Guest Rate 1}" />
                <Rates nop="{No of Persons 2}" rate="{Rate 2}" grate="{Guest Rate 2}" />
            </DateRange>
            <DateRange from="{From Date 2}" to="To Date 2">
                <Rates nop="{No of Persons 1}" rate="{Rate 1}" grate="{Guest Rate 1}" />
                <Rates nop="{No of Persons 2}" rate="{Rate 2}" grate="{Guest Rate 2}" />
            </DateRange>
        </RoomTariff>
    </ProductAvailRetrievalRS>
    
                                                                

    Set Inventory API        Top

    The availability request allows 24beds partners to send updates on availability. For partners wanting to experiment with the API, the requests can be posted directly to the interface at http://www.24beds.com/apieqc/si. Make sure to include below xml in your http header.

    XML Request
    
        <?xml version="1.0" encoding="UTF-8"?>
        <ProductSetInventoryRQ>
            <Authentication username="{User Name}" password="{Password}"/>
            <Hotel id={Hotelid}/>
            <ParamSet>
                <ProductSetInventory RoomtypeId="{Roomtype Id 1}" from="{From Date 1}" to="{To Date 1}" inv="{NoofRooms Avl 1}"/>
                <ProductSetInventory RoomtypeId="{Roomtype Id 1}" from="{From Date 2}" to="{To Date 2}" inv="{NoofRooms Avl 2}"/>
                <ProductSetInventory RoomtypeId="{Roomtype Id 2}" from="{From Date 3}" to="{To Date 3}" inv="{NoofRooms Avl 3}"/>
                <ProductSetInventory RoomtypeId="{Roomtype Id 2}" from="{From Date 4}" to="{To Date 4}" inv="{NoofRooms Avl 4}"/>
            </ParamSet>
        </ProductSetInventoryRQ>
    
                                                                
    Post Request
       URL : http://www.24beds.com/apieqc/si
    
        'datas' => {
            "ProductSetInventoryRQ" : [
                "Authentication" : [ 
                    "attr" : [ 
                        "username" : "user@mail.com",
                        "password" : "PASSWORD"
                    ],
                "Hotel" : [ 
                    "attr" : [ 
                        "id" : "Hotel id"
                    ]
                ],
                "ParamSet" : [
                    "ProductSetInventory" : [
                        "0":  [
                            "attr":  [
                                "RoomtypeId" : "Room Type id",
                                "from" : "From Date",
                                "to" : "To Date",
                                "inv" : "No of Rooms Available"
                            ]
                        ]
                    ]
                ]
            ]
        }
    
                                                                
    Parameters
    Name Type Description
    datasarray
    Array of JSON serializable hashes representing requested hotels.
    key description type
    username 24beds API login name string
    password 24beds API login password string
    id 24beds hotel id integer
    RoomtypeId 24beds room type id integer
    from Starting date date
    to Ending date date
    inv No of Rooms Available date

    Example: datas => '{"ProductSetInventoryRQ":{"Authentication":{"attr":{"username":"user@domainname.com","password":"12345678"}},"Hotel":{"attr":{"id":"555"}},"ParamSet":{"ProductSetInventory":{0:{"attr":{"RoomtypeId":"1234","from":"2017-07-21","to":"2017-08-05","inv":"3"}}}}}}'


    Call Function
    
        $datas[0] = array ('RoomtypeId' => {Roomtype Id 1},'from_date' => "{From Date 1}",'to_date' => "{To Date 1}",'inv' => {NoofRooms Avl 1});
        $datas[1] = array ('RoomtypeId' => {Roomtype Id 1},'from_date' => "{From Date 2}",'to_date' => "{To Date 2}",'inv' => {NoofRooms Avl 2});
        $datas[2] = array ('RoomtypeId' => {Roomtype Id 2},'from_date' => "{From Date 3}",'to_date' => "{To Date 3}",'inv' => {NoofRooms Avl 3});
        $datas[3] = array ('RoomtypeId' => {Roomtype Id 2},'from_date' => "{From Date 4}",'to_date' => "{To Date 4}",'inv' => {NoofRooms Avl 4});
        $xml = $obj_24beds->setAvailability($data);
    
                                                                
    XML Response
    
    On Success
    <?xml version="1.0" encoding="UTF-8"?>
    <ProductSetInventoryRS>
        <Result>{Inventory Updated}</Result>
    </ProductSetInventoryRS>
    
    On Error <?xml version="1.0" encoding="UTF-8"?> <ProductSetInventoryRS> <Result>{Error Message}</Result> </ProductSetInventoryRS>

    Set Room Rates API        Top

    The rate request allows 24beds partners to send updates on rates. For partners wanting to experiment with the API, the requests can be posted directly to the interface at http://www.24beds.com/apieqc/sr. Make sure to include below xml in your http header.

    XML Request
    
        <?xml version="1.0" encoding="UTF-8"?>
        <ProductSetRateRQ>
            <Authentication username="{User Name}" password="{Password}"/>
            <Hotel id={Hotelid}/>
            <ParamSet>
                <ProductSetRate RoomtypeId="{Roomtype Id 1}" from="{From Date 1}" to="{To Date 1}" guests="{NoofGuest 1}" rate="{Rate 1}" guest_rate="{Guest Rate 1}"/>
                <ProductSetRate RoomtypeId="{Roomtype Id 1}" from="{From Date 2}" to="{To Date 2}" guests="{NoofGuest 2}" rate="{Rate 2}" guest_rate="{Guest Rate 2}"/>
                <ProductSetRate RoomtypeId="{Roomtype Id 2}" from="{From Date 3}" to="{To Date 3}" guests="{NoofGuest 1}" rate="{Rate 3}" guest_rate="{Guest Rate 3}"/>
                <ProductSetRate RoomtypeId="{Roomtype Id 2}" from="{From Date 4}" to="{To Date 4}" guests="{NoofGuest 2}" rate="{Rate 4}" guest_rate="{Guest Rate 4}"/>
            </ParamSet>
        </ProductSetRateRQ>
    
                                                                
    Post Request
       URL : http://www.24beds.com/apieqc/sr
    
        'datas' => {
            "ProductSetRoomRatesRQ" : [
                "Authentication" : [ 
                    "attr" : [ 
                        "username" : "user@mail.com",
                        "password" : "PASSWORD"
                    ],
                "Hotel" : [ 
                    "attr" : [ 
                        "id" : "Hotel id"
                    ]
                ],
                "ParamSet" : [
                    "ProductSetRate" : [
                        "0":  [
                            "attr":  [
                                "RoomtypeId" : "Room Type id",
                                "from" : "From Date",
                                "to" : "To Date",
                                "guests" : "No of Guests",
                                "rate" : "Daily Tariff Rate",
                                "guest_rate" : "Daily Guest Tariff"
                            ]
                        ]
                    ]
                ]
            ]
        }
    
                                                                
    Parameters
    Name Type Description
    datasarray
    Array of JSON serializable hashes representing requested hotels.
    key description type
    username 24beds API login name string
    password 24beds API login password string
    id 24beds hotel id integer
    RoomtypeId 24beds room type id integer
    from Starting date date
    to Ending date date
    guests Guests Allowed integer
    rate Tariff Rate decimal
    guest_rate Guest Tariff Rate decimal

    Example: datas => '{"ProductSetRoomRatesRQ":{"Authentication":{"attr":{"username":"user@domainname.com","password":"12345678"}},"Hotel":{"attr":{"id":"555"}},"ParamSet":{"ProductSetRate":{0:{"attr":{"RoomtypeId":"1234","from":"2017-07-21","to":"2017-08-05","guests":"2","rate":"600","guest_rate":"150"}}}}}}'


    Call Function
    
        $datas[0] = array ('RoomtypeId' => {Roomtype Id 1},'from_date' => "{From Date 1}",'to_date' => "{To Date 1}",'guests' => {NoofGuest 1},'rate' => {Rate 1},'guests' => {Guest Rate 1});
        $datas[1] = array ('RoomtypeId' => {Roomtype Id 1},'from_date' => "{From Date 2}",'to_date' => "{To Date 2}",'guests' => {NoofGuest 2},'rate' => {Rate 2},'guests' => {Guest Rate 2});
        $datas[2] = array ('RoomtypeId' => {Roomtype Id 2},'from_date' => "{From Date 3}",'to_date' => "{To Date 3}",'guests' => {NoofGuest 1},'rate' => {Rate 3},'guests' => {Guest Rate 3});
        $datas[3] = array ('RoomtypeId' => {Roomtype Id 2},'from_date' => "{From Date 4}",'to_date' => "{To Date 4}",'guests' => {NoofGuest 2},'rate' => {Rate 4},'guests' => {Guest Rate 4});
        $xml = $obj_24beds->setRate($data);
    
                                                                
    XML Response
    
    On Success
    <?xml version="1.0" encoding="UTF-8"?>
    <ProductSetRateRS>
        <Result>{Rates Updated}</Result>
    </ProductSetRateRS>
    
    On Error <?xml version="1.0" encoding="UTF-8"?> <ProductSetRateRS> <Result>{Error Message}</Result> </ProductSetRateRS>

    Booking Notification API        Top

    24beds provides a program interface for 24beds partners to retrieve bookings made on 24beds points of sale. 24beds partners can retrieve pending bookings (reservations) as frequently as they want. If an 24beds partner does not retrieve the booking information electronically, 24beds sends the information to the hotel by email. The Request can be attempted against the production endpoint of API at http://www.24beds.com/apieqc/gr. Make sure to include below xml in your http header.

    XML Request
    
        <?xml version="1.0" encoding="UTF-8"?>
        <BookingRetrievalRQ>
            <Authentication username="{User Name}" password="{Password}"/>
            <Hotel id={Hotelid}/>
            <ParamSet>
                <BookingRetrieval from="{From Date}" to="{To Date}"/>
            </ParamSet>
        </BookingRetrievalRQ>
    
                                                                
    Post Request
       URL : http://www.24beds.com/apieqc/gr
    
        'datas' => {
            "BookingRetrievalRQ" : [
                "Authentication" : [ 
                    "attr" : [ 
                        "username" : "user@mail.com",
                        "password" : "PASSWORD"
                    ],
                "Hotel" : [ 
                    "attr" : [ 
                        "id" : "Hotel id"
                    ]
                ],
                "ParamSet" : [
                    "BookingRetrieval" : [
                        "attr":  [
                            "from" : "From Date",
                            "to" : "To Date"
                        ]
                    ]
                ]
            ]
        }
    
                                                                
    Parameters
    Name Type Description
    datasarray
    Array of JSON serializable hashes representing requested hotels.
    key description type
    username 24beds API login name string
    password 24beds API login password string
    id 24beds hotel id integer
    from Starting date date
    to Ending date date

    Example: datas => '{"BookingRetrievalRQ":{"Authentication":{"attr":{"username":"user@domainname.com","password":"12345678"}},"Hotel":{"attr":{"id":"555"}},"ParamSet":{"BookingRetrieval":{"attr":{"from":"2017-07-21","to":"2017-08-05"}}}}}'


    Call Function
    
        $xml = $obj_24beds->getReservations('{From Date}', '{To Date}');
    
                                                                
    XML Response
    
    <?xml version="1.0" encoding="UTF-8"?>
    <BookingRetrievalRS>
        <Bookings>
            <Row sno={Row No}> 
                <Cusname>{Customer Name}</Cusname>
                <InDate>{CheckIn Date}</InDate>
                <OutDate>{CheckOut Date}</OutDate>
                <BookDate>{Booked Date}</BookDate>
                <NoofGuests>{No of Guests}</NoofGuests>
                <RoomType>{Room Type}</RoomType>
                <BookStatus>{Current Room Status}</BookStatus>
                <PaidStatus>{Payment Status}</PaidStatus>
                <ConfirmStatus>{Booking Confirm Status}</ConfirmStatus>
            </Row>
        </Bookings>
    </BookingRetrievalRS>
    
                                                                
    Include Class        Top
    abstract class BaseChannel {
    
        protected $debug = true;
        protected $testMode = true;
        protected $currency = 'INR';
    
        public function getCurrency() {
            return $this->currency;
        }
    
        public function setCurrency($currency) {
            $this->currency = $currency;
        }
    
        protected function getTestMode() {
            return $this->testMode ? 'test' : 'live';
        }
    
        public function setTestMode($test = true) {
            $this->testMode = (bool) $test;
        }
    
        public function processCurl($url, $data = "", $headers = []) {
            set_time_limit(600);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            if (!is_array($headers)) {
                $headers = [];
            }
            array_merge($headers, [
                'Accept: application/xml',
                'Connection: Keep-Alive',
                'Accept-Language: en-us',
                'Accept-Encoding: gzip, deflate',
                'Content-Type: application/xml',
                'Cache-Control: no-cache, no-store, must-revalidate',
                'Pragma: no-cache',
                'Expires: 0'
            ]);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5');
            curl_setopt($ch, CURLOPT_TIMEOUT, 180);
            $data = array('datas' => json_encode($data));
            if (!empty($data)) {
                if (is_array($data)) {
                    $strData = "";
                    foreach ($data as $k => $v) {
                        $strData .= $k . '=' . rawurlencode($v) . '&';
                    }
                    $data = substr($strData, 0, -1);
                }
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            }
            $result = curl_exec($ch);
            curl_close($ch);
            return $result;
        }
    
    }
    
    class Beds24 extends BaseChannel {
    
        protected $auth = ['username' => '', "password" => ''];
        protected $returnWarnings = 1;
        protected $hotelCode;
        protected $urls = [
            'getPropertyDetails' => [
                'test' => 'http://www.24beds.com/apieqc/pd',
                'live' => 'http://www.24beds.com/apieqc/pd'
            ],
            'getInventoryList' => [
                'test' => 'http://www.24beds.com/apieqc/in',
                'live' => 'http://www.24beds.com/apieqc/in'
            ],
            'setAvailability' => [
                'test' => 'http://www.24beds.com/apieqc/si',
                'live' => 'http://www.24beds.com/apieqc/si'
            ],
            'setRate' => [
                'test' => 'http://www.24beds.com/apieqc/sr',
                'live' => 'http://www.24beds.com/apieqc/sr'
            ],
            'getReservations' => [
                'test' => 'http://www.24beds.com/apieqc/gr',
                'live' => 'http://www.24beds.com/apieqc/gr'
            ],
            'setReservationConfirmation' => [
                'test' => 'http://www.24beds.com/apieqc/sc',
                'live' => 'http://www.24beds.com/apieqc/sc'
            ],
        ];
        protected $ns = [
            'PAR' => 'http://www.24beds.com/EQC/PAR',
            'AR' => 'http://www.24beds.com/EQC/AR',
            'BR' => 'http://www.24beds.com/EQC/BR',
            'BC' => 'http://www.24beds.com/EQC/BC'
        ];
    
        public function __construct($hotel_code, $username = '', $pass = '', $currency = 'INR') {
            $this->hotelCode = $hotel_code;
            $this->currency = $currency;
            if ($username != '') {
                $this->auth['username'] = $username;
            }
            if ($pass != '') {
                $this->auth['password'] = $pass;
            }
        }
    
        public function getInventoryList($roomtypeid, $from_date, $to_date) {
            $xml = '<ParamSet><ProductRetrieval RoomtypeId="' . $roomtypeid . '" from="' . $from_date . '" to="' . $to_date . '"/></ParamSet>';
            $xml = $this->prepareXml('ProductAvailRetrieval', $this->ns['PAR'], $xml, 1);
            $result = $this->processCurl($this->getUrl(__FUNCTION__), $xml);
            return $result;
        }
    
        public function setRate($datas) {
            $xml = '<ParamSet>';
            foreach ($datas as $data) {
                $xml .= '<ProductSetRate RoomtypeId="' . $data['room type id'] . '" from="' . $data['from_date'] . '" to="' . $data['to_date'] . '" guests="' . $data['guests'] . '" rate="' . $data['rate'] . '" guest_rate="' . $data['guest_rate'] . '"/>';
            }
            $xml .= '</ParamSet>';
            if ($xml != "") {
                $xml = $this->prepareXml('ProductSetRate', $this->ns['AR'], $xml, 1);
                $result = $this->processCurl($this->getUrl(__FUNCTION__), $xml);
            }
            return $result;
        }
    
        public function setAvailability($datas) {
            $xml = '<ParamSet>';
            foreach ($datas as $data) {
                $xml .= '<ProductSetInventory RoomtypeId="' . $data['room type id'] . '" from="' . $data['from_date'] . '" to="' . $data['to_date'] . '" inv="' . $data['inv'] . '"/>';
            }
            $xml .= '</ParamSet>';
            $xml = $this->prepareXml('ProductSetInventory', $this->ns['AR'], $xml);
            $result = $this->processCurl($this->getUrl(__FUNCTION__), $xml);
            return $result;
        }
    
        protected function prepareXml($callName, $ns = '', $xml = "", $hotelid_flag = 1) {
            return '<?xml version = "1.0" encoding = "UTF-8" ?>'
                    . '<' . $callName . 'RQ>'
                    . '<Authentication username="' . $this->getAuth('username') . '" password="' . $this->getAuth('password') . '"/>'
                    . (($hotelid_flag == 1) ? '<Hotel id="' . $this->hotelCode . '"/>' : '')
                    . $xml
                    . '</' . $callName . 'RQ>';
        }
    
        public function getPropertyDetails() {
            $xml = "";
            $xml = $this->prepareXml('PropertyDetails', $this->ns['PAR'], $xml, 1);
            $result = $this->processCurl($this->getUrl(__FUNCTION__), $xml);
            return $result;
        }
    
        protected function processCurl($url, $data = "", $headers = []) {
            $success = false;
            $errors = [];
            $datarr = $this->xml2array($data, $get_attributes = 3, $priority = 'tag');
            $result = parent::processCurl($url, $datarr, $headers);
            return $result;
        }
    
        protected function xml2array($contents, $get_attributes = 1, $priority = 'tag') {
            if (!$contents) {
                return array();
            }
            if (!function_exists('xml_parser_create')) {
                return array();
            }
            $parser = xml_parser_create('');
            xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
            xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
            xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
            xml_parse_into_struct($parser, trim($contents), $xml_values);
            xml_parser_free($parser);
            if (!$xml_values) {
                return;
            }
            $xml_array = array();
            $parents = array();
            $opened_tags = array();
            $arr = array();
            $current = & $xml_array;
            $repeated_tag_index = array();
            foreach ($xml_values as $data) {
                unset($attributes, $value);
                extract($data);
                $result = array();
                $attributes_data = array();
                if (isset($value)) {
                    if ($priority == 'tag') {
                        $result = $value;
                    } else {
                        $result['value'] = $value;
                    }
                }
                if (isset($attributes) && $get_attributes) {
                    foreach ($attributes as $attr => $val) {
                        if ($attr == 'ResStatus') {
                            $current[$attr][] = $val;
                        }
                        if ($priority == 'tag') {
                            $attributes_data[$attr] = $val;
                        } else {
                            $result['attr'][$attr] = $val;
                        }
                    }
                }
                if ($type == "open") {
                    $parent[$level - 1] = & $current;
                    if (!is_array($current) or ( !in_array($tag, array_keys($current)))) {
                        if ($attributes_data) {
                            $current[$tag][''] = $attributes_data;
                        }
                        $repeated_tag_index[$tag . '_' . $level] = 1;
                        $current = & $current[$tag];
                    } else {
                        if (isset($current[$tag][0])) {
                            $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
                            $repeated_tag_index[$tag . '_' . $level] ++;
                        } else {
                            $current[$tag] = array(
                                $current[$tag],
                                $result
                            );
                            $repeated_tag_index[$tag . '_' . $level] = 2;
                            if (isset($current[$tag][''])) {
                                $current[$tag]['0_attr'] = $current[$tag][''];
                                unset($current[$tag]['']);
                            }
                        }
                        $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
                        $current = & $current[$tag][$last_item_index];
                    }
                } elseif ($type == "complete") {
                    if (!isset($current[$tag]['attr'])) {
                        $current[$tag]['attr'] = $result;
                        $repeated_tag_index[$tag . '_' . $level] = 1;
                        if ($priority == 'tag' and $attributes_data) {
                            $current[$tag]['attr'] = $attributes_data;
                        }
                    } else {
                        if (isset($current[$tag]['attr'][0]) && is_array($current[$tag]['attr'])) {
                            $current[$tag]['attr'][$repeated_tag_index[$tag . '_' . $level]] = $result;
                            if ($priority == 'tag' and $get_attributes and $attributes_data) {
                                $current[$tag]['attr'][$repeated_tag_index[$tag . '_' . $level] . ''] = $attributes_data;
                            }
                            $repeated_tag_index[$tag . '_' . $level] ++;
                        } else {
                            $current[$tag]['attr'] = array($current[$tag]['attr'], $result);
                            $repeated_tag_index[$tag . '_' . $level] = 1;
                            if ($priority == 'tag' and $get_attributes) {
                                if (isset($current[$tag][''])) {
                                    $current[$tag]['attr'] = $current[$tag];
                                    unset($current[$tag]);
                                }
                                if ($attributes_data) {
                                    $current[$tag]['attr'][$repeated_tag_index[$tag . '_' . $level]] = $attributes_data;
                                }
                            }
                            $repeated_tag_index[$tag . '_' . $level] ++;
                        }
                    }
                } elseif ($type == 'close') {
                    $current = & $parent[$level - 1];
                }
            }
            return ($xml_array);
        }
    
    
        protected function getUrl($type) {
            return $this->urls[$type][$this->getTestMode()];
        }
    
        protected function getAuth($key) {
            return $this->auth[$key];
        }
    }