Updates - Improved error messages, new inquiry parameters and PHP-SDK 1.0.31

02 May 2016

Improved Error Messages

The JUSTIMMO Api got some much needed improvements on giving feedback for wrong parameters.

RAW API

The API will return errors by setting the http status code to the appropriate value and may return a content with further information on the error.

401 Authentication Failure

Username and/or password are not correct. Status code will have the value 401.

404 Not found

The url you are trying to call could not be found. Status code will have the value 404.

<?xml version="1.0" encoding="UTF-8"?>
<justimmo>
  <error>Ungültige Anfrage</error>
</justimmo>

400 Bad Request

A parameter could not be evaluated or has a not supported value. Status code will have the value 400.

<?xml version="1.0" encoding="UTF-8"?>
<justimmo>
  <error>zimmer_von ["test" is not a number.]</error>
</justimmo>

500 Server Error

Internal JUSTIMMO error. Status code will have the value 500.

<?xml version="1.0" encoding="UTF-8"?>
<justimmo>
  <error>Internal Server Error</error>
</justimmo>

PHP-SDK

To reflect those changes the PHP-SDK uses new exceptions. All SDK related exceptions implement the Justimmo\Exception\JustimmoException to let you catch all SDK exceptions thrown by the SDK.

<?php

try {
    //...
    $query->find();
    //...
} catch (\Justimmo\Exception\InvalidRequestException $e) {
    //bad request format oder filter parameter, example output "zimmer_von ["test" is not a number.]"
    echo $e->getMessage();
} catch (\Justimmo\Exception\JustimmoException $e) {
    //other sdk exception
} catch (\Exception $e) {
    //exception not thrown by SDK if JustimmoException is previously catched
}

Available Exceptions

Class Description
Justimmo\Exception\InvalidRequestException Thrown if api returns a statuscode between 400 and 499 due to invalid request data
Justimmo\Exception\AuthenticationException Thrown if SDK could not login
Justimmo\Exception\NotFoundException API returned a 404 Error, eg. Realty detail request could not find a realty matching the given id
Justimmo\Exception\StatusCodeException API returned a non successfull status code which is not handled by any of the other exceptions
Justimmo\Exception\MethodNotFoundException Thrown by most magic methods like toKeyValue() if method was not found on the model object
Justimmo\Exception\AttachmentSizeNotFoundException Thrown by $attachment->getUrl() if $size has not been found
Justimmo\Exception\JustimmoException Interface to catch all SDK related exceptions

New Inquiry Parameters

Realty Inquiries now support title and salutations.

RAW API

Use titel for title and andrede_id for salutations.

https://api.justimmo.at/rest/v1/objekt/anfrage?objekt_id=123456&titel=Dr&anrede_id=1&vorname=Test&nachname=Ttest&email=test%40gmail.com&tel=123456&message=Ich+interessiere+mich+f%C3%BCr+das+Angebot

PHP-SDK

<?php
//...
$inquiry->setTitle('Dr.');
$inquiry->setSalutationId(1); //Mr.
//...