/** * Create accommodations from XML * * @param \SimpleXMLElement $sxe the API response * * @return self */ public function fromXML(\SimpleXMLElement $sxe) { $accommodations = array(); $this->count = 0; foreach ($sxe->children() as $accommodation) { $cat = new Accommodation(); $cat->fromXml($accommodation); $accommodations[] = $cat; ++$this->count; } $this->setData($accommodations); return $this; }
* the available accommodation * * API action: getAccommodationCategories */ require __DIR__ . '/../bootstrap.php'; use HolidayLink\Api\Accommodation; /** * Retrieve the accommodation using optional code, filters and your API credentials * (see bootstrap.php for credentials creation) */ try { $params = array('expand' => 'accommodationCategory, supplier_type, location, postal_code, neighborhood, address, map_lat, map_lng, map_zoom, photos, videos, created_at, updated_at'); //set your own accommodation code, this is only for test purpose $code = 'o20'; $accommodation = Accommodation::singleFromXML($code, $params, $apiCredentials); } catch (Exception $ex) { echo 'Exception:', $ex->getMessage(), PHP_EOL; exit(1); } ?> <html> <head> <meta charset="utf-8"> <title>Get accommodation</title> </head> <body> <div>Got accommodation</div> <pre><?php print_r($accommodation->toArray());
* Create the accommodation using optional code and your API credentials * (see bootstrap.php for credentials creation) */ try { // provide some params for expand - preview in response $params = ['expand' => 'postal_code']; // provide data for update - array with key => value structure /** ****************************** IMPORTANT ******************************* * required params: * - title * - accommodation_category_id * - location_id (use just ids from cities, NOT region or country id) */ $data = ['title' => 'test accommodation', 'postal_code' => '12345', 'accommodation_category_id' => 1, 'location_id' => 16]; $accommodation = Accommodation::createSingle($params, $data, $apiCredentials); } catch (Exception $ex) { echo 'Exception:', $ex->getMessage(), PHP_EOL; exit(1); } ?> <html> <head> <meta charset="utf-8"> <title>Accommodation create</title> </head> <body> <div>Accommodation created</div> <pre><?php print_r($accommodation);
* API action: deleteAccommodation */ require __DIR__ . '/../bootstrap.php'; use HolidayLink\Api\Accommodation; /** * Delete the accommodation using optional code and your API credentials * (see bootstrap.php for credentials creation) */ try { // provide some params for expand - preview in response $params = ['expand' => 'postal_code']; // provide data for update - array with key => value structure $data = ['title' => 'test', 'postal_code' => '12345']; //set your own accommodation code, this is only for test purpose $code = 'your code'; $accommodation = Accommodation::updateSingle($code, $params, $data, $apiCredentials); } catch (Exception $ex) { echo 'Exception:', $ex->getMessage(), PHP_EOL; exit(1); } ?> <html> <head> <meta charset="utf-8"> <title>Accommodation update</title> </head> <body> <div>Accommodation updated</div> <pre><?php print_r($accommodation);
/** * This sample demonstrates how to delete accommodation * * API action: deleteAccommodation */ require __DIR__ . '/../bootstrap.php'; use HolidayLink\Api\Accommodation; /** * Delete the accommodation using optional code and your API credentials * (see bootstrap.php for credentials creation) */ try { //set your own accommodation code, this is only for test purpose $code = 'o31'; $accommodation = Accommodation::deleteSingle($code, $apiCredentials); } catch (Exception $ex) { echo 'Exception:', $ex->getMessage(), PHP_EOL; exit(1); } ?> <html> <head> <meta charset="utf-8"> <title>Accommodation delete</title> </head> <body> <div>Accommodation deleted</div> <pre><?php if ($accommodation) {