PHP code example of adventureres / php-sdk-v1

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

    

adventureres / php-sdk-v1 example snippets


$advRes = new AdventureRes\AdventureRes(
    $baseDomain = 'http://reservations.domain.com',
    $apiKey     = '12345abcde', // <- Comes from your AdventureRes installation
    $username   = 'theuser', 
    $password   = 'opensesame',
    $location   = 10
);

use AdventureRes\Models\Input\ServiceAvailabilityInputModel;

// Static declaration:
$input = ServiceAvailabilityModel::populateModel([
    'AdultQty'   => 2,
    'YouthQty'   => 0,
    'Units'      => 0,
    'StartDate'  => '06/01/2016',
    'Display'    => 'ITEM'
]);

// Class declaration with attributes passed via the constructor:
$input = new ServiceAvailabilityModel([
    'AdultQty'   => 2,
    'YouthQty'   => 0,
    'Units'      => 0,
    'StartDate'  => '06/01/2016',
    'Display'    => 'ITEM'
]);

$input->setAttribute('AdultQty', 5);

if (! $model->isValid()) {
    // Get errors as an array
    $errors = $model->getErrors();

    // Get errors as a concatenated string
    $errorString = $model->getErrorsAsString();
}

// Gets an array of all attributes and their values
$attributes = $model->getAttributes();

// Gets the value of one attribute
$attribute = $model->getAttribute('AdultPrice');

// Gets the value of one attribute using magic method
$attribute = $model->AdultPrice;

$serviceAvailability = $advRes->service()->getServiceAvailability($inputModel);
$package = $advRes->package()->getPackage($inputModel);
$costSummary = $advRes->reservation()->getCostSummary($inputModel);
$newCustomer = $advRes->customer()->createCustomer($inputModel);

use AdventureRes\AdventureRes;
use AdventureRes\Models\Input\ServiceAvailabilityInputModel;

$advRes = new AdventureRes($config['baseDomain'], $config['apiKey'], $config['username'], $config['password'], $config['location']);

try {
    $input = ServiceAvailabilityInputModel::populateModel([
        'ServiceId' => 123,
        'AdultQty'  => 2,
        'YouthQty'  => 0,
        'Units'     => 0,
        'StartDate' => '06/01/2016',
        'Display'   => 'ITEM'
    ]);

    $serviceAvailability = $advRes->service()->getServiceAvailability($input);

    if (! $serviceAvailability->isValid()) {
        throw new \Exception($serviceAvailability->getErrorsAsString());
    }

} catch (AdventureRes\Exceptions\AdventureResSDKException $ex) {
    return $ex->getMessage();
}