├── .gitignore ├── lib └── YDD │ └── Vebra │ ├── Exception │ ├── GoneException.php │ ├── NotFoundException.php │ ├── ForbiddenException.php │ ├── NoContentException.php │ ├── XMLParsingException.php │ ├── NotModifiedException.php │ ├── UnauthorizedException.php │ ├── NotImplementedException.php │ ├── UnknownStatusCodeException.php │ └── InternalServerErrorException.php │ ├── TokenStorage │ ├── TokenStorageInterface.php │ ├── Base.php │ └── File.php │ ├── Model │ ├── LandArea.php │ ├── Bullet.php │ ├── ChangedPropertySummary.php │ ├── Price.php │ ├── EnergyRatingPair.php │ ├── Area.php │ ├── PropertySummary.php │ ├── File.php │ ├── Dimension.php │ ├── Paragraph.php │ ├── BranchSummary.php │ ├── AttributedModel.php │ ├── ChangedFileSummary.php │ ├── StreetView.php │ ├── Address.php │ ├── Branch.php │ └── Property.php │ └── API.php ├── composer.json ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/GoneException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * GoneException 17 | */ 18 | class GoneException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/NotFoundException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * NotFoundException 17 | */ 18 | class NotFoundException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/ForbiddenException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * ForbiddenException 17 | */ 18 | class ForbiddenException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/NoContentException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * NoContentException 17 | */ 18 | class NoContentException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/XMLParsingException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * XMLParsingException 17 | */ 18 | class XMLParsingException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/NotModifiedException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * NotModifiedException 17 | */ 18 | class NotModifiedException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/UnauthorizedException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * UnauthorizedException 17 | */ 18 | class UnauthorizedException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/NotImplementedException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * NotImplementedException 17 | */ 18 | class NotImplementedException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/UnknownStatusCodeException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * UnknownStatusCodeException 17 | */ 18 | class UnknownStatusCodeException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Exception/InternalServerErrorException.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Exception; 14 | 15 | /** 16 | * InternalServerErrorException 17 | */ 18 | class InternalServerErrorException extends \Exception 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/TokenStorage/TokenStorageInterface.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\TokenStorage; 14 | 15 | /** 16 | * An interface for storage of Tokens 17 | */ 18 | interface TokenStorageInterface 19 | { 20 | /** 21 | * Set the token 22 | * @param string $token The token 23 | */ 24 | function setToken($token); 25 | 26 | /** 27 | * Get the token 28 | * @return string The token 29 | */ 30 | function getToken(); 31 | } 32 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ydd/vebra", 3 | "description": "Vebra API Wrapper", 4 | "keywords": ["vebra"], 5 | "homepage": "https://github.com/mdavis1982/Vebra-PHP-API-Wrapper", 6 | "type": "library", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Damon Jones", 11 | "email": "damon@yummyduckdesign.co.uk", 12 | "homepage": "http://yummyduckdesign.co.uk/" 13 | }, 14 | { 15 | "name": "Matthew Davis", 16 | "email": "matt@yummyduckdesign.co.uk", 17 | "homepage": "http://yummyduckdesign.co.uk/" 18 | } 19 | ], 20 | "require": { 21 | "php": ">=5.3.2", 22 | "kriswallsmith/buzz": "*" 23 | }, 24 | "autoload": { 25 | "psr-0": { 26 | "YDD": "lib/" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Damon Jones and Matthew Davis 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/LandArea.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * LandArea 17 | */ 18 | class LandArea extends AttributedModel 19 | { 20 | protected static $attributeTypeMapping = array( 21 | 'unit' => 'string' 22 | ); 23 | 24 | protected $area; 25 | 26 | /** 27 | * Constructor 28 | * 29 | * @param float $area The area 30 | */ 31 | public function __construct($area) 32 | { 33 | parent::__construct(); 34 | 35 | $this->setArea($area); 36 | } 37 | 38 | /** 39 | * get Area 40 | * 41 | * @return float $area 42 | */ 43 | public function getArea() 44 | { 45 | return $this->area; 46 | } 47 | 48 | /** 49 | * set Area 50 | * 51 | * @param float $area 52 | * 53 | * @return object 54 | */ 55 | public function setArea($area) 56 | { 57 | $this->area = (float) $area; 58 | 59 | return $this; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/Bullet.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * Bullet 17 | */ 18 | class Bullet extends AttributedModel 19 | { 20 | protected static $attributeTypeMapping = array( 21 | 'id' => 'int' 22 | ); 23 | 24 | protected $value; // varchar 50 25 | 26 | /** 27 | * Constructor 28 | * 29 | * @param string $value The bullet text 30 | */ 31 | public function __construct($value) 32 | { 33 | parent::__construct(); 34 | 35 | $this->value = $value; 36 | } 37 | 38 | /** 39 | * get Value 40 | * 41 | * @return string $value 42 | */ 43 | public function getValue() 44 | { 45 | return $this->value; 46 | } 47 | 48 | /** 49 | * set Value 50 | * 51 | * @param string $value 52 | * 53 | * @return object 54 | */ 55 | public function setValue($value) 56 | { 57 | $this->value = $value; 58 | 59 | return $this; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/ChangedPropertySummary.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * ChangedPropertySummary 17 | */ 18 | class ChangedPropertySummary extends PropertySummary 19 | { 20 | protected $lastAction; 21 | 22 | /** 23 | * set LastAction 24 | * 25 | * @param string $lastAction 26 | * 27 | * @return object 28 | */ 29 | public function setLastAction($lastAction) 30 | { 31 | $this->lastAction = $lastAction; 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * get LastAction 38 | * 39 | * @return string 40 | */ 41 | public function getLastAction() 42 | { 43 | return $this->lastAction; 44 | } 45 | 46 | /** 47 | * get ClientId 48 | * 49 | * @return int $clientId 50 | */ 51 | public function getClientId() 52 | { 53 | preg_match('#branch\/(\d+)/#', $this->url, $matches); 54 | 55 | return isset($matches[1]) ? (int) $matches[1] : null; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/TokenStorage/Base.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\TokenStorage; 14 | 15 | /** 16 | * A base implementation of TokenStorageInterface 17 | */ 18 | abstract class Base implements TokenStorageInterface 19 | { 20 | /** 21 | * The token 22 | * @var string 23 | */ 24 | protected $token; 25 | 26 | /** 27 | * Constructor 28 | */ 29 | public function __construct() 30 | { 31 | $this->load(); 32 | } 33 | 34 | /** 35 | * Set the token 36 | * @param string $token Set the token 37 | */ 38 | public function setToken($token) 39 | { 40 | $this->token = $token; 41 | $this->save(); 42 | } 43 | 44 | /** 45 | * Get the token 46 | * @return string Get the token 47 | */ 48 | public function getToken() 49 | { 50 | return $this->token; 51 | } 52 | 53 | /** 54 | * Load the token 55 | */ 56 | abstract protected function load(); 57 | 58 | /** 59 | * Save the token 60 | */ 61 | abstract protected function save(); 62 | } 63 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/Price.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * Price 17 | */ 18 | class Price extends AttributedModel 19 | { 20 | protected static $attributeTypeMapping = array( 21 | 'rent' => 'string', 22 | 'currency' => 'string', 23 | 'qualifier' => 'string', 24 | 'display' => 'string' 25 | ); 26 | 27 | protected $value; 28 | 29 | /** 30 | * Constructor 31 | * 32 | * @param int $value The price 33 | */ 34 | public function __construct($value) 35 | { 36 | parent::__construct(); 37 | 38 | $this->value = $value; 39 | } 40 | 41 | /** 42 | * get Value 43 | * 44 | * @return int $value 45 | */ 46 | public function getValue() 47 | { 48 | return $this->value; 49 | } 50 | 51 | /** 52 | * set Value 53 | * 54 | * @param int $value 55 | * 56 | * @return object 57 | */ 58 | public function setValue($value) 59 | { 60 | $this->value = (int) $value; 61 | 62 | return $this; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/EnergyRatingPair.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * EnergyRatingPair 17 | */ 18 | class EnergyRatingPair 19 | { 20 | protected $current; 21 | protected $potential; 22 | 23 | /** 24 | * Constructor 25 | * 26 | * @param int $current The current value 27 | * @param int $potential The potential value 28 | */ 29 | public function __construct($current, $potential) 30 | { 31 | $this->setCurrent($current); 32 | $this->setPotential($potential); 33 | } 34 | 35 | /** 36 | * get Current 37 | * 38 | * @return int $current 39 | */ 40 | public function getCurrent() 41 | { 42 | return $this->current; 43 | } 44 | 45 | /** 46 | * set Current 47 | * 48 | * @param int $current 49 | * 50 | * @return object 51 | */ 52 | public function setCurrent($current) 53 | { 54 | $this->current = (int) $current; 55 | 56 | return $this; 57 | } 58 | 59 | /** 60 | * get Potential 61 | * 62 | * @return int $potential 63 | */ 64 | public function getPotential() 65 | { 66 | return $this->potential; 67 | } 68 | 69 | /** 70 | * set Potential 71 | * 72 | * @param int $potential 73 | * 74 | * @return object 75 | */ 76 | public function setPotential($potential) 77 | { 78 | $this->potential = (int) $potential; 79 | 80 | return $this; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/Area.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * Area 17 | */ 18 | class Area extends AttributedModel 19 | { 20 | protected static $attributeTypeMapping = array( 21 | 'measure' => 'string', 22 | 'unit' => 'string' 23 | ); 24 | 25 | protected $min; 26 | protected $max; 27 | 28 | /** 29 | * Constructor 30 | * 31 | * @param float $min The minimum 32 | * @param float $max The maximum 33 | */ 34 | public function __construct($min, $max) 35 | { 36 | parent::__construct(); 37 | 38 | $this->setMin($min); 39 | $this->setMax($max); 40 | } 41 | 42 | /** 43 | * get Min 44 | * 45 | * @return float $min 46 | */ 47 | public function getMin() 48 | { 49 | return $this->min; 50 | } 51 | 52 | /** 53 | * set Min 54 | * 55 | * @param float $min 56 | * 57 | * @return object 58 | */ 59 | public function setMin($min) 60 | { 61 | $this->min = (float) $min; 62 | 63 | return $this; 64 | } 65 | 66 | /** 67 | * get Max 68 | * 69 | * @return float $max 70 | */ 71 | public function getMax() 72 | { 73 | return $this->max; 74 | } 75 | 76 | /** 77 | * set Max 78 | * 79 | * @param float $max 80 | * 81 | * @return object 82 | */ 83 | public function setMax($max) 84 | { 85 | $this->max = (float) $max; 86 | 87 | return $this; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/PropertySummary.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * PropertySummary 17 | */ 18 | class PropertySummary 19 | { 20 | protected $propId; 21 | protected $lastChanged; 22 | protected $url; 23 | 24 | /** 25 | * set PropId 26 | * 27 | * @param int $propId 28 | * 29 | * @return object 30 | */ 31 | public function setPropId($propId) 32 | { 33 | $this->propId = (int) $propId; 34 | 35 | return $this; 36 | } 37 | 38 | /** 39 | * get PropId 40 | * 41 | * @return int $propId 42 | */ 43 | public function getPropId() 44 | { 45 | return $this->propId; 46 | } 47 | 48 | /** 49 | * set LastChanged 50 | * 51 | * @param \DateTime $lastChanged 52 | * 53 | * @return object 54 | */ 55 | public function setLastChanged(\DateTime $lastChanged = null) 56 | { 57 | $this->lastChanged = $lastChanged; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * get lastChanged 64 | * 65 | * @return \DateTime $lastChanged 66 | */ 67 | public function getLastChanged() 68 | { 69 | return $this->lastChanged; 70 | } 71 | 72 | /** 73 | * set Url 74 | * 75 | * @param string $url 76 | * 77 | * @return object 78 | */ 79 | public function setUrl($url) 80 | { 81 | $this->url = $url; 82 | 83 | return $this; 84 | } 85 | 86 | /** 87 | * get Url 88 | * 89 | * @return string $url 90 | */ 91 | public function getUrl() 92 | { 93 | return $this->url; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/File.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * File 17 | */ 18 | class File extends AttributedModel 19 | { 20 | protected static $attributeTypeMapping = array( 21 | 'id' => 'int', 22 | 'type' => 'int' 23 | ); 24 | 25 | protected $name; // varchar 255 26 | protected $url; // varchar 255 27 | protected $updated; // \DateTime 28 | 29 | /** 30 | * get Name 31 | * 32 | * @return string $name 33 | */ 34 | public function getName() 35 | { 36 | return $this->name; 37 | } 38 | 39 | /** 40 | * set Name 41 | * 42 | * @param string $name 43 | * 44 | * @return object 45 | */ 46 | public function setName($name) 47 | { 48 | $this->name = $name; 49 | 50 | return $this; 51 | } 52 | 53 | /** 54 | * get Url 55 | * 56 | * @return string $url 57 | */ 58 | public function getUrl() 59 | { 60 | return $this->url; 61 | } 62 | 63 | /** 64 | * set Url 65 | * 66 | * @param string $url 67 | * 68 | * @return object 69 | */ 70 | public function setUrl($url) 71 | { 72 | $this->url = $url; 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * get Updated 79 | * 80 | * @return \DateTime $updated 81 | */ 82 | public function getUpdated() 83 | { 84 | return $this->updated; 85 | } 86 | 87 | /** 88 | * set Updated 89 | * 90 | * @param \DateTime $updated 91 | * 92 | * @return object 93 | */ 94 | public function setUpdated($updated) 95 | { 96 | $this->updated = $updated; 97 | 98 | return $this; 99 | } 100 | 101 | /** 102 | * get FileId 103 | * 104 | * @return int $fileId 105 | */ 106 | public function getFileId() 107 | { 108 | if ($this->url) { 109 | return (int) substr($this->url, strrpos($this->url, '/') + 1); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/TokenStorage/File.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\TokenStorage; 14 | 15 | /** 16 | * A filesystem based Token Storage system 17 | */ 18 | class File extends Base 19 | { 20 | /** 21 | * The unique username to use for finding this specific token 22 | * @var string 23 | */ 24 | protected $username; 25 | 26 | /** 27 | * The path where the token files are stored 28 | * @var string 29 | */ 30 | protected $path; 31 | 32 | /** 33 | * Constructor 34 | * @param string $username The username to use to identify this specific token 35 | * @param string $path The path where the token files are stored 36 | */ 37 | public function __construct($username, $path) 38 | { 39 | if (!$username) { 40 | throw new \InvalidArgumentException('Username must be provided.'); 41 | } 42 | 43 | if (!$path) { 44 | throw new \InvalidArgumentException('Token file path must be provided.'); 45 | } 46 | 47 | $this->username = $username; 48 | $this->path = $path; 49 | 50 | parent::__construct(); 51 | } 52 | 53 | /** 54 | * Get the filename of the file containing this token 55 | * @return string The path and filename of the file containing this token 56 | */ 57 | protected function getFilename() 58 | { 59 | return $this->path . md5($this->username) . '.txt'; 60 | } 61 | 62 | /** 63 | * Load the token from a file 64 | */ 65 | protected function load() 66 | { 67 | if (false !== ($token = @file_get_contents($this->getFilename()))) { 68 | $this->token = trim($token); 69 | } else { 70 | throw new \Exception(sprintf('Token could not be loaded from "%s"', $this->getFilename())); 71 | } 72 | } 73 | 74 | /** 75 | * Save the token to a file 76 | */ 77 | protected function save() 78 | { 79 | if (false === ($result = @file_put_contents($this->getFilename(), $this->token))) { 80 | throw new \Exception(sprintf('Token could not be saved to "%s"', $this->getFilename())); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/Dimension.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * Dimension 17 | */ 18 | class Dimension 19 | { 20 | protected $metric; // varchar 50 21 | protected $imperial; // varchar 50 22 | protected $mixed; // varchar 50 23 | 24 | /** 25 | * Constructor 26 | * 27 | * @param string $metric The metric value 28 | * @param string $imperial The imperial value 29 | * @param string $mixed The mixed value 30 | */ 31 | public function __construct($metric, $imperial, $mixed) 32 | { 33 | $this->setMetric($metric); 34 | $this->setImperial($imperial); 35 | $this->setMixed($mixed); 36 | } 37 | 38 | /** 39 | * get Metric 40 | * 41 | * @return string $metric 42 | */ 43 | public function getMetric() 44 | { 45 | return $this->metric; 46 | } 47 | 48 | /** 49 | * set Metric 50 | * 51 | * @param string $metric 52 | * 53 | * @return object 54 | */ 55 | public function setMetric($metric) 56 | { 57 | $this->metric = $metric; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * get Imperial 64 | * 65 | * @return string $imperial 66 | */ 67 | public function getImperial() 68 | { 69 | return $this->imperial; 70 | } 71 | 72 | /** 73 | * set Imperial 74 | * 75 | * @param string $imperial 76 | * 77 | * @return object 78 | */ 79 | public function setImperial($imperial) 80 | { 81 | $this->imperial = $imperial; 82 | 83 | return $this; 84 | } 85 | 86 | /** 87 | * get Mixed 88 | * 89 | * @return string $mixed 90 | */ 91 | public function getMixed() 92 | { 93 | return $this->mixed; 94 | } 95 | 96 | /** 97 | * set Mixed 98 | * 99 | * @param string $mixed 100 | * 101 | * @return object 102 | */ 103 | public function setMixed($mixed) 104 | { 105 | $this->mixed = $mixed; 106 | 107 | return $this; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/Paragraph.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * Paragraph 17 | */ 18 | class Paragraph extends AttributedModel 19 | { 20 | protected static $attributeTypeMapping = array( 21 | 'id' => 'int', 22 | 'type' => 'int' 23 | ); 24 | 25 | protected $name; // varchar 255 26 | protected $file; // int (index of the file, see Property's files property) 27 | protected $dimension; // Dimension 28 | protected $text; 29 | 30 | /** 31 | * get Name 32 | * 33 | * @return string $name 34 | */ 35 | public function getName() 36 | { 37 | return $this->name; 38 | } 39 | 40 | /** 41 | * set Name 42 | * 43 | * @param string $name 44 | * 45 | * @return object 46 | */ 47 | public function setName($name) 48 | { 49 | $this->name = $name; 50 | 51 | return $this; 52 | } 53 | 54 | /** 55 | * get File 56 | * 57 | * @return int $file 58 | */ 59 | public function getFile() 60 | { 61 | return $this->file; 62 | } 63 | 64 | /** 65 | * set File 66 | * 67 | * @param int $file 68 | * 69 | * @return object 70 | */ 71 | public function setFile($file) 72 | { 73 | $this->file = (int) $file; 74 | 75 | return $this; 76 | } 77 | 78 | /** 79 | * get Dimension 80 | * 81 | * @return Dimension $dimension 82 | */ 83 | public function getDimension() 84 | { 85 | return $this->dimension; 86 | } 87 | 88 | /** 89 | * set Dimension 90 | * 91 | * @param Dimension $dimension 92 | * 93 | * @return object 94 | */ 95 | public function setDimension(Dimension $dimension) 96 | { 97 | $this->dimension = $dimension; 98 | 99 | return $this; 100 | } 101 | 102 | /** 103 | * get Text 104 | * 105 | * @return string $text 106 | */ 107 | public function getText() 108 | { 109 | return $this->text; 110 | } 111 | 112 | /** 113 | * set Text 114 | * 115 | * @param string $text 116 | * 117 | * @return object 118 | */ 119 | public function setText($text) 120 | { 121 | $this->text = $text; 122 | 123 | return $this; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/BranchSummary.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * BranchSummary 17 | */ 18 | class BranchSummary 19 | { 20 | protected $name; 21 | protected $firmId; 22 | protected $branchId; 23 | protected $url; 24 | 25 | /** 26 | * set Name 27 | * 28 | * @param string $name 29 | * 30 | * @return object 31 | */ 32 | public function setName($name) 33 | { 34 | $this->name = $name; 35 | 36 | return $this; 37 | } 38 | 39 | /** 40 | * get Name 41 | * 42 | * @return string $name 43 | */ 44 | public function getName() 45 | { 46 | return $this->name; 47 | } 48 | 49 | /** 50 | * set FirmId 51 | * 52 | * @param int $firmId 53 | * 54 | * @return object 55 | */ 56 | public function setFirmId($firmId) 57 | { 58 | $this->firmId = (int) $firmId; 59 | 60 | return $this; 61 | } 62 | 63 | /** 64 | * get FirmId 65 | * 66 | * @return int $firmId 67 | */ 68 | public function getFirmId() 69 | { 70 | return $this->firmId; 71 | } 72 | 73 | /** 74 | * set BranchId 75 | * 76 | * @param int $branchId 77 | * 78 | * @return object 79 | */ 80 | public function setBranchId($branchId) 81 | { 82 | $this->branchId = (int) $branchId; 83 | 84 | return $this; 85 | } 86 | 87 | /** 88 | * get BranchId 89 | * 90 | * @return int $branchId 91 | */ 92 | public function getBranchId() 93 | { 94 | return $this->branchId; 95 | } 96 | 97 | /** 98 | * set Url 99 | * 100 | * @param string $url 101 | * 102 | * @return object 103 | */ 104 | public function setUrl($url) 105 | { 106 | $this->url = $url; 107 | 108 | return $this; 109 | } 110 | 111 | /** 112 | * get Url 113 | * 114 | * @return string $url 115 | */ 116 | public function getUrl() 117 | { 118 | return $this->url; 119 | } 120 | 121 | /** 122 | * get ClientId 123 | * 124 | * @return int $clientId 125 | */ 126 | public function getClientId() 127 | { 128 | if ($this->url) { 129 | return (int) substr($this->url, strrpos($this->url, '/') + 1); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/AttributedModel.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * AttributedModel 17 | */ 18 | class AttributedModel 19 | { 20 | protected $attributes; 21 | 22 | /** 23 | * Constructor 24 | */ 25 | public function __construct() 26 | { 27 | $this->attributes = array(); 28 | } 29 | 30 | /** 31 | * get Attribute 32 | * 33 | * @param string $key 34 | * 35 | * @return string 36 | */ 37 | public function getAttribute($key) 38 | { 39 | if (array_key_exists($key, $this->attributes)) { 40 | return $this->attributes[$key]; 41 | } 42 | } 43 | 44 | /** 45 | * set Attribute 46 | * 47 | * @param string $key The attribute name 48 | * @param \SimpleXMLElement $value The attribute value 49 | * 50 | * @return object 51 | */ 52 | public function setAttribute($key, $value) 53 | { 54 | if (array_key_exists($key, static::$attributeTypeMapping)) { 55 | $type = strtolower(static::$attributeTypeMapping[$key]); 56 | switch ($type) { 57 | case 'boolean': 58 | case 'bool': 59 | $value = (bool) filter_var($value, FILTER_VALIDATE_BOOLEAN); 60 | break; 61 | case 'integer': 62 | case 'int': 63 | $value = (int) $value; 64 | break; 65 | case 'float': 66 | $value = (float) $value; 67 | break; 68 | case 'string': 69 | default: 70 | $value = (string) $value; 71 | break; 72 | } 73 | 74 | $this->attributes[$key] = $value; 75 | } else { 76 | throw new \InvalidArgumentException("Unexpected attribute '$key'."); 77 | } 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * get Attributes 84 | * 85 | * @return array $attributes 86 | */ 87 | public function getAttributes() 88 | { 89 | return $this->attributes; 90 | } 91 | 92 | /** 93 | * set Attributes 94 | * 95 | * @param object|array $attributes 96 | * 97 | * @return object 98 | */ 99 | public function setAttributes($attributes) 100 | { 101 | foreach ($attributes as $key => $value) { 102 | $this->setAttribute($key, $value); 103 | } 104 | 105 | return $this; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/ChangedFileSummary.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * ChangedFileSummary 17 | */ 18 | class ChangedFileSummary 19 | { 20 | protected $fileId; 21 | protected $filePropId; 22 | protected $lastChanged; 23 | protected $isDeleted; 24 | protected $url; 25 | protected $propUrl; 26 | 27 | /** 28 | * set FileId 29 | * 30 | * @param int $fileId 31 | * 32 | * @return $this 33 | */ 34 | public function setFileId($fileId) 35 | { 36 | $this->fileId = (int) $fileId; 37 | 38 | return $this; 39 | } 40 | 41 | /** 42 | * get FileId 43 | * 44 | * @return int $fileId 45 | */ 46 | public function getFileId() 47 | { 48 | return $this->fileId; 49 | } 50 | 51 | /** 52 | * set FilePropId 53 | * 54 | * @param int $filePropId 55 | * 56 | * @return object 57 | */ 58 | public function setFilePropId($filePropId) 59 | { 60 | $this->filePropId = (int) $filePropId; 61 | 62 | return $this; 63 | } 64 | 65 | /** 66 | * get FilePropId 67 | * 68 | * @return int $filePropId 69 | */ 70 | public function getFilePropId() 71 | { 72 | return $this->filePropId; 73 | } 74 | 75 | /** 76 | * set LastChanged 77 | * 78 | * @param \DateTime $lastChanged 79 | * 80 | * @return object 81 | */ 82 | public function setLastChanged(\DateTime $lastChanged = null) 83 | { 84 | $this->lastChanged = $lastChanged; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * get lastChanged 91 | * 92 | * @return \DateTime $lastChanged 93 | */ 94 | public function getLastChanged() 95 | { 96 | return $this->lastChanged; 97 | } 98 | 99 | /** 100 | * set isDeleted 101 | * 102 | * @param Boolean $isDeleted 103 | * 104 | * @return object 105 | */ 106 | public function setIsDeleted($isDeleted) 107 | { 108 | $this->isDeleted = (bool) $isDeleted; 109 | 110 | return $this; 111 | } 112 | 113 | /** 114 | * isDeleted 115 | * 116 | * @return Boolean 117 | */ 118 | public function isDeleted() 119 | { 120 | return $this->isDeleted; 121 | } 122 | 123 | /** 124 | * set Url 125 | * 126 | * @param string $url 127 | * 128 | * @return object 129 | */ 130 | public function setUrl($url) 131 | { 132 | $this->url = $url; 133 | 134 | return $this; 135 | } 136 | 137 | /** 138 | * get Url 139 | * 140 | * @return string $url 141 | */ 142 | public function getUrl() 143 | { 144 | return $this->url; 145 | } 146 | 147 | /** 148 | * set PropUrl 149 | * 150 | * @param string $propUrl 151 | * 152 | * @return object 153 | */ 154 | public function setPropUrl($propUrl) 155 | { 156 | $this->propUrl = $propUrl; 157 | 158 | return $this; 159 | } 160 | 161 | /** 162 | * get PropUrl 163 | * 164 | * @return string 165 | */ 166 | public function getPropUrl() 167 | { 168 | return $this->propUrl; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/StreetView.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * StreetView 17 | */ 18 | class StreetView 19 | { 20 | protected $povLatitude; 21 | protected $povLongitude; 22 | protected $povPitch; 23 | protected $povHeading; 24 | protected $povZoom; 25 | 26 | /** 27 | * Constructor 28 | * 29 | * @param float $povLatitude The metric value 30 | * @param float $povLongitude The imperial value 31 | * @param float $povPitch The mixed value 32 | * @param float $povHeading The mixed value 33 | * @param int $povZoom The pov_zoom value 34 | */ 35 | public function __construct($povLatitude, $povLongitude, $povPitch, $povHeading, $povZoom) 36 | { 37 | $this->setPovLatitude($povLatitude); 38 | $this->setPovLongitude($povLongitude); 39 | $this->setPovPitch($povPitch); 40 | $this->setPovHeading($povHeading); 41 | $this->setPovZoom($povZoom); 42 | } 43 | 44 | /** 45 | * get PovLatitude 46 | * 47 | * @return float $povLatitude 48 | */ 49 | public function getPovLatitude() 50 | { 51 | return $this->povLatitude; 52 | } 53 | 54 | /** 55 | * set PovLatitude 56 | * 57 | * @param float $povLatitude 58 | * 59 | * @return object 60 | */ 61 | public function setPovLatitude($povLatitude) 62 | { 63 | $this->povLatitude = $povLatitude; 64 | 65 | return $this; 66 | } 67 | 68 | /** 69 | * get PovLongitude 70 | * 71 | * @return float $povLongitude 72 | */ 73 | public function getPovLongitude() 74 | { 75 | return $this->povLongitude; 76 | } 77 | 78 | /** 79 | * set PovLongitude 80 | * 81 | * @param float $povLongitude 82 | * 83 | * @return object 84 | */ 85 | public function setPovLongitude($povLongitude) 86 | { 87 | $this->povLongitude = $povLongitude; 88 | 89 | return $this; 90 | } 91 | 92 | /** 93 | * get PovPitch 94 | * 95 | * @return float $povPitch 96 | */ 97 | public function getPovPitch() 98 | { 99 | return $this->povPitch; 100 | } 101 | 102 | /** 103 | * set PovPitch 104 | * 105 | * @param float $povPitch 106 | * 107 | * @return object 108 | */ 109 | public function setPovPitch($povPitch) 110 | { 111 | $this->povPitch = $povPitch; 112 | 113 | return $this; 114 | } 115 | 116 | /** 117 | * get PovHeading 118 | * 119 | * @return float $povHeading 120 | */ 121 | public function getPovHeading() 122 | { 123 | return $this->povHeading; 124 | } 125 | 126 | /** 127 | * set PovHeading 128 | * 129 | * @param float $povHeading 130 | * 131 | * @return object 132 | */ 133 | public function setPovHeading($povHeading) 134 | { 135 | $this->povHeading = $povHeading; 136 | 137 | return $this; 138 | } 139 | 140 | /** 141 | * get PovZoom 142 | * 143 | * @return int $povZoom 144 | */ 145 | public function getPovZoom() 146 | { 147 | return $this->povZoom; 148 | } 149 | 150 | /** 151 | * set PovZoom 152 | * 153 | * @param int $povZoom 154 | * 155 | * @return object 156 | */ 157 | public function setPovZoom($povZoom) 158 | { 159 | $this->povZoom = $povZoom; 160 | 161 | return $this; 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/Address.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * Address 17 | */ 18 | class Address 19 | { 20 | protected $name; // varchar 50 21 | protected $street; // varchar 50 22 | protected $locality; // varchar 150 23 | protected $town; // varchar 50 24 | protected $county; // varchar 50 25 | protected $postcode; // varchar 9 26 | protected $customLocation; // varchar 100 27 | protected $display; // varchar 255 28 | 29 | /** 30 | * get Name 31 | * 32 | * @return string $name 33 | */ 34 | public function getName() 35 | { 36 | return $this->name; 37 | } 38 | 39 | /** 40 | * set Name 41 | * 42 | * @param string $name 43 | * 44 | * @return object 45 | */ 46 | public function setName($name) 47 | { 48 | $this->name = $name; 49 | 50 | return $this; 51 | } 52 | 53 | /** 54 | * get Street 55 | * 56 | * @return string $street 57 | */ 58 | public function getStreet() 59 | { 60 | return $this->street; 61 | } 62 | 63 | /** 64 | * set Street 65 | * 66 | * @param string $street 67 | * 68 | * @return object 69 | */ 70 | public function setStreet($street) 71 | { 72 | $this->street = $street; 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * get Locality 79 | * 80 | * @return string $locality 81 | */ 82 | public function getLocality() 83 | { 84 | return $this->locality; 85 | } 86 | 87 | /** 88 | * set Locality 89 | * 90 | * @param string $locality 91 | * 92 | * @return object 93 | */ 94 | public function setLocality($locality) 95 | { 96 | $this->locality = $locality; 97 | 98 | return $this; 99 | } 100 | 101 | /** 102 | * get Town 103 | * 104 | * @return string $town 105 | */ 106 | public function getTown() 107 | { 108 | return $this->town; 109 | } 110 | 111 | /** 112 | * set Town 113 | * 114 | * @param string $town 115 | * 116 | * @return object 117 | */ 118 | public function setTown($town) 119 | { 120 | $this->town = $town; 121 | 122 | return $this; 123 | } 124 | 125 | /** 126 | * get County 127 | * 128 | * @return string $county 129 | */ 130 | public function getCounty() 131 | { 132 | return $this->county; 133 | } 134 | 135 | /** 136 | * set County 137 | * 138 | * @param string $county 139 | * 140 | * @return object 141 | */ 142 | public function setCounty($county) 143 | { 144 | $this->county = $county; 145 | 146 | return $this; 147 | } 148 | 149 | /** 150 | * get Postcode 151 | * 152 | * @return string $postcode 153 | */ 154 | public function getPostcode() 155 | { 156 | return $this->postcode; 157 | } 158 | 159 | /** 160 | * set Postcode 161 | * 162 | * @param string $postcode 163 | * 164 | * @return object 165 | */ 166 | public function setPostcode($postcode) 167 | { 168 | $this->postcode = $postcode; 169 | 170 | return $this; 171 | } 172 | 173 | /** 174 | * get CustomLocation 175 | * 176 | * @return string $customLocation 177 | */ 178 | public function getCustomLocation() 179 | { 180 | return $this->customLocation; 181 | } 182 | 183 | /** 184 | * set CustomLocation 185 | * 186 | * @param string $customLocation 187 | * 188 | * @return object 189 | */ 190 | public function setCustomLocation($customLocation) 191 | { 192 | $this->customLocation = $customLocation; 193 | 194 | return $this; 195 | } 196 | 197 | /** 198 | * get Display 199 | * 200 | * @return string $display 201 | */ 202 | public function getDisplay() 203 | { 204 | return $this->display; 205 | } 206 | 207 | /** 208 | * set Display 209 | * 210 | * @param string $display 211 | * 212 | * @return object 213 | */ 214 | public function setDisplay($display) 215 | { 216 | $this->display = $display; 217 | 218 | return $this; 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vebra PHP API Wrapper 2 | ===================== 3 | 4 | This is a third-party PHP library which aims to simplify the use of the Vebra XML web service.
5 | The current version of the API is version 9.
6 | NB: This library is not affiliated with [Vebra](http://vebra.com/) in any way.
7 | 8 | See the [User Guide](http://webservices.vebra.com/export/xsd/v9/Client_Feed_API_v9_UserGuide.pdf) or the [Vebra API Version 9 schema](http://webservices.vebra.com/export/xsd/v9/exportapi.xsd) for more information. 9 | 10 | Requirements 11 | ------------ 12 | 13 | PHP 5.3+
14 | The [Buzz](http://github.com/kriswallsmith/Buzz/) lightweight HTTP Request library. 15 | 16 | Recommended installation method (using the Composer dependency manager) 17 | ----------------------------------------------------------------------- 18 | 19 | If you are starting a new project, or if your existing project does not use composer, download and install it: 20 | 21 | curl -s http://getcomposer.org/installer | php 22 | 23 | Create a new composer.json file with this library as a dependency: 24 | 25 | ```json 26 | { 27 | "require": { 28 | "ydd/vebra": "*@dev" 29 | } 30 | } 31 | ``` 32 | 33 | If your project is already using composer then edit the composer.json file in your project and add this library as a dependency, as shown above. 34 | 35 | Install your project dependencies using composer: 36 | 37 | php composer.phar install 38 | 39 | Require the composer autoloader in your script or bootstrap code: 40 | ```php 41 | getBranches(); 89 | 90 | Iterate over the branch summary objects and retrieve branch objects for each one: 91 | 92 | foreach ($branchSummaries as $branchSummary) { 93 | $branch = $api->getBranch($branchSummary->getClientId()); 94 | } 95 | 96 | The returned branch object has accessors for each of the properties: 97 | 98 | echo $branch->getName(); 99 | 100 | Retrieve the properties for a given branch (as an iterable collection of property summary objects): 101 | 102 | $propertySummaries = $api->getPropertyList($branch->getClientId()); 103 | 104 | Iterate over the property summary objects and retrieve property objects for each one: 105 | 106 | foreach ($propertySummaries as $propertySummary) { 107 | $property = $api->getProperty($branch->getClientId(), $propertySummary->getPropId()); 108 | } 109 | 110 | The returned property object has accessors for each of the properties: 111 | 112 | echo $property->getAddress(); 113 | 114 | Retrieve properties which have changed since a given date: 115 | 116 | $properties = $api->getChangedProperties(new \DateTime('2012-01-01')); 117 | 118 | Retrieve files which have changed since a given date: 119 | 120 | $files = $api->getChangedFiles(new \DateTime('2012-01-01')); 121 | 122 | Authors 123 | ------- 124 | 125 | Damon Jones -
126 | Matthew Davis 127 | 128 | License 129 | ------- 130 | 131 | Vebra PHP API Wrapper is licensed under the MIT License - see the LICENSE file for details 132 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/Branch.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * Branch 17 | */ 18 | class Branch 19 | { 20 | protected $clientId; 21 | protected $firmId; 22 | protected $branchId; 23 | protected $name; 24 | protected $street; 25 | protected $town; 26 | protected $county; 27 | protected $postcode; 28 | protected $phone; 29 | protected $email; 30 | protected $queriedAt; 31 | 32 | /** 33 | * Constructor 34 | */ 35 | public function __construct() 36 | { 37 | $this->setQueriedAt(new \DateTime); 38 | } 39 | 40 | /** 41 | * set ClientId 42 | * 43 | * @param int $clientId 44 | * 45 | * @return object 46 | */ 47 | public function setClientId($clientId) 48 | { 49 | $this->clientId = (int) $clientId; 50 | 51 | return $this; 52 | } 53 | 54 | /** 55 | * get ClientId 56 | * 57 | * @return int $value 58 | */ 59 | public function getClientId() 60 | { 61 | return $this->clientId; 62 | } 63 | 64 | /** 65 | * set FirmId 66 | * 67 | * @param int $firmId 68 | * 69 | * @return object 70 | */ 71 | public function setFirmId($firmId) 72 | { 73 | $this->firmId = (int) $firmId; 74 | 75 | return $this; 76 | } 77 | 78 | /** 79 | * get FirmId 80 | * 81 | * @return int $firmId 82 | */ 83 | public function getFirmId() 84 | { 85 | return $this->firmId; 86 | } 87 | 88 | /** 89 | * set BranchId 90 | * 91 | * @param int $branchId 92 | * 93 | * @return object 94 | */ 95 | public function setBranchId($branchId) 96 | { 97 | $this->branchId = (int) $branchId; 98 | 99 | return $this; 100 | } 101 | 102 | /** 103 | * get BranchId 104 | * 105 | * @return int $branchId 106 | */ 107 | public function getBranchId() 108 | { 109 | return $this->branchId; 110 | } 111 | 112 | /** 113 | * set Name 114 | * 115 | * @param string $name 116 | * 117 | * @return object 118 | */ 119 | public function setName($name) 120 | { 121 | $this->name = $name; 122 | 123 | return $this; 124 | } 125 | 126 | /** 127 | * get Name 128 | * 129 | * @return string $name 130 | */ 131 | public function getName() 132 | { 133 | return $this->name; 134 | } 135 | 136 | /** 137 | * set Street 138 | * 139 | * @param string $street 140 | * 141 | * @return object 142 | */ 143 | public function setStreet($street) 144 | { 145 | $this->street = $street; 146 | 147 | return $this; 148 | } 149 | 150 | /** 151 | * get Street 152 | * 153 | * @return string $street 154 | */ 155 | public function getStreet() 156 | { 157 | return $this->street; 158 | } 159 | 160 | /** 161 | * set Town 162 | * 163 | * @param string $town 164 | * 165 | * @return object 166 | */ 167 | public function setTown($town) 168 | { 169 | $this->town = $town; 170 | 171 | return $this; 172 | } 173 | 174 | /** 175 | * get Town 176 | * 177 | * @return string $towm 178 | */ 179 | public function getTown() 180 | { 181 | return $this->town; 182 | } 183 | 184 | /** 185 | * set County 186 | * 187 | * @param string $county 188 | * 189 | * @return object 190 | */ 191 | public function setCounty($county) 192 | { 193 | $this->county = $county; 194 | 195 | return $this; 196 | } 197 | 198 | /** 199 | * get County 200 | * 201 | * @return string $county 202 | */ 203 | public function getCounty() 204 | { 205 | return $this->county; 206 | } 207 | 208 | /** 209 | * set Postcode 210 | * 211 | * @param string $postcode 212 | * 213 | * @return object 214 | */ 215 | public function setPostcode($postcode) 216 | { 217 | $this->postcode = $postcode; 218 | 219 | return $this; 220 | } 221 | 222 | /** 223 | * get Postcode 224 | * 225 | * @return string $postcode 226 | */ 227 | public function getPostcode() 228 | { 229 | return $this->postcode; 230 | } 231 | 232 | /** 233 | * set Phone 234 | * 235 | * @param string $phone 236 | * 237 | * @return object 238 | */ 239 | public function setPhone($phone) 240 | { 241 | $this->phone = $phone; 242 | 243 | return $this; 244 | } 245 | 246 | /** 247 | * get Phone 248 | * 249 | * @return string $phone 250 | */ 251 | public function getPhone() 252 | { 253 | return $this->phone; 254 | } 255 | 256 | /** 257 | * set Email 258 | * 259 | * @param string $email 260 | * 261 | * @return object 262 | */ 263 | public function setEmail($email) 264 | { 265 | $this->email = $email; 266 | 267 | return $this; 268 | } 269 | 270 | /** 271 | * get Email 272 | * 273 | * @return string $email 274 | */ 275 | public function getEmail() 276 | { 277 | return $this->email; 278 | } 279 | 280 | /** 281 | * set QueriedAt 282 | * 283 | * @param \DateTime $queriedAt 284 | * 285 | * @return object 286 | */ 287 | public function setQueriedAt(\DateTime $queriedAt = null) 288 | { 289 | $this->queriedAt = $queriedAt; 290 | 291 | return $this; 292 | } 293 | 294 | /** 295 | * get QueriedAt 296 | * 297 | * @return \DateTime $queriedAt 298 | */ 299 | public function getQueriedAt() 300 | { 301 | return $this->queriedAt; 302 | } 303 | 304 | /** 305 | * Import object properties from an associative array 306 | * 307 | * @param array $arr An associative array 308 | */ 309 | public function fromArray(array $arr) 310 | { 311 | foreach ($arr as $key => $value) { 312 | $method = 'set' . $key; 313 | if (method_exists($this, $method)) { 314 | $this->$method($value); 315 | } 316 | } 317 | } 318 | 319 | /** 320 | * Export the object properties to an associative array 321 | * 322 | * @return array An associative array 323 | */ 324 | public function toArray() 325 | { 326 | $arr = array(); 327 | foreach ($this as $key => $value) { 328 | $method = 'get' . $key; 329 | if (method_exists($this, $method)) { 330 | $arr[$key] = $this->$method(); 331 | } 332 | } 333 | 334 | return $arr; 335 | } 336 | } 337 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/API.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra; 14 | 15 | use YDD\Vebra\Exception\XMLParsingException, 16 | YDD\Vebra\Exception\NoContentException, 17 | YDD\Vebra\Exception\NotModifiedException, 18 | YDD\Vebra\Exception\UnauthorizedException, 19 | YDD\Vebra\Exception\ForbiddenException, 20 | YDD\Vebra\Exception\NotFoundException, 21 | YDD\Vebra\Exception\GoneException, 22 | YDD\Vebra\Exception\InternalServerErrorException, 23 | YDD\Vebra\Exception\NotImplementedException, 24 | YDD\Vebra\Exception\UnknownStatusCodeException 25 | ; 26 | 27 | use YDD\Vebra\TokenStorage\TokenStorageInterface; 28 | 29 | use Buzz\Client\ClientInterface, 30 | Buzz\Message\Factory\FactoryInterface, 31 | Buzz\Message\Response, 32 | Buzz\Exception\InvalidArgumentException 33 | ; 34 | 35 | use YDD\Vebra\Model\BranchSummary, 36 | YDD\Vebra\Model\Branch, 37 | YDD\Vebra\Model\PropertySummary, 38 | YDD\Vebra\Model\Property, 39 | YDD\Vebra\Model\Address, 40 | YDD\Vebra\Model\Price, 41 | YDD\Vebra\Model\Area, 42 | YDD\Vebra\Model\EnergyRatingPair, 43 | YDD\Vebra\Model\Paragraph, 44 | YDD\Vebra\Model\Dimension, 45 | YDD\Vebra\Model\Bullet, 46 | YDD\Vebra\Model\File, 47 | YDD\Vebra\Model\LandArea, 48 | YDD\Vebra\Model\StreetView, 49 | YDD\Vebra\Model\ChangedPropertySummary, 50 | YDD\Vebra\Model\ChangedFileSummary 51 | ; 52 | 53 | /** 54 | * An implementation of the Vebra API 55 | */ 56 | class API 57 | { 58 | const HOST = 'http://webservices.vebra.com'; 59 | 60 | protected $baseUrl; 61 | protected $dataFeedId; 62 | protected $username; 63 | protected $password; 64 | protected $tokenStorage; 65 | protected $client; 66 | protected $messageFactory; 67 | 68 | /** 69 | * Constructor 70 | * 71 | * @param string $dataFeedId The data feed ID 72 | * @param string $username The username 73 | * @param string $password The password 74 | * @param TokenStorageInterface $tokenStorage The client storage 75 | * @param ClientInterface $client The client 76 | * @param FactoryInterface $messageFactory The message factory 77 | * @param string $feedVersion The feed version 78 | */ 79 | public function __construct($dataFeedId, $username, $password, TokenStorageInterface $tokenStorage, ClientInterface $client, FactoryInterface $messageFactory, $feedVersion = 'v9') 80 | { 81 | $this->baseUrl = sprintf('/export/%s/'.$feedVersion.'/', $dataFeedId); 82 | $this->dataFeedId = $dataFeedId; 83 | $this->username = $username; 84 | $this->password = $password; 85 | $this->tokenStorage = $tokenStorage; 86 | $this->client = $client; 87 | $this->messageFactory = $messageFactory; 88 | } 89 | 90 | /** 91 | * execute 92 | * 93 | * @param string $url The URL 94 | * @param Boolean $secondAttempt If the request is the second attempt (after re-authentication due to a 401) 95 | * 96 | * @throws XMLParsingException 97 | * @throws NoContentException 98 | * @throws NotModifiedException 99 | * @throws UnauthorizedException 100 | * @throws ForbiddenException 101 | * @throws NotFoundException 102 | * @throws GoneException 103 | * @throws InternalServerErrorException 104 | * @throws NotImplementedException 105 | * @throws UnknownStatusCodeException 106 | * 107 | * @return \SimpleXMLElement 108 | */ 109 | public function execute($url, $secondAttempt = false) 110 | { 111 | if (!is_string($url) || empty($url)) { 112 | throw new \InvalidArgumentException('URL must be a non-empty string.'); 113 | } 114 | 115 | $request = $this->messageFactory->createRequest('GET', $this->baseUrl . $url, self::HOST); 116 | $request->addHeader('Authorization: Basic ' . base64_encode($this->tokenStorage->getToken())); 117 | $response = $this->messageFactory->createResponse(); 118 | $this->client->send($request, $response); 119 | 120 | switch ($response->getStatusCode()) { 121 | // All okay 122 | case 200: 123 | // Return a SimpleXMLElement created from the response 124 | $saved = libxml_use_internal_errors(true); 125 | $xml = simplexml_load_string($response->getContent()); 126 | $errors = libxml_get_errors(); 127 | libxml_clear_errors(); 128 | libxml_use_internal_errors($saved); 129 | 130 | if ($errors) { 131 | throw new XMLParsingException($errors); 132 | } 133 | 134 | return $xml; 135 | break; 136 | 137 | // No content 138 | case 204: 139 | throw new NoContentException; 140 | break; 141 | 142 | // Not modified 143 | case 304: 144 | throw new NotModifiedException; 145 | break; 146 | 147 | // Unauthorized 148 | case 401: 149 | if ($secondAttempt) { 150 | throw new UnauthorizedException; 151 | } 152 | 153 | // The token may have expired, request a new token 154 | $tokenRequest = $this->messageFactory->createRequest('GET', $this->baseUrl . 'branch', self::HOST); 155 | $tokenRequest->addHeader('Authorization: Basic ' . base64_encode($this->username.':'.$this->password)); 156 | $tokenResponse = $this->messageFactory->createResponse(); 157 | $this->client->send($tokenRequest, $tokenResponse); 158 | 159 | if (401 === $tokenResponse->getStatusCode()) { 160 | // Unauthorized: current token hasn't expired or invalid credentials 161 | throw new UnauthorizedException; 162 | } 163 | 164 | // save the token 165 | $token = $tokenResponse->getHeader('Token'); 166 | $this->tokenStorage->setToken(trim($token)); 167 | 168 | // try again 169 | return $this->execute($url, true); 170 | break; 171 | 172 | // Forbidden 173 | case 403: 174 | throw new ForbiddenException; 175 | break; 176 | 177 | // Not found 178 | case 404: 179 | throw new NotFoundException; 180 | break; 181 | 182 | // Gone 183 | case 410: 184 | throw new GoneException; 185 | break; 186 | 187 | // Internal Server Error 188 | case 500: 189 | throw new InternalServerErrorException; 190 | break; 191 | 192 | // Not implemented 193 | case 501: 194 | throw new NotImplementedException; 195 | break; 196 | 197 | // Unknown status code 198 | default: 199 | throw new UnknownStatusCodeException; 200 | break; 201 | } 202 | } 203 | 204 | 205 | /** 206 | * get Branches 207 | * 208 | * @return array 209 | */ 210 | public function getBranches() 211 | { 212 | $branches = array(); 213 | 214 | $xml = $this->execute('branch'); 215 | 216 | foreach ($xml->branch as $xmlBranch) { 217 | $branch = new BranchSummary; 218 | $branch->setName(self::normalise($xmlBranch->name, 'string')); 219 | $branch->setFirmId(self::normalise($xmlBranch->firmid, 'int')); 220 | $branch->setBranchId(self::normalise($xmlBranch->branchid, 'int')); 221 | $branch->setUrl(self::normalise($xmlBranch->url, 'string')); 222 | $branches[] = $branch; 223 | } 224 | 225 | return $branches; 226 | } 227 | 228 | /** 229 | * get Branch 230 | * 231 | * @param int $clientId The client ID 232 | * 233 | * @throws \InvalidArgumentException 234 | * 235 | * @return Branch 236 | */ 237 | public function getBranch($clientId) 238 | { 239 | if (!is_int($clientId)) { 240 | throw new \InvalidArgumentException('Client ID must be an integer.'); 241 | } 242 | 243 | $xml = $this->execute(sprintf('branch/%s', $clientId)); 244 | 245 | $branch = new Branch; 246 | $branch->setClientId($clientId); 247 | $branch->setFirmId(self::normalise($xml{'FirmID'}, 'int')); 248 | $branch->setBranchId(self::normalise($xml->{'BranchID'}, 'int')); 249 | $branch->setName(self::normalise($xml->name, 'string')); 250 | $branch->setStreet(self::normalise($xml->street, 'string')); 251 | $branch->setTown(self::normalise($xml->town, 'string')); 252 | $branch->setCounty(self::normalise($xml->county, 'string')); 253 | $branch->setPostcode(self::normalise($xml->postcode, 'string')); 254 | $branch->setPhone(self::normalise($xml->phone, 'string')); 255 | $branch->setEmail(self::normalise($xml->email, 'string')); 256 | 257 | return $branch; 258 | } 259 | 260 | /** 261 | * get PropertyList 262 | * 263 | * @param int $clientId The client ID 264 | * 265 | * @throws \InvalidArgumentException 266 | * 267 | * @return array 268 | */ 269 | public function getPropertyList($clientId) 270 | { 271 | if (!is_int($clientId)) { 272 | throw new \InvalidArgumentException('Client ID must be an integer.'); 273 | } 274 | 275 | $properties = array(); 276 | 277 | $xml = $this->execute(sprintf('branch/%d/property', $clientId)); 278 | 279 | foreach ($xml->property as $xmlProperty) { 280 | $property = new PropertySummary; 281 | $property->setPropId(self::normalise($xmlProperty->{'prop_id'}, 'int')); 282 | $property->setLastChanged(self::normalise($xmlProperty->lastchanged, 'datetime')); 283 | $property->setUrl(self::normalise($xmlProperty->url, 'string')); 284 | $properties[] = $property; 285 | } 286 | 287 | return $properties; 288 | } 289 | 290 | /** 291 | * get Property 292 | * 293 | * @param int $clientId The client ID 294 | * @param int $propertyId The property ID 295 | * 296 | * @throws \InvalidArgumentException 297 | * 298 | * @return Property 299 | */ 300 | public function getProperty($clientId, $propertyId) 301 | { 302 | if (!is_int($clientId)) { 303 | throw new \InvalidArgumentException('Client ID must be an integer.'); 304 | } 305 | 306 | if (!is_int($propertyId)) { 307 | throw new \InvalidArgumentException('Property ID must be an integer.'); 308 | } 309 | 310 | $xml = $this->execute(sprintf('branch/%d/property/%d', $clientId, $propertyId)); 311 | 312 | $property = new Property; 313 | $property->setAttributes($xml->attributes()); 314 | 315 | $property->setAgentReference(self::normalise($xml->reference->agents, 'string')); 316 | 317 | $address = new Address; 318 | $address 319 | ->setName(self::normalise($xml->address->name, 'string')) 320 | ->setStreet(self::normalise($xml->address->street, 'string')) 321 | ->setLocality(self::normalise($xml->address->locality, 'string')) 322 | ->setTown(self::normalise($xml->address->town, 'string')) 323 | ->setCounty(self::normalise($xml->address->county, 'string')) 324 | ->setPostcode(self::normalise($xml->address->postcode, 'string')) 325 | ->setCustomLocation(self::normalise($xml->address->custom_location, 'string')) 326 | ->setDisplay(self::normalise($xml->address->display, 'string')); 327 | 328 | $property->setAddress($address); 329 | 330 | $price = new Price(self::normalise($xml->price, 'int')); 331 | $price->setAttributes($xml->price->attributes()); 332 | $property->setPrice($price); 333 | 334 | $property->setRentalFees(self::normalise($xml->rentalfees, 'string')); 335 | $property->setLettingsFee(self::normalise($xml->lettingsfee, 'string')); 336 | $property->setRmQualifier(self::normalise($xml->{'rm_qualifier'}, 'int')); 337 | $property->setAvailable(self::normalise($xml->available, 'string')); 338 | $property->setUploaded(self::normalise($xml->uploaded, 'string')); 339 | $property->setLongitude(self::normalise($xml->longitude, 'float')); 340 | $property->setLatitude(self::normalise($xml->latitude, 'float')); 341 | $property->setEasting(self::normalise($xml->easting, 'int')); 342 | $property->setNorthing(self::normalise($xml->northing, 'int')); 343 | $property->setWebStatus(self::normalise($xml->{'web_status'}, 'int')); 344 | $property->setCustomStatus(self::normalise($xml->{'custom_status'}, 'string')); 345 | $property->setCommRent(self::normalise($xml->{'comm_rent'}, 'string')); 346 | $property->setPremium(self::normalise($xml->premium, 'string')); 347 | $property->setServiceCharge(self::normalise($xml->{'service_charge'}, 'string')); 348 | $property->setRateableValue(self::normalise($xml->{'rateable_value'}, 'string')); 349 | $property->setType(self::normalise($xml->type, 'string')); 350 | $property->setFurnished(self::normalise($xml->furnished, 'int')); 351 | $property->setRmType(self::normalise($xml->{'rm_type'}, 'int')); 352 | $property->setLetBond(self::normalise($xml->{'let_bond'}, 'int')); 353 | $property->setRmLetTypeId(self::normalise($xml->{'rm_let_type_id'}, 'int')); 354 | $property->setBedrooms(self::normalise($xml->bedrooms, 'int')); 355 | $property->setReceptions(self::normalise($xml->receptions, 'int')); 356 | $property->setBathrooms(self::normalise($xml->bathrooms, 'int')); 357 | $property->setUserField1(self::normalise($xml->userfield1, 'string')); 358 | $property->setUserField2(self::normalise($xml->userfield2, 'int')); 359 | $property->setSoldDate(self::normalise($xml->solddate, 'datetime')); 360 | $property->setLeaseEnd(self::normalise($xml->leaseend, 'datetime')); 361 | $property->setInstructed(self::normalise($xml->instructed, 'datetime')); 362 | $property->setSoldPrice(self::normalise($xml->soldprice, 'int')); 363 | $property->setGarden(self::normalise($xml->garden, 'boolean')); 364 | $property->setParking(self::normalise($xml->parking, 'boolean')); 365 | $property->setNewBuild(self::normalise($xml->newbuild, 'boolean')); 366 | $property->setGroundRent(self::normalise($xml->groundrent, 'string')); 367 | $property->setCommission(self::normalise($xml->commission, 'string')); 368 | 369 | if ($xml->landarea) { 370 | $landArea = new LandArea( 371 | self::normalise($xml->landarea->area, 'float') 372 | ); 373 | $landArea->setAttributes($xml->landarea->attributes()); 374 | $property->setLandArea($landArea); 375 | } 376 | 377 | $property->setStreetView( 378 | new StreetView( 379 | self::normalise($xml->streetview->pov_latitude, 'float'), 380 | self::normalise($xml->streetview->pov_longitude, 'float'), 381 | self::normalise($xml->streetview->pov_pitch, 'float'), 382 | self::normalise($xml->streetview->pov_heading, 'float'), 383 | self::normalise($xml->streetview->pov_zoom, 'int') 384 | ) 385 | ); 386 | 387 | $arr = array(); 388 | foreach ($xml->area as $a) { 389 | $area = new Area( 390 | self::normalise($a->min, 'float'), 391 | self::normalise($a->max, 'float') 392 | ); 393 | $area->setAttributes($a->attributes()); 394 | $arr[] = $area; 395 | } 396 | $property->setArea($arr); 397 | 398 | $property->setDescription(self::normalise($xml->description, 'string')); 399 | 400 | $property->setEnergyEfficiency( 401 | new EnergyRatingPair( 402 | self::normalise($xml->hip->energy_performance->energy_efficiency->current, 'int'), 403 | self::normalise($xml->hip->energy_performance->energy_efficiency->potential, 'int') 404 | ) 405 | ); 406 | 407 | $property->setEnvironmentalImpact( 408 | new EnergyRatingPair( 409 | self::normalise($xml->hip->energy_performance->environmental_impact->current, 'int'), 410 | self::normalise($xml->hip->energy_performance->environmental_impact->potential, 'int') 411 | ) 412 | ); 413 | 414 | $arr = array(); 415 | foreach ($xml->paragraphs->paragraph as $p) { 416 | 417 | $paragraph = new Paragraph; 418 | $paragraph->setName(self::normalise($p->name, 'string')); 419 | $paragraph->setFile(self::normalise($p->file->attributes()['ref'], 'int')); 420 | $paragraph->setDimension( 421 | new Dimension( 422 | self::normalise($p->dimensions->metric, 'string'), 423 | self::normalise($p->dimensions->imperial, 'string'), 424 | self::normalise($p->dimensions->mixed, 'string') 425 | ) 426 | ); 427 | $paragraph->setText(self::normalise($p->text, 'string')); 428 | $paragraph->setAttributes($p->attributes()); 429 | $arr[] = $paragraph; 430 | } 431 | $property->setParagraphs($arr); 432 | 433 | $arr = array(); 434 | foreach ($xml->bullets->bullet as $b) { 435 | $bullet = new Bullet(self::normalise($b, 'string')); 436 | $bullet->setAttributes($b->attributes()); 437 | $arr[$bullet->getAttribute('id')] = $bullet; 438 | } 439 | $property->setBullets($arr); 440 | 441 | $arr = array(); 442 | foreach ($xml->files->file as $f) { 443 | $file = new File; 444 | $file->setName(self::normalise($f->name, 'string')); 445 | $file->setUrl(self::normalise($f->url, 'string')); 446 | $file->setUpdated(self::normalise($f->updated, 'datetime')); 447 | $file->setAttributes($f->attributes()); 448 | $arr[$file->getAttribute('id')] = $file; 449 | } 450 | $property->setFiles($arr); 451 | 452 | return $property; 453 | } 454 | 455 | /** 456 | * get ChangedProperties 457 | * 458 | * @param \DateTime $date The changed date 459 | * 460 | * @return array 461 | */ 462 | public function getChangedProperties(\DateTime $date) 463 | { 464 | $properties = array(); 465 | 466 | $xml = $this->execute(sprintf('property/%s', $date->format('Y/m/d/H/i/s'))); 467 | 468 | foreach ($xml->property as $xmlProperty) { 469 | $property = new ChangedPropertySummary; 470 | $property->setPropId(self::normalise($xmlProperty->propid, 'int')); 471 | $property->setLastChanged(self::normalise($xmlProperty->lastchanged, 'datetime')); 472 | $property->setLastAction(self::normalise($xmlProperty->action, 'string')); 473 | $property->setUrl(self::normalise($xmlProperty->url, 'string')); 474 | $properties[] = $property; 475 | } 476 | 477 | return $properties; 478 | } 479 | 480 | /** 481 | * get ChangedFiles 482 | * 483 | * @param \DateTime $date The changed date 484 | * 485 | * @return array 486 | */ 487 | public function getChangedFiles(\DateTime $date) 488 | { 489 | $files = array(); 490 | 491 | $xml = $this->execute(sprintf('files/%s', $date->format('Y/m/d/H/i/s'))); 492 | 493 | foreach ($xml->file as $xmlFile) { 494 | $file = new ChangedFileSummary; 495 | $file->setFileId(self::normalise($xmlFile->{'file_id'}, 'int')); 496 | $file->setFilePropId(self::normalise($xmlFile->{'file_propid'}, 'int')); 497 | $file->setLastChanged(self::normalise($xmlFile->updated, 'datetime')); 498 | $file->setIsDeleted(self::normalise($xmlFile->deleted, 'bool')); 499 | $file->setUrl(self::normalise($xmlFile->url, 'string')); 500 | $file->setPropUrl(self::normalise($xmlFile->{'prop_url'}, 'string')); 501 | $files[] = $file; 502 | } 503 | 504 | return $files; 505 | } 506 | 507 | /** 508 | * normalise 509 | * 510 | * @param \SimpleXMLElement $xml The xml element 511 | * @param string $cast The type to cast to 512 | * 513 | * @return mixed 514 | */ 515 | protected static function normalise($xml, $cast = null) 516 | { 517 | if (!$xml || empty($xml)) { 518 | return null; 519 | } 520 | 521 | switch (strtolower($cast)) { 522 | case 'string': 523 | return (string) $xml; 524 | case 'integer': 525 | case 'int': 526 | return (int) $xml; 527 | case 'float': 528 | return (float) $xml; 529 | case 'boolean': 530 | case 'bool': 531 | return (string) $xml === 'true'; 532 | case 'datetime': 533 | return new \DateTime((string) $xml); 534 | default: 535 | return $xml; 536 | } 537 | } 538 | } 539 | -------------------------------------------------------------------------------- /lib/YDD/Vebra/Model/Property.php: -------------------------------------------------------------------------------- 1 | and Matthew Davis 7 | 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace YDD\Vebra\Model; 14 | 15 | /** 16 | * Property 17 | */ 18 | class Property extends AttributedModel 19 | { 20 | protected static $attributeTypeMapping = array( 21 | 'id' => 'int', 22 | 'propertyid' => 'int', 23 | 'system' => 'string', 24 | 'firmid' => 'int', 25 | 'branchid' => 'int', 26 | 'database' => 'int', 27 | 'featured' => 'bool' 28 | ); 29 | 30 | protected $agentReference; // varchar 30 31 | protected $address; // Address 32 | protected $price; // Price 33 | protected $rentalFees; // varchar 400 34 | protected $lettingsFee; // varchar 4000 35 | protected $rmQualifier; // enum 36 | protected $available; // string 37 | protected $uploaded; // string 38 | protected $longitude; // float 39 | protected $latitude; // float 40 | protected $easting; // int 41 | protected $northing; // int 42 | protected $streetView; // StreetView 43 | protected $webStatus; // enum 44 | protected $customStatus; // varchar 30 45 | protected $commRent; // varchar 30 46 | protected $premium; // varchar 30 47 | protected $serviceCharge; // varchar 30 48 | protected $rateableValue; // varchar 30 49 | protected $type; // varchar 50 50 | protected $furnished; // enum 51 | protected $rmType; // int 52 | protected $letBond; // int 53 | protected $rmLetTypeId; // enum 54 | protected $bedrooms; // int 55 | protected $receptions; // int 56 | protected $bathrooms; // int 57 | protected $userField1; // varchar 150 58 | protected $userField2; // int 59 | protected $soldDate; // date 60 | protected $leaseEnd; // date 61 | protected $instructed; // date 62 | protected $soldPrice; // int 63 | protected $garden; // boolean 64 | protected $parking; // boolean 65 | protected $newBuild; // boolean 66 | protected $groundRent; // varchar 50 67 | protected $commission; // varchar 30 68 | protected $area; // Area 69 | protected $landArea; // LandArea 70 | protected $description; // varchar 71 | protected $energyEfficiency; // EnergyRatingPair 72 | protected $environmentalImpact; // EnergyRatingPair 73 | protected $paragraphs; // array 74 | protected $bullets; // array (max 12) 75 | protected $files; // array 76 | protected $queriedAt; 77 | 78 | /** 79 | * Constructor 80 | */ 81 | public function __construct() 82 | { 83 | parent::__construct(); 84 | 85 | $this->setQueriedAt(new \DateTime); 86 | } 87 | 88 | /** 89 | * get AgentReference 90 | * 91 | * @return string $agentReference 92 | */ 93 | public function getAgentReference() 94 | { 95 | return $this->agentReference; 96 | } 97 | 98 | /** 99 | * set AgentReference 100 | * 101 | * @param string $agentReference 102 | * 103 | * @return object 104 | */ 105 | public function setAgentReference($agentReference) 106 | { 107 | $this->agentReference = $agentReference; 108 | 109 | return $this; 110 | } 111 | 112 | /** 113 | * get Address 114 | * 115 | * @return Address $address 116 | */ 117 | 118 | public function getAddress() 119 | { 120 | return $this->address; 121 | } 122 | 123 | /** 124 | * set Address 125 | * 126 | * @param Address $address 127 | * 128 | * @return object 129 | */ 130 | public function setAddress(Address $address) 131 | { 132 | $this->address = $address; 133 | 134 | return $this; 135 | } 136 | 137 | /** 138 | * get Price 139 | * 140 | * @return Price $price 141 | */ 142 | public function getPrice() 143 | { 144 | return $this->price; 145 | } 146 | 147 | /** 148 | * set Price 149 | * 150 | * @param Price $price 151 | * 152 | * @return object 153 | */ 154 | public function setPrice(Price $price) 155 | { 156 | $this->price = $price; 157 | 158 | return $this; 159 | } 160 | 161 | /** 162 | * get RentalFees 163 | * 164 | * @return string $rentalFees 165 | */ 166 | public function getRentalFees() 167 | { 168 | return $this->rentalFees; 169 | } 170 | 171 | /** 172 | * set RentalFees 173 | * 174 | * @param string $rentalFees 175 | * 176 | * @return object 177 | */ 178 | public function setRentalFees($rentalFees) 179 | { 180 | $this->rentalFees = $rentalFees; 181 | 182 | return $this; 183 | } 184 | 185 | /** 186 | * get LettingsFee 187 | * 188 | * @return string $lettingsFee 189 | */ 190 | public function getLettingsFee() 191 | { 192 | return $this->lettingsFee; 193 | } 194 | 195 | /** 196 | * set LettingsFee 197 | * 198 | * @param string $lettingsFee 199 | * 200 | * @return object 201 | */ 202 | public function setLettingsFee($lettingsFee) 203 | { 204 | $this->lettingsFee = $lettingsFee; 205 | 206 | return $this; 207 | } 208 | 209 | /** 210 | * get RmQualifier 211 | * 212 | * @return int $rmQualifier 213 | */ 214 | public function getRmQualifier() 215 | { 216 | return $this->rmQualifier; 217 | } 218 | 219 | /** 220 | * set RmQualifier 221 | * 222 | * @param int $rmQualifier 223 | * 224 | * @return object 225 | */ 226 | public function setRmQualifier($rmQualifier) 227 | { 228 | $this->rmQualifier = (int) $rmQualifier; 229 | 230 | return $this; 231 | } 232 | 233 | /** 234 | * get Available 235 | * 236 | * @return string $available 237 | */ 238 | public function getAvailable() 239 | { 240 | return $this->available; 241 | } 242 | 243 | /** 244 | * set Available 245 | * 246 | * @param string $available 247 | * 248 | * @return object 249 | */ 250 | public function setAvailable($available) 251 | { 252 | $this->available = $available; 253 | 254 | return $this; 255 | } 256 | 257 | /** 258 | * get Uploaded 259 | * 260 | * @return string $uploaded 261 | */ 262 | public function getUploaded() 263 | { 264 | return $this->uploaded; 265 | } 266 | 267 | /** 268 | * set Uploaded 269 | * 270 | * @param string $uploaded 271 | * 272 | * @return object 273 | */ 274 | public function setUploaded($uploaded) 275 | { 276 | $this->uploaded = $uploaded; 277 | 278 | return $this; 279 | } 280 | 281 | /** 282 | * get Longitude 283 | * 284 | * @return float $longitude 285 | */ 286 | public function getLongitude() 287 | { 288 | return $this->longitude; 289 | } 290 | 291 | /** 292 | * set Longitude 293 | * 294 | * @param float $longitude 295 | * 296 | * @return object 297 | */ 298 | public function setLongitude($longitude) 299 | { 300 | $this->longitude = (float) $longitude; 301 | 302 | return $this; 303 | } 304 | 305 | /** 306 | * get Latitude 307 | * 308 | * @return float $latitude 309 | */ 310 | public function getLatitude() 311 | { 312 | return $this->latitude; 313 | } 314 | 315 | /** 316 | * set Latitude 317 | * 318 | * @param float $latitude 319 | * 320 | * @return object 321 | */ 322 | public function setLatitude($latitude) 323 | { 324 | $this->latitude = (float) $latitude; 325 | 326 | return $this; 327 | } 328 | 329 | /** 330 | * get Easting 331 | * 332 | * @return int $easting 333 | */ 334 | public function getEasting() 335 | { 336 | return $this->easting; 337 | } 338 | 339 | /** 340 | * set Easting 341 | * 342 | * @param int $easting 343 | * 344 | * @return object 345 | */ 346 | public function setEasting($easting) 347 | { 348 | $this->easting = (int) $easting; 349 | 350 | return $this; 351 | } 352 | 353 | /** 354 | * get Northing 355 | * 356 | * @return int $northing 357 | */ 358 | public function getNorthing() 359 | { 360 | return $this->northing; 361 | } 362 | 363 | /** 364 | * set Northing 365 | * 366 | * @param int $northing 367 | * 368 | * @return object 369 | */ 370 | public function setNorthing($northing) 371 | { 372 | $this->northing = (int) $northing; 373 | 374 | return $this; 375 | } 376 | 377 | /** 378 | * get StreetView 379 | * 380 | * @return StreetView $streetView 381 | */ 382 | public function getStreetView() 383 | { 384 | return $this->streetView; 385 | } 386 | 387 | /** 388 | * set StreetView 389 | * 390 | * @param StreetView $streetView 391 | * 392 | * @return object 393 | */ 394 | public function setStreetView(StreetView $streetView) 395 | { 396 | $this->streetView = $streetView; 397 | 398 | return $this; 399 | } 400 | 401 | /** 402 | * get WebStatus 403 | * 404 | * @return int $webStatus 405 | */ 406 | public function getWebStatus() 407 | { 408 | return $this->webStatus; 409 | } 410 | 411 | /** 412 | * set WebStatus 413 | * 414 | * @param int $webStatus 415 | * 416 | * @return object 417 | */ 418 | public function setWebStatus($webStatus) 419 | { 420 | $this->webStatus = (int) $webStatus; 421 | 422 | return $this; 423 | } 424 | 425 | /** 426 | * get CustomStatus 427 | * 428 | * @return $customStatus 429 | */ 430 | public function getCustomStatus() 431 | { 432 | return $this->customStatus; 433 | } 434 | 435 | /** 436 | * set CustomStatus 437 | * 438 | * @param string $customStatus 439 | * 440 | * @return object 441 | */ 442 | public function setCustomStatus($customStatus) 443 | { 444 | $this->customStatus = $customStatus; 445 | 446 | return $this; 447 | } 448 | 449 | /** 450 | * get CommRent 451 | * 452 | * @return string $commRent 453 | */ 454 | public function getCommRent() 455 | { 456 | return $this->commRent; 457 | } 458 | 459 | /** 460 | * set CommRent 461 | * 462 | * @param string $commRent 463 | * 464 | * @return object 465 | */ 466 | public function setCommRent($commRent) 467 | { 468 | $this->commRent = $commRent; 469 | 470 | return $this; 471 | } 472 | 473 | /** 474 | * get Premium 475 | * 476 | * @return string $premium 477 | */ 478 | public function getPremium() 479 | { 480 | return $this->premium; 481 | } 482 | 483 | /** 484 | * set Premium 485 | * 486 | * @param string $premium 487 | * 488 | * @return object 489 | */ 490 | public function setPremium($premium) 491 | { 492 | $this->premium = $premium; 493 | 494 | return $this; 495 | } 496 | 497 | /** 498 | * get ServiceCharge 499 | * 500 | * @return string $serviceCharge 501 | */ 502 | public function getServiceCharge() 503 | { 504 | return $this->serviceCharge; 505 | } 506 | 507 | /** 508 | * set ServiceCharge 509 | * 510 | * @param string $serviceCharge 511 | * 512 | * @return object 513 | */ 514 | public function setServiceCharge($serviceCharge) 515 | { 516 | $this->serviceCharge = $serviceCharge; 517 | 518 | return $this; 519 | } 520 | 521 | /** 522 | * get RateableValue 523 | * 524 | * @return string $rateableValue 525 | */ 526 | public function getRateableValue() 527 | { 528 | return $this->rateableValue; 529 | } 530 | 531 | /** 532 | * set RateableValue 533 | * 534 | * @param string $rateableValue 535 | * 536 | * @return object 537 | */ 538 | public function setRateableValue($rateableValue) 539 | { 540 | $this->rateableValue = $rateableValue; 541 | 542 | return $this; 543 | } 544 | 545 | /** 546 | * get Type 547 | * 548 | * @return string $type 549 | */ 550 | public function getType() 551 | { 552 | return $this->type; 553 | } 554 | 555 | /** 556 | * set Type 557 | * 558 | * @param string $type 559 | * 560 | * @return object 561 | */ 562 | public function setType($type) 563 | { 564 | $this->type = $type; 565 | 566 | return $this; 567 | } 568 | 569 | /** 570 | * get Furnished 571 | * 572 | * @return int $furnished 573 | */ 574 | public function getFurnished() 575 | { 576 | return $this->furnished; 577 | } 578 | 579 | /** 580 | * set Furnished 581 | * 582 | * @param int $furnished 583 | * 584 | * @return object 585 | */ 586 | public function setFurnished($furnished) 587 | { 588 | $this->furnished = (int) $furnished; 589 | 590 | return $this; 591 | } 592 | 593 | /** 594 | * get RmType 595 | * 596 | * @return int $rmType 597 | */ 598 | public function getRmType() 599 | { 600 | return $this->rmType; 601 | } 602 | 603 | /** 604 | * set RmType 605 | * 606 | * @param int $rmType 607 | * 608 | * @return object 609 | */ 610 | public function setRmType($rmType) 611 | { 612 | $this->rmType = (int) $rmType; 613 | 614 | return $this; 615 | } 616 | 617 | /** 618 | * get LetBond 619 | * 620 | * @return int $letBond 621 | */ 622 | public function getLetBond() 623 | { 624 | return $this->letBond; 625 | } 626 | 627 | /** 628 | * set LetBond 629 | * 630 | * @param int $letBond 631 | * 632 | * @return object 633 | */ 634 | public function setLetBond($letBond) 635 | { 636 | $this->letBond = (int) $letBond; 637 | 638 | return $this; 639 | } 640 | 641 | /** 642 | * get RmLetTypeId 643 | * 644 | * @return int $rmLetTypeId 645 | */ 646 | public function getRmLetTypeId() 647 | { 648 | return $this->rmLetTypeId; 649 | } 650 | 651 | /** 652 | * set RmLetTypeId 653 | * 654 | * @param int $rmLetTypeId 655 | * 656 | * @return object 657 | */ 658 | public function setRmLetTypeId($rmLetTypeId) 659 | { 660 | $this->rmLetTypeId = (int) $rmLetTypeId; 661 | 662 | return $this; 663 | } 664 | 665 | /** 666 | * get Bedrooms 667 | * 668 | * @return int $bedrooms 669 | */ 670 | public function getBedrooms() 671 | { 672 | return $this->bedrooms; 673 | } 674 | 675 | /** 676 | * set Bedrooms 677 | * 678 | * @param int $bedrooms 679 | * 680 | * @return int 681 | */ 682 | public function setBedrooms($bedrooms) 683 | { 684 | $this->bedrooms = (int) $bedrooms; 685 | 686 | return $this; 687 | } 688 | 689 | /** 690 | * get Receptions 691 | * 692 | * @return int $receptions 693 | */ 694 | public function getReceptions() 695 | { 696 | return $this->receptions; 697 | } 698 | 699 | /** 700 | * set Receptions 701 | * 702 | * @param int $receptions 703 | * 704 | * @return object 705 | */ 706 | public function setReceptions($receptions) 707 | { 708 | $this->receptions = (int) $receptions; 709 | 710 | return $this; 711 | } 712 | 713 | /** 714 | * get Bathrooms 715 | * 716 | * @return int $bathrooms 717 | */ 718 | public function getBathrooms() 719 | { 720 | return $this->bathrooms; 721 | } 722 | 723 | /** 724 | * set Bathrooms 725 | * 726 | * @param int $bathrooms 727 | * 728 | * @return object 729 | */ 730 | public function setBathrooms($bathrooms) 731 | { 732 | $this->bathrooms = (int) $bathrooms; 733 | 734 | return $this; 735 | } 736 | 737 | /** 738 | * get UserField1 739 | * 740 | * @return string $userField1 741 | */ 742 | public function getUserField1() 743 | { 744 | return $this->userField1; 745 | } 746 | 747 | /** 748 | * set UserField1 749 | * 750 | * @param string $userField1 751 | * 752 | * @return object 753 | */ 754 | public function setUserField1($userField1) 755 | { 756 | $this->userField1 = $userField1; 757 | 758 | return $this; 759 | } 760 | 761 | /** 762 | * get UserField2 763 | * 764 | * @return int $userField2 765 | */ 766 | public function getUserField2() 767 | { 768 | return $this->userField2; 769 | } 770 | 771 | /** 772 | * set UserField2 773 | * 774 | * @param int $userField2 775 | * 776 | * @return object 777 | */ 778 | public function setUserField2($userField2) 779 | { 780 | $this->userField2 = (int) $userField2; 781 | 782 | return $this; 783 | } 784 | 785 | /** 786 | * get SoldDate 787 | * 788 | * @return \DateTime $soldDate 789 | */ 790 | public function getSoldDate() 791 | { 792 | return $this->soldDate; 793 | } 794 | 795 | /** 796 | * set SoldDate 797 | * 798 | * @param \DateTime $soldDate 799 | * 800 | * @return object 801 | */ 802 | public function setSoldDate(\DateTime $soldDate = null) 803 | { 804 | $this->soldDate = $soldDate; 805 | 806 | return $this; 807 | } 808 | 809 | /** 810 | * get LeaseEnd 811 | * 812 | * @return \DateTime $leaseEnd 813 | */ 814 | public function getLeaseEnd() 815 | { 816 | return $this->leaseEnd; 817 | } 818 | 819 | /** 820 | * set LeaseEnd 821 | * 822 | * @param \DateTime $leaseEnd 823 | * 824 | * @return object 825 | */ 826 | public function setLeaseEnd(\DateTime $leaseEnd = null) 827 | { 828 | $this->leaseEnd = $leaseEnd; 829 | 830 | return $this; 831 | } 832 | 833 | /** 834 | * get Instructed 835 | * 836 | * @return \DateTime $instructed 837 | */ 838 | public function getInstructed() 839 | { 840 | return $this->instructed; 841 | } 842 | 843 | /** 844 | * set Instructed 845 | * 846 | * @param \DateTime $instructed 847 | * 848 | * @return object 849 | */ 850 | public function setInstructed(\DateTime $instructed = null) 851 | { 852 | $this->instructed = $instructed; 853 | 854 | return $this; 855 | } 856 | 857 | /** 858 | * get SoldPrice 859 | * 860 | * @return int $soldPrice 861 | */ 862 | public function getSoldPrice() 863 | { 864 | return $this->soldPrice; 865 | } 866 | 867 | /** 868 | * set SoldPrice 869 | * 870 | * @param int $soldPrice 871 | * 872 | * @return object 873 | */ 874 | public function setSoldPrice($soldPrice) 875 | { 876 | $this->soldPrice = (int) $soldPrice; 877 | 878 | return $this; 879 | } 880 | 881 | /** 882 | * get Garden 883 | * 884 | * @return Boolean $garden 885 | */ 886 | public function getGarden() 887 | { 888 | return $this->garden; 889 | } 890 | 891 | /** 892 | * set Garden 893 | * 894 | * @param Boolean $garden 895 | * 896 | * @return object 897 | */ 898 | public function setGarden($garden) 899 | { 900 | $this->garden = (bool) $garden; 901 | 902 | return $this; 903 | } 904 | 905 | /** 906 | * get Parking 907 | * 908 | * @return Boolean $parking 909 | */ 910 | public function getParking() 911 | { 912 | return $this->parking; 913 | } 914 | 915 | /** 916 | * set Parking 917 | * 918 | * @param Boolean $parking 919 | * 920 | * @return object 921 | */ 922 | public function setParking($parking) 923 | { 924 | $this->parking = (bool) $parking; 925 | 926 | return $this; 927 | } 928 | 929 | /** 930 | * get NewBuild 931 | * 932 | * @return Boolean $newBuild 933 | */ 934 | public function getNewBuild() 935 | { 936 | return $this->newBuild; 937 | } 938 | 939 | /** 940 | * set NewBuild 941 | * 942 | * @param Boolean $newBuild 943 | * 944 | * @return object 945 | */ 946 | public function setNewBuild($newBuild) 947 | { 948 | $this->newBuild = (bool) $newBuild; 949 | 950 | return $this; 951 | } 952 | 953 | /** 954 | * get GroundRent 955 | * 956 | * @return string $groundRent 957 | */ 958 | public function getGroundRent() 959 | { 960 | return $this->groundRent; 961 | } 962 | 963 | /** 964 | * set GroundRent 965 | * 966 | * @param string $groundRent 967 | * 968 | * @return object 969 | */ 970 | public function setGroundRent($groundRent) 971 | { 972 | $this->groundRent = $groundRent; 973 | 974 | return $this; 975 | } 976 | 977 | /** 978 | * get Commission 979 | * 980 | * @return string $commission 981 | */ 982 | public function getCommission() 983 | { 984 | return $this->commission; 985 | } 986 | 987 | /** 988 | * set Commission 989 | * 990 | * @param string $commission 991 | * 992 | * @return object 993 | */ 994 | public function setCommission($commission) 995 | { 996 | $this->commission = $commission; 997 | 998 | return $this; 999 | } 1000 | 1001 | /** 1002 | * get Area 1003 | * 1004 | * @return array $area 1005 | */ 1006 | public function getArea() 1007 | { 1008 | return $this->area; 1009 | } 1010 | 1011 | /** 1012 | * set Area 1013 | * 1014 | * @param array $area 1015 | * 1016 | * @return object 1017 | */ 1018 | public function setArea(array $area) 1019 | { 1020 | $this->area = $area; 1021 | 1022 | return $this; 1023 | } 1024 | 1025 | /** 1026 | * get LandArea 1027 | * 1028 | * @return LandArea $landArea 1029 | */ 1030 | public function getLandArea() 1031 | { 1032 | return $this->landArea; 1033 | } 1034 | 1035 | /** 1036 | * set LandArea 1037 | * 1038 | * @param LandArea $landArea 1039 | * 1040 | * @return object 1041 | */ 1042 | public function setLandArea(LandArea $landArea) 1043 | { 1044 | $this->landArea = $landArea; 1045 | 1046 | return $this; 1047 | } 1048 | 1049 | /** 1050 | * get Description 1051 | * 1052 | * @return string $description 1053 | */ 1054 | public function getDescription() 1055 | { 1056 | return $this->description; 1057 | } 1058 | 1059 | /** 1060 | * set Description 1061 | * 1062 | * @param string $description 1063 | * 1064 | * @return object 1065 | */ 1066 | public function setDescription($description) 1067 | { 1068 | $this->description = $description; 1069 | 1070 | return $this; 1071 | } 1072 | 1073 | /** 1074 | * get EnergyEfficiency 1075 | * 1076 | * @return EnergyRatingPair $energyEfficiency 1077 | */ 1078 | public function getEnergyEfficiency() 1079 | { 1080 | return $this->energyEfficiency; 1081 | } 1082 | 1083 | /** 1084 | * set EnergyEfficiency 1085 | * 1086 | * @param EnergyRatingPair $energyEfficiency 1087 | * 1088 | * @return object 1089 | */ 1090 | public function setEnergyEfficiency(EnergyRatingPair $energyEfficiency) 1091 | { 1092 | $this->energyEfficiency = $energyEfficiency; 1093 | 1094 | return $this; 1095 | } 1096 | 1097 | /** 1098 | * get EnvironmentalImpact 1099 | * 1100 | * @return EnergyRatingPair $environmentalImpact 1101 | */ 1102 | public function getEnvironmentalImpact() 1103 | { 1104 | return $this->environmentalImpact; 1105 | } 1106 | 1107 | /** 1108 | * set EnvironmentalImpact 1109 | * 1110 | * @param EnergyRatingPair $environmentalImpact 1111 | * 1112 | * @return object 1113 | */ 1114 | public function setEnvironmentalImpact(EnergyRatingPair $environmentalImpact) 1115 | { 1116 | $this->environmentalImpact = $environmentalImpact; 1117 | 1118 | return $this; 1119 | } 1120 | 1121 | /** 1122 | * get Paragraphs 1123 | * 1124 | * @return array $paragraphs 1125 | */ 1126 | public function getParagraphs() 1127 | { 1128 | return $this->paragraphs; 1129 | } 1130 | 1131 | /** 1132 | * set Paragraphs 1133 | * 1134 | * @param array $paragraphs 1135 | * 1136 | * @return object 1137 | */ 1138 | public function setParagraphs(array $paragraphs) 1139 | { 1140 | $this->paragraphs = $paragraphs; 1141 | 1142 | return $this; 1143 | } 1144 | 1145 | /** 1146 | * get Bullets 1147 | * 1148 | * @return array $bullets 1149 | */ 1150 | public function getBullets() 1151 | { 1152 | return $this->bullets; 1153 | } 1154 | 1155 | /** 1156 | * set Bullets 1157 | * 1158 | * @param array $bullets 1159 | * 1160 | * @return object 1161 | */ 1162 | public function setBullets(array $bullets) 1163 | { 1164 | $this->bullets = $bullets; 1165 | 1166 | return $this; 1167 | } 1168 | 1169 | /** 1170 | * get Files 1171 | * 1172 | * @return array $files 1173 | */ 1174 | public function getFiles() 1175 | { 1176 | return $this->files; 1177 | } 1178 | 1179 | /** 1180 | * set Files 1181 | * 1182 | * @param array $files 1183 | * 1184 | * @return object 1185 | */ 1186 | public function setFiles(array $files) 1187 | { 1188 | $this->files = $files; 1189 | 1190 | return $this; 1191 | } 1192 | 1193 | /** 1194 | * get QueriedAt 1195 | * 1196 | * @return \DateTime $queriedAt 1197 | */ 1198 | public function getQueriedAt() 1199 | { 1200 | return $this->queriedAt; 1201 | } 1202 | 1203 | /** 1204 | * set QueriedAt 1205 | * 1206 | * @param \DateTime $queriedAt 1207 | * 1208 | * @return object 1209 | */ 1210 | public function setQueriedAt(\DateTime $queriedAt = null) 1211 | { 1212 | $this->queriedAt = $queriedAt; 1213 | 1214 | return $this; 1215 | } 1216 | 1217 | /** 1218 | * Import object properties from an associative array 1219 | * 1220 | * @param array $arr An associative array 1221 | */ 1222 | public function fromArray(array $arr) 1223 | { 1224 | foreach ($arr as $key => $value) { 1225 | $method = 'set' . $key; 1226 | if (method_exists($this, $method)) { 1227 | $this->$method($value); 1228 | } 1229 | } 1230 | } 1231 | 1232 | /** 1233 | * Export the object properties to an associative array 1234 | * 1235 | * @return array An associative array 1236 | */ 1237 | public function toArray() 1238 | { 1239 | $arr = array(); 1240 | foreach ($this as $key => $value) { 1241 | $method = 'get' . $key; 1242 | if (method_exists($this, $method)) { 1243 | $arr[$key] = $this->$method(); 1244 | } 1245 | } 1246 | 1247 | return $arr; 1248 | } 1249 | } 1250 | --------------------------------------------------------------------------------