PHP code example of homlity / sdk-homlity
1. Go to this page and download the library: Download homlity/sdk-homlity 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/ */
homlity / sdk-homlity example snippets
omlity\Sdk\Config;
use Homlity\Sdk\Filter\PropertyFilters;
use Homlity\Sdk\HomlityClient;
use Homlity\Sdk\Request\CreateLeadRequest;
$token = $_ENV['HOMLITY_ACCESS_TOKEN'];
$config = Config::forTenantApi($token);
$client = new HomlityClient($config);
$profile = $client->company()->profile();
echo $profile->name();
$channels = $client->channels()->list();
foreach ($channels as $channel) {
echo $channel->id();
echo $channel->name();
}
$categories = $client->tickets()->categories();
foreach ($categories as $category) {
echo $category->id();
echo $category->name();
echo $category->description() ?? '';
echo $category->parentId() ?? '';
}
$properties = $client->properties()->search(new PropertyFilters(
search: 'apartamento Laureles',
propertyTypeIds: [2],
salePriceMin: 300_000_000,
salePriceMax: 700_000_000,
rooms: 3,
page: 1,
perPage: 20,
));
$verification = $client->clients()->verifyDocument('AB-123456', 'CE');
if (!$properties->isEmpty()) {
$result = $client->leads()->create(new CreateLeadRequest(
name: 'Ada Lovelace',
email: '[email protected] ',
propertyId: $properties->items()[0]->id(),
clientId: $verification->client()?->id(),
));
echo $result->lead()->id();
}
omlity\Sdk\Config;
use Homlity\Sdk\HomlityClient;
$sdk = new HomlityClient(new Config(
apiKey: $_ENV['HOMLITY_API_KEY'],
baseUrl: Config::BASE_URL_PRODUCTION,
timeoutSeconds: 30,
));
$clients = $sdk->clients()->all();
$categories = $sdk->categories()->list();
$locations = $sdk->locations()->search('Medellín');
$result = $sdk->listings()->create([
'external_code' => 'INT-0001',
'client_id' => 'df03d199-be5c-4c5c-98f6-849361cb7fae',
'offer' => 'sell',
'property_type' => 'house',
'description' => 'Casa amplia y bien ubicada.',
'price' => 450_000_000,
'area' => 120,
'address' => ['address' => 'Calle 12 # 34-56'],
'locations' => [
'location_point' => ['latitude' => 4.729795079, 'longitude' => -74.044724493],
'location_main_id' => '1895e0a3-60b8-4a9d-858d-f2c7297b48b2',
'view_map' => 2,
],
'listing_contact' => [
'emails' => [['email' => '[email protected] ', 'is_main' => true, 'sort_order' => 0]],
'phones' => [['phone' => '+573001112233', 'sort_order' => 0]],
],
]);
use Homlity\Sdk\Homlity\Config;
use Homlity\Sdk\Homlity\HomlityClient;
$wordpress = new HomlityClient(new Config(
apiKey: $_ENV['HOMLITY_WORDPRESS_TOKEN'],
baseUrl: 'https://inmobiliaria.example.com',
));
$property = [
'id' => '12345',
'code' => 'EXT-12345',
'status' => 'active',
'operation' => 'venta',
'type' => 'apartamento',
'category' => 'residencial',
'media' => ['photos' => [], 'videos' => []],
];
$wordpress->properties()->push([$property]);
$wordpress->properties()->deactivate('EXT-12345');
$wordpress->webhooks()->notify('property.updated', 'EXT-12345');
$report = $wordpress->analytics()->report(['range' => 30, 'limit' => 20]);
use Homlity\Sdk\Exception\ApiException;
use Homlity\Sdk\Exception\AuthorizationException;
try {
$property = $sdk->properties()->get(123);
} catch (AuthorizationException $error) {
// El token no tiene permiso para este recurso.
} catch (ApiException $error) {
error_log(sprintf(
'Homlity HTTP %s; tracking=%s',
$error->statusCode() ?? 'sin-respuesta',
$error->trackingId() ?? 'n/a',
));
}
bash
composer