PHP code example of inigo-aldama / inmovilla-api-client
1. Go to this page and download the library: Download inigo-aldama/inmovilla-api-client 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/ */
inigo-aldama / inmovilla-api-client example snippets
use Inmovilla\ApiClient\ApiClientConfig;
$config = ApiClientConfig::fromIniFile('config/api.ini');
$config = ApiClientConfig::fromArray([
'AGENCY' => 'my-agency',
'PASSWORD' => 'my-password',
'LANGUAGE' => 1,
'API_URL' => 'https://api.inmovilla.com/v1',
'DOMAIN' => 'example.com',
]);
use Inmovilla\Repository\CiudadRepository;
use Inmovilla\Repository\ZonaRepository;
use Inmovilla\Repository\PropiedadRepository;
use Inmovilla\Repository\PropiedadFichaRepository;
$cities = $cityRepository->findAll();
foreach ($cities->items as $city) {
$zones = $zoneRepository->findByCity($city->cod_ciu);
foreach ($zones->items as $zone) {
$properties = $propertyRepository->findByZone($zone->cod_zona);
foreach ($properties->items as $property) {
$details = $propertyDetailsRepository->findOneByCodOffer($property->cod_ofer);
}
}
}
namespace Inmovilla\Repository;
use Inmovilla\DTO\Pagination\PaginacionPropiedadesDTO;
class CustomPropertyRepository extends PropiedadRepository
{
public function findWithElevator(int $startPosition = 1, int $numElements = 100, string $order = 'precioinmo, precioalq'): PaginacionPropiedadesDTO
{
$where = $this->buildWhereClause(['ascensor' => 1]);
$response = $this->addRequest(PaginacionPropiedadesDTO::ARRAY_DATA_KEY, $startPosition, $numElements, $where, $order);
return PaginacionPropiedadesDTO::fromArray($response);
}
}
$customPropertyRepository = new CustomPropertyRepository($client);
$propertiesWithElevator = $customPropertyRepository->findWithElevator();
foreach ($propertiesWithElevator->items as $property) {
echo "Property: Ref=" . $property->ref . PHP_EOL;
}
use Inmovilla\ApiClient\ApiClientConfig;
use Inmovilla\ApiClient\ApiClientFactory;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\HttpFactory;
$config = ApiClientConfig::fromIniFile('config/api.ini');
$httpClient = new GuzzleClient();
$requestFactory = new HttpFactory();
$client = ApiClientFactory::createFromConfig($config, $httpClient, $requestFactory);
$request = new Request('properties', 1, 100, 'ascensor=1', 'precioinmo, precioalq');
$requestBatch = new RequestBatch();
$requestBatch->addRequest($request);
$response = $client->sendRequest($requestBatch);
foreach ($response['properties'] as $property) {
echo "Property: Ref=" . $property['ref'] . PHP_EOL;
}