Attachments

Attachments have multiple properties

On every model object (Realty, Employee, Project) you can fetch it’s attachment with following methods

<?php
$realty->getPictures();
$realty->getVideos();
$realty->getDocuments();

//you can add a parameter to the methods to filter by different groups

//gets all pictures regardless of the group
$realty->getPictures();

//gets all pictures without a group
$realty->getPictures(null);

//gets all pictures of the group TITELBILD
$realty->getPictures('TITELBILD');

//gets all pictures of the group bilder360
$realty->getPictures('bilder360');

// ...

File Urls

A list of available attachment sizes can be found here.

You can request specific sizes with the setPicturesize function.

$api = new JustimmoApi('xxxxxxxxx', 'xxxxxxxxxxxx');
$api->setBaseUrl('http://api.justimmo.at/rest');
$api->setCulture('de');

$mapper  = new RealtyMapper();
$wrapper = new RealtyWrapper($mapper);

$query  = new RealtyQuery($api, $wrapper, $mapper);

// adds the requested picture sizes, listed at the link above 
$query->setPicturesize(array('big', 'big2'));

//gets an url to an attachment size, but only if the api returned that size
$attachment->getUrl('big');

//gets an url to an attachment size, even if the api does not return that size. BEWARE: this method cannot ensure that the url is a valid ressource
$attachment->calculateUrl('big');

Acquiring the links of a realty

$api = new JustimmoApi('xxxxxxxxx', 'xxxxxxxxxxxx');
$api->setBaseUrl('http://api.justimmo.at/rest');
$api->setCulture('de');

$mapper  = new RealtyMapper();
$wrapper = new RealtyWrapper($mapper);

$query  = new RealtyQuery($api, $wrapper, $mapper);
$realty = $query->findPk(1234567);

/** @var \Justimmo\Model\Attachment $link */
foreach ($realty->getLinks() as $link) {
    var_dump($link);
}

/** @var \Justimmo\Model\Attachment $attachment */
foreach ($realty->getAttachments() as $attachment) {
    if ($attachment->getType() === 'link') {
        var_dump($attachment);
    }
}

Acquiring the links of a residential project

$api = new JustimmoApi('xxxxxxxxx', 'xxxxxxxxxxxx');
$api->setBaseUrl('http://api.justimmo.at/rest');
$api->setCulture('de');

$mapper  = new ProjectMapper();
$wrapper = new ProjectWrapper($mapper);

$query    = new ProjectQuery($api, $wrapper, $mapper);
$project = $query->findPk(1234567);

/** @var \Justimmo\Model\Attachment $link */
foreach ($project->getLinks() as $link) {
    var_dump($link);
}

/** @var \Justimmo\Model\Attachment $attachment */
foreach ($project->getAttachments() as $attachment) {
    if ($attachment->getType() === 'link') {
        var_dump($attachment);
    }
}