PHP code example of kenny-mgn / profitbase-php-client
1. Go to this page and download the library: Download kenny-mgn/profitbase-php-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/ */
kenny-mgn / profitbase-php-client example snippets
use KennyMgn\ProfitbaseClient\ProfitbaseClient;
try {
$client = ProfitbaseClient::create('your-api-key', 'https://pbXXXXX.profitbase.ru/api/v4/json');
$response = $client->houses();
$jsonString = $response->getBody()->getContents();
$arrayResult = json_decode($jsonString, associative: true);
} catch (Throwable $throwable) {
echo $throwable->getMessage();
}
# HTTP статус ответа
$response->getStatusCode();
# Тело ответа
$body = $response->getBody();
# Читаем всё содержимое в память
$jsonString = $body->getContents();
public function specialOffers(
?bool $isArchived = null,
?bool $isDiscounted = null,
array $queryParams = []
)
$queryParams = ['ids[]' => [1, 2, 3]];
$client = ProfitbaseClient::create($apiKey, $baseEndpoint);
$response = $client->properties(['status[]' => ['AVAILABLE', 'BOOKED']]);
$client = ProfitbaseClient::create(
$apiKey,
$baseEndpoint,
[
'timeout' => 20,
'headers' => ['X-Custom-Header' => 'value'],
]
);
use Cerbero\JsonParser\JsonParser;
use KennyMgn\ProfitbaseClient\ProfitbaseClient;
try {
$client = ProfitbaseClient::create($apiKey, $baseEndpoint);
$response = $client->houses();
$stream = $response->getBody();
JsonParser::parse($stream)->traverse(function (mixed $value, string|int $key, JsonParser $parser) {
// Действия
});
} catch (Throwable $throwable) {
echo $throwable->getMessage();
}
$client = ProfitbaseClient::create($apiKey, $baseEndpoint, ['stream' => false]);
$client->limitRequestRateTo(2);
auth(string $apiKey): ResponseInterface
$client->auth('app-some-key');
houses(array $queryParams = []): ResponseInterface
$client->houses(['isArchive' => false]);
houseFloorCount(int $houseID, array $queryParams = []): ResponseInterface
$client->houseFloorCount(houseID: 12345);
houseFloorPropertyCount(int $houseID, int $floor, array $queryParams = []): ResponseInterface
$client->houseFloorPropertyCount(houseID: 12345, floor: 5);
housesLegacyV3(int $projectID, array $queryParams = []): ResponseInterface
$client->housesLegacyV3(projectID: 789);
houseCreate(array $body, array $queryParams = []): ResponseInterface
$client->houseCreate(['title' => 'Корпус 1', 'projectId' => 789]);
houseUpdate(int $houseID, array $body, array $queryParams = []): ResponseInterface
$client->houseUpdate(12345, ['title' => 'Корпус 1А']);
housesSearch(string $searchQuery, array $queryParams = []): ResponseInterface
$client->housesSearch('Корпус 1');
projects(?bool $isArchive = null, array $queryParams = []): ResponseInterface
$client->projects(isArchive: false);
projectCreate(array $body, array $queryParams = []): ResponseInterface
$client->projectCreate(['title' => 'Новомосковский', 'type' => 'complex']);
projectUpdate(int $projectID, array $body, array $queryParams = []): ResponseInterface
$client->projectUpdate(789, ['title' => 'Квартальный', 'type' => 'quarter']);
projectsSearch(string $searchQuery, array $queryParams = []): ResponseInterface
$client->projectsSearch('Новомосковский');
properties(array $queryParams = []): ResponseInterface
$client->properties(['status[]' => ['AVAILABLE', 'BOOKED']]);
propertyCreate(array $body, array $queryParams = []): ResponseInterface
$client->propertyCreate([
'house_id' => 1,
'number' => 'A101',
'rooms_amount' => 3,
'section' => '1',
'floor' => 11,
'status' => 'AVAILABLE',
"area" => [
"area_total" => 60.2,
"area_estimated" => 60.2,
"area_living" => 60.2,
"area_kitchen" => 60.2,
"area_balcony" => 60.2,
"area_without_balcony" => 60.2
],
]);
propertyUpdate(int $propertyID, array $body, array $queryParams = []): ResponseInterface
$client->propertyUpdate(56789, ['status' => 'SOLD']);
propertyTypes(array $queryParams = []): ResponseInterface
$client->propertyTypes();
propertyDealList(int $dealID, array $queryParams = []): ResponseInterface
$client->propertyDealList(dealID: 112233);
propertyHistory(
int $propertyID,
?int $offset = null,
?int $limit = null,
array $queryParams = []
): ResponseInterface
$client->propertyHistory(56789, offset: 0, limit: 10);
propertiesLegacyV3(int $projectID, int $houseID, array $queryParams = []): ResponseInterface
$client->propertiesLegacyV3(projectID: 123, houseID: 456);
propertyDeals(array $propertyIDs, array $queryParams = []): ResponseInterface
$client->propertyDeals([56789, 56790]);
propertyStatusChange(int $propertyID, array $body, array $queryParams = []): ResponseInterface
$client->propertyStatusChange(56789, ['status' => 'UNAVAILABLE']);
reserveProlong(array $body, array $queryParams = []): ResponseInterface
$client->reserveProlong(['propertyId' => 56789, 'date' => '2025-11-16 12:00']);
board(int $houseID, array $queryParams = []): ResponseInterface
$client->board(houseID: 12345);
plans(array $queryParams = []): ResponseInterface
$client->plans(['projectId' => 123]);
presetsLegacy(int $projectID, int $houseID, array $queryParams = []): ResponseInterface
$client->presetsLegacy(projectID: 789, houseID: 12345);
facades(int $houseID, array $queryParams = []): ResponseInterface
$client->facades(houseID: 12345);
floors(int $houseID, array $queryParams = []): ResponseInterface
$client->floors(houseID: 12345);
specialOffers(
?bool $isArchived = null,
?bool $isDiscounted = null,
array $queryParams = []
): ResponseInterface
$client->specialOffers(isArchived: false, isDiscounted: true);
crmDeals(?int $dealID = null, array $queryParams = []): ResponseInterface
$client->crmDeals(dealID: 112233);
crmPropertyDeals(int $propertyID, array $queryParams = []): ResponseInterface
$client->crmPropertyDeals(56789);
crmPropertyDealAdd(array $body, array $queryParams = []): ResponseInterface
$client->crmPropertyDealAdd(['dealId' => 112233, 'propertyId' => 56789]);
crmPropertyDealRemove(int $dealID, array $body = [], array $queryParams = []): ResponseInterface
$client->crmPropertyDealRemove(dealID: 112233);
crmDealPropertyUpdate(int $dealID, int $propertyID, array $queryParams = []): ResponseInterface
$client->crmDealPropertyUpdate(dealID: 112233, propertyID: 56789);
crmPropertyStatusSync(int $dealID, array $queryParams = []): ResponseInterface
$client->crmPropertyStatusSync(dealID: 112233);
orderCreate(array $body, array $queryParams = []): ResponseInterface
$client->orderCreate([
'order' => [
'name' => 'TEST',
'phone' => '+79111111111',
'email' => '[email protected] ',
'apartment_id' => 248408,
'calc_credit' => 1,
'comment' => 'тестовая заявка',
'widget_id' => 1
]
]);
history(array $body, array $queryParams = []): ResponseInterface
$client->history([
'offset' => 0,
'limit' => 20,
'property_ids' => [
3225787,
3225788
],
'from' => '2023-03-01 10:56:15',
'to' => '2023-03-02 07:20:50',
]);
customStatuses(string $crmID, ?string $statusID = null, array $queryParams = []): ResponseInterface
$client->customStatuses('bitrix');
filters(array $queryParams = []): ResponseInterface
$client->filters();
filterFacings(array $houseIDs = [], array $queryParams = []): ResponseInterface
$client->filterFacings([12345, 12346]);
filterPropertySpecifications(array $queryParams = []): ResponseInterface
$client->filterPropertySpecifications();
propertySpecifications(array $propertyIDs = [], array $queryParams = []): ResponseInterface
$client->propertySpecifications([56789, 56790]);
propertySpecificationList(array $queryParams = []): ResponseInterface
$client->propertySpecificationList();
propertySpecificationHouse(int $houseID, array $queryParams = []): ResponseInterface
$client->propertySpecificationHouse(houseID: 12345);
queueReserveList(int $propertyID, array $queryParams = []): ResponseInterface
$client->queueReserveList(propertyID: 56789);
queueReserveDelete(
int $dealQueueItemID,
array $body = [],
array $queryParams = []
): ResponseInterface
$client->queueReserveDelete(dealQueueItemID: 123456);
queueReserveCreate(
int $propertyID,
int|string $dealID,
array $body = [],
array $queryParams = []
): ResponseInterface
php
$client->queueReserveCreate(propertyID: 56789, dealID: 112233);
php
queueReserveChangePosition(
int $sourceDealQueueItemID,
int $targetDealQueueItemID,
array $body = [],
array $queryParams = []
): ResponseInterface
php
$client->queueReserveChangePosition(12456, 124);
php
renders(?int $projectID = null, array $queryParams = []): ResponseInterface
php
$client->renders(projectID: 789);
php
userInfo(array $queryParams = []): ResponseInterface
php
$client->userInfo(['email' => '[email protected] ']);
php
userAccessUpdate(int $userID, array $body, array $queryParams = []): ResponseInterface
php
$client->userAccessUpdate(
334455,
[
'isAccountAccessEnabled' => 'true',
'isUsersSectionAccessEnabled' => 'true',
'isObjectsSectionAccessEnabled' => 'true'
]
);
php
userPasswordForgot(int $userID, array $queryParams = []): ResponseInterface
php
$client->userPasswordForgot(userID: 334455);
php
stockVersionsFind(array $body, array $queryParams = []): ResponseInterface
php
$client->stockVersionsFind([
'ids' => [
12345,
12346
],
'fields' => [
'price',
'status'
]
]);