sturents / api
Installs: 61 995
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 9
Forks: 5
Open Issues: 2
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^6.0 || ^7.0
- netresearch/jsonmapper: ^1.4 || ^2.0 || ^3.0 || ^4.0
- psr/http-message: ^1.1 || ^2.0
Requires (Dev)
- roave/security-advisories: dev-latest
- sturents/swagger-php-model-generator: ^0.2
- vimeo/psalm: ^5.14
- dev-master
- 2.0.35
- 2.0.34
- 2.0.33
- 2.0.32
- 2.0.31
- 2.0.30
- 2.0.29
- 2.0.28
- 2.0.27
- 2.0.26
- 2.0.25
- 2.0.24
- 2.0.23
- 2.0.22
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- v1.3.x-dev
- 1.3.0
- 1.2.1
- 1.2.0
- 1.0.0
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-james-fixed
- dev-C18-228/channel-api/response-updates
- dev-emily/add-booking-status-endpoint
- dev-craig/undefined-fixes
- dev-dependabot/composer/guzzlehttp/psr7-1.9.1
- dev-dependabot/composer/guzzlehttp/guzzle-6.5.8
- dev-dev-bump-guzzle-to-v7
- dev-fjmillman/AW-2643/add-360-photos-to-outbound-api
- dev-fjmillman/AW-2244/add-tours-to-media-object
This package is auto-updated.
Last update: 2024-10-29 13:54:20 UTC
README
Master branch is for v2.0 which is not available yet; please check releases for previous versions. For outbound data check 1.3., for inbound use 1.2.
Install using composer:
php composer.phar require sturents/api
Wait, what's Composer?
Composer is the de-facto package manager for PHP projects. If you haven't used it before it is very simple to set up.
- Visit the Composer download page and follow instructions to download composer into your project root.
- You should now have a file called
composer.phar
in your project root. You can run various commands using this file. - Start by running
php composer.phar init
to create yourcomposer.json
file. This file stores all your project configuration and dependencies. - Now either run the command at the top of the readme to install the StuRents API, or add
"sturents/api": "*"
to the"require"
object inside yourcomposer.json
file.
To use Composer dependencies inside a PHP file is simple - just the following to the top of your file:
require_once __DIR__.'/vendor/autoload.php';
Now you can create or use any object without having to worry about requiring its files - Composer and PHP's autoloader will handle that for you.
Send a property to StuRents
$property = new \SturentsLib\Api\Models\PropertyCreation;
// Use setters to create sub-objects and set properties as
// described in the documentation:
// https://sturents.com/software/developer/house-create
// Or as demonstrated in `examples/send.php`
$upload_client = new \SturentsLib\Api\UploadClient(LANDLORD_ID, UPLOAD_KEY);
$put_property = new \SturentsLib\Api\Requests\PutProperty;
$put_property->setBody($property);
try {
$response = $put_property->sendWith($upload_client);
}
catch (\Exception $e){
echo "An unexpected problem happened: ".$e->getMessage();
}
if ($response instanceof PropertySaved){
echo 'Property created with ID: '.$response->getPropertyId()."\n"; // outputs an integer
}
elseif ($response->isError()){
echo 'A known error occurred of type '.get_class($response)."\n";
echo json_encode($response)."\n";
}
else {
echo 'An unknown error occurred of type '.get_class($response)."\n";
}
Fetch data from StuRents with a Landlord ID
// Where LANDLORD_ID is an integer
$display_client = new \SturentsLib\Api\DisplayClient(LANDLORD_ID, DISPLAY_KEY);
$get_properties = new \SturentsLib\Api\Requests\GetProperties;
try {
$response = $get_properties->sendWith($display_client);
}
catch (\Exception $e){
echo "A problem happened: ".$e->getMessage();
}
var_dump($response instanceof ListProperties); // outputs 'true'
echo $response->pagination->pages // echo, e.g. 3
var_dump($response->properties[0] instanceof PropertyOutbound) // outputs 'true'
Fetch data from StuRents as a channel
// Where *_ID values are strings
$display_client = new \SturentsLib\Api\ChannelClient(LANDLORD_ID, CHANNEL_ID, DISPLAY_KEY);
$get_properties = new \SturentsLib\Api\Requests\GetProperties;
try {
$response = $get_properties->sendWith($display_client);
}
catch (\Exception $e){
echo "A problem happened: ".$e->getMessage();
}
var_dump($response instanceof ListProperties); // outputs 'true'
echo $response->pagination->pages // echo, e.g. 3
var_dump($response->properties[0] instanceof PropertyOutbound) // outputs 'true'