コード例 #1
0
 /**
  * Create accommodation units from XML
  *
  * @param  \SimpleXMLElement $sxe the API response
  *
  * @return self
  */
 public function fromXML(\SimpleXMLElement $sxe)
 {
     $accommodationUnits = array();
     $this->count = 0;
     foreach ($sxe->children() as $accommodationUnit) {
         $cat = new AccommodationUnit();
         $cat->fromXml($accommodationUnit);
         $accommodationUnits[] = $cat;
         ++$this->count;
     }
     $this->setData($accommodationUnits);
     return $this;
 }
コード例 #2
0
 * 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' => ''];
    // provide data for update - array with key => value structure
    /**
     ****************************** IMPORTANT *******************************
     * required params:
     *  - title
     *  - accommodation_id
     *  - accommodation_unit_type_id
     */
    $data = ['title' => 'test accommodation unit', 'accommodation_id' => 71, 'accommodation_unit_type_id' => 3];
    $accommodationUnit = AccommodationUnit::createSingle($params, $data, $apiCredentials);
} catch (Exception $ex) {
    echo 'Exception:', $ex->getMessage(), PHP_EOL;
    exit(1);
}
?>

<html>
  <head>
    <meta charset="utf-8">
    <title>Accommodation unit create</title>
  </head>
  <body>
    <div>Accommodation unit created</div>
    <pre><?php 
print_r($accommodationUnit);