PHP code example of fw4 / organimmo-rental-api

1. Go to this page and download the library: Download fw4/organimmo-rental-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fw4 / organimmo-rental-api example snippets


use Organimmo\Rental\Organimmo;

$client = new Organimmo('customer-id');

// Retrieve existing access token from storage (getAccessTokenFromDataStore to be implemented)
$accessToken = getAccessTokenFromDataStore();

if (empty($accessToken) || $accessToken->hasExpired()) {
	// Request and store new access token (saveAccessTokenToDataStore to be implemented)
	$accessToken = $client->requestAccessToken('client-id', 'client-secret', 'username', 'password');
    saveAccessTokenToDataStore($accessToken);
} else {
    $client->setAccessToken($accessToken);
}

$country = $client->countries()->get(1);

if (is_null($country)) echo 'Country does not exist' . PHP_EOL;
else echo $country->name . PHP_EOL;

$countries = $client->countries()->get();

foreach ($countries as $country) {
	echo $country->name . PHP_EOL;
}

$rental_unit_id = 1;
$photos = $client->rentalUnits()->photos($rental_unit_id)->get();

$city = $client->cities()->get(1);
$country = $city->country->get();
echo $country->name . PHP_EOL;

$city = $client->cities()->depth(1)->get(1);
echo $city->country->name . PHP_EOL;

$countries = $client->countries()->sort('name')->get();

$countries = $client->countries()->from(date_create('2020-01-01'))->to(date_create('2020-06-01'))->get();