PHP code example of housemates / connect-api

1. Go to this page and download the library: Download housemates/connect-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

housemates / connect-api example snippets


$configuration = new \Housemates\ConnectApi\Configuration();
$configuration
    ->setAccessToken('b2fcrSRUV8OsN6Yn79UKGIiGDCLUJtGqEL3m2aO4')
    ->setApiPartnerId('01H0N04529EXND84J5AN2ZH7CX');

$connectApi = new Housemates\ConnectApi\ApiClient($configuration);

$filters = new \Housemates\ConnectApi\Filters\PropertyFilter();
$filters->setCityFilter('manchester')
try{
    $results = $connectApi->getProperties($filters);
    print_r($results->getData()->getItems());
} catch (\Exception $e) {
    // Handle exception
}

try{
    $property = $connectApi->getProperty('01H0N04529EXND84J5AN2ZH7CX');
    print_r($property->getData()->getItem());
} catch (\Exception $e) {
    // Handle exception
}

$filters = new \Housemates\ConnectApi\Filters\RoomFilter();
$filters->setPriceRangeFilter('[100,400]'); // Please note that the price range must be in the format [min,max]

try{
    $results = $connectApi->getRooms($filters);
    print_r($results->getData()->getItems());
} catch (\Exception $e) {
    // Handle exception
}

$filters = new \Housemates\ConnectApi\Filters\RoomFilter();
$filters->setPriceRangeFilter('[100,400]'); // Please note that the price range must be in the format [min,max]

$sort = new \Housemates\ConnectApi\Sort();
$sort->setSortBy('price', 'asc');

try{
    $results = $connectApi->getRooms($filters, $sort);
    print_r($results->getData()->getItems());
} catch (\Exception $e) {
    // Handle exception
}

try{
    $room = $connectApi->getRoom('01H0N04529EXND84J5AN2ZH7CX');
    print_r($room->getData()->getItem());
} catch (\Exception $e) {
    // Handle exception
}

try{
    $bookingPeriods = $connectApi->getBookingPeriods('01H0N04529EXND84J5AN2ZH7CX');
    print_r($bookingPeriods->getData()->getItems());
} catch (\Exception $e) {
    // Handle exception
}

$checkoutStartRequest = new \Housemates\ConnectApi\Requests\CheckoutStartRequest();
$checkoutStartRequest
    ->setRoomId('01H0N7WS7ZN1DGEJFF2C14K8NJ')
    ->setBookingPeriodId('01H1TQKHVCN2F00MP2D7ACX6S8')
    ->setOperatorId('9258a234-f90b-4871-b434-247087fec215');
try{
    $checkoutStartResponse = $connectApi->startCheckout($checkoutStartRequest);
    print_r($checkoutStartResponse->getData()));
} catch (\Exception $e) {
    // Handle exception
}