PHP code example of oberonamsterdam / travelbase-api-client

1. Go to this page and download the library: Download oberonamsterdam/travelbase-api-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/ */

    

oberonamsterdam / travelbase-api-client example snippets


$client = new \Oberon\TravelbaseClient\ApiClient("https://example.com", "APIKEY");

/** @var \Oberon\TravelbaseClient\Model\Partner[] $partners */
$partners = $client->getPartners();

/** @var \Oberon\TravelbaseClient\Model\Partner $partner */
$partners = $client->getPartner($yourPartnerId);

/** @var \Oberon\TravelbaseClient\Model\Accommodation $accommodation */
$accommodation = $client->getAccommodation($yourAccommodationId);

/** @var \Oberon\TravelbaseClient\Model\RentalUnit $rentalUnit */
$rentalUnit = $client->getRentalUnit($yourRentalUnitId);

$cursor = null;
$hasMoreBookings = true;
/** @var \Oberon\TravelbaseClient\Model\Booking[] $bookings */
$bookings = [];
while ($hasMoreBookings) {
    $bookingConnection =  $client->getAllBookings($yourPartnerId, 10, $cursor);
    $bookings = array_merge($bookings, $bookingConnection->getNodes());
    $cursor = $bookingConnection->getPageInfo()->getEndCursor();
    $hasMoreBookings = $bookingConnection->getPageInfo()->isHasNextPage();
}

/** @var \Oberon\TravelbaseClient\Model\Booking $booking */
$booking = $client->getBooking($yourBookingId);

/** @var \Oberon\TravelbaseClient\Model\Booking[] $bookings */
$bookings = $client->getUpdatedBookings($yourPartnerId, new \DateTime('2022-01-01'));

/** @var \Oberon\TravelbaseClient\Model\Company $company */
$company = $client->getCompany($yourCompanyId);

/** @var \Oberon\TravelbaseClient\Model\Activity $activity */
$activity = $client->getActivity($yourActivityId);

/** @var \Oberon\TravelbaseClient\Model\Ticket $ticket */
$ticket = $client->getTicket($yourTicketId);

$cursor = null;
$hasMoreTickets = true;
/** @var \Oberon\TravelbaseClient\Model\Ticket[] $tickets */
$tickets = [];
while ($hasMoreTickets) {
    $ticketConnection =  $client->getAllTickets($yourPartnerId, 10, $cursor);
    $tickets = array_merge($tickets, $ticketConnection->getNodes());
    $cursor = $ticketConnection->getPageInfo()->getEndCursor();
    $hasMoreTickets = $ticketConnection->getPageInfo()->isHasNextPage();
}

//Send as a model
$allotment = new \Oberon\TravelbaseClient\Model\Allotment();
$allotment->setAmount(1); // as array
$allotmentCollection[] = [
    'amount' => 1, // 

//Send as a model
$tripPricing = new \Oberon\TravelbaseClient\Model\TripPricing();
$tripPricing->setDuration(1);
$tripPricing->setDate(new \DateTime('2022-01-01'));
$tripPricing->setPrice(100.50); // ion' => 1, // itId, $tripPricingCollection);

// To delete all trip pricings for a specific rentalunit, only supply the first parameter. 
// To delete all trips for a specific datetime supply first and second parameter.
// To delete all trips for a specific duration supply first and third parameter
// To delete a specific trip pricing supply all paramters

$client->deleteTrips($yourRentalUnitId, new \DateTime(), 1);

//Send as a model
$datePricing = new \Oberon\TravelbaseClient\Model\DatePricing();
$datePricing->setDate(new \DateTime('2022-01-01'));
$datePricing->setNightPrice(100.50); // Price(40); // tePricing;

//send as array
$datePricingCollection[] = [
    'date' => '2022-01-02', // quired
    'departureAllowed' => false // 

// Delete pricings starting from a specific datetime
$client->deleteDatePricings($yourRentalUnitId, new \DateTime('2022-01-01'));

// Delete pricings within a specific datetime range
$client->deleteDatePricings($yourRentalUnitId, new \DateTime('2022-01-01 12:00:00'), new \DateTime('2022-01-01 18:00:00'));

//Send as a model
$datePricingModifier = new \Oberon\TravelbaseClient\Model\DatePricingModifier();
$datePricingModifier->setStartDate(new \DateTime('2022-01-01')); // ); // d as array
$datePricingModifier = [
    'startDate' => '2022-01-01', // teDatePricingModifier($yourRentalUnitId, $datePricingModifier);

//Send as a model
$datePricingModifier = new \Oberon\TravelbaseClient\Model\DatePricingModifier();
$datePricingModifier->setStartDate(new \DateTime('2023-01-01')); // ); // array
$datePricingModifier = [
    'startDate' => '2023-01-01', // DatePricingModifier($yourDatePricingModifierId, $datePricingModifier);

$client->deleteDatePricingModifier($yourDatePricingModifierId);

// To delete all trip pricings for a specific rentalunit, only supply the first parameter. 
// To delete all trips for a specific datetime supply first and second parameter.
// To delete all trips for a specific duration supply first and third parameter
// To delete a specific trip pricing supply all paramters

$client->completePendingBooking($yourBookingId, true);

// Send as a model
$timeslot = new \Oberon\TravelbaseClient\Model\TimeslotInput(
    $yourRateGroupId, //  1, // ion[] = [
    'rateGroupId' => $yourRateGroupId,  // rnalId' => 'id1', //