PHP code example of cronixweb / streamline-sdk

1. Go to this page and download the library: Download cronixweb/streamline-sdk 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/ */

    

cronixweb / streamline-sdk example snippets


Cronixweb\Streamline\...

use Cronixweb\Streamline\Streamline;

// config/services.php
return [
    // ...
    'streamline' => [
        'token_key'    => env('STREAMLINE_TOKEN_KEY'),
        'token_secret' => env('STREAMLINE_TOKEN_SECRET'),
    ],
];

use Cronixweb\Streamline\Streamline;

$apiKey    = config('services.streamline.token_key');
$apiSecret = config('services.streamline.token_secret');

$streamline = Streamline::api($apiKey, $apiSecret);

// Fetch first page of properties
$properties = $streamline->properties()->all();

// Fetch a single property by unit_id
$property = $streamline->properties()->find(12345);

$properties = $streamline->properties()->all();

$property = $streamline->properties()->find(12345);

$propClient    = $streamline->properties();
$amenities     = $propClient->amenities(12345)->all();      // AmenitiesClient
$galleryImages = $propClient->galleryImages(12345)->all();  // GalleryImagesClient
$reviews       = $propClient->reviews(12345)->all();        // ReviewsClient
$rates         = $propClient->propertyRates(12345)->all();  // PropertyRatesClient

$amenities = $streamline
    ->properties()
    ->amenities(12345)
    ->all();

// Or via a dedicated client:
// $amenities = $streamline->amenities()->getPropertyAmenities(12345);

$images = $streamline
    ->properties()
    ->galleryImages(12345)
    ->all();

// Or via a dedicated client:
// $images = $streamline->galleryImages()->getPropertyGalleryImages(12345);

use Cronixweb\Streamline\Utils\ReviewsClient; // for type hints, if desired

// Scoped to a unit via properties client
$reviews = $streamline->properties()->reviews(12345)->all();

// Or using the method with filters
$reviews = $streamline->reviews()->getGuestReviews(
    housekeeperId: null,   // e.g. 789
    unitId:       12345,
    returnAll:    true
);

$blocked = $streamline->bookedDates()->getBlockedDaysForUnit(
    unitId:           12345,
    startdate:        '01/01/2025', // optional
    enddate:          '01/31/2025', // optional
    displayB2BBlocks: true,         // optional
    allowInvalid:     false,        // optional
    owningId:         null          // optional, single unit only
);

$blocked = $streamline->bookedDates()->getBlockedDaysForUnit(
    unitId:           [12345, 67890],
    startdate:        '01/01/2025',
    enddate:          '01/31/2025',
    displayB2BBlocks: true,
    allowInvalid:     false
);

$rates = $streamline->propertyRates()->all([
    'unit_id'                      => 12345,
    'startdate'                    => '01/01/2025',
    'enddate'                      => '01/31/2025',

    // Optional flags:
    'use_room_type_logic'          => true,
    'dailyChangeOver'              => false,
    'use_homeaway_max_days_notice' => false,

    // Provide either of the following (not both):
    // 'rate_type_ids' => [1, 2, 3],
    // or nested:
    // 'rate_types'    => ['id' => [1, 2, 3]],

    'show_los_if_enabled'          => true,
    'max_los_stay'                 => 14,   // 

$rates = $streamline->propertyRates()->getPropertyRates(
    unitId:                   12345,
    startdate:                '01/01/2025',
    enddate:                  '01/31/2025',
    useRoomTypeLogic:         null,
    dailyChangeOver:          null,
    useHomeawayMaxDaysNotice: null,
    rateTypeIds:              [1, 2],
    showLosIfEnabled:         true,
    maxLosStay:               14,
    useAdvLogicIfDefined:     null
);

$new = $streamline->refreshToken();

// Example response:
// [
//     'apikey'    => '...',
//     'apiSecret' => '...',
// ]

use Cronixweb\Streamline\Exceptions\StreamlineApiException;
use Illuminate\Http\Client\ConnectionException;

try {
    $rates = $streamline
        ->propertyRates()
        ->getPropertyRates(12345, '01/01/2025', '01/31/2025');
} catch (StreamlineApiException $e) {
    // Handle API-level error (log, alert, transform to domain exception, etc.)
} catch (ConnectionException $e) {
    // Handle network/transport errors (timeouts, DNS issues, etc.)
} catch (\InvalidArgumentException $e) {
    // Handle invalid input before hitting the API
}
bash
composer dump-autoload