PHP code example of gonebusy / gonebusy-php-client

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

    

gonebusy / gonebusy-php-client example snippets


// Configuration parameters and credentials
$authorization = "Token <your API key>"; // Set Authorization to "Token <your API key>"

$client = new GonebusyLib\GonebusyClient($authorization);

$bookings = $client->getBookings();

function getBookings(
        $authorization,
        $page = 1,
        $perPage = 10,
        $states = null,
        $userId = null)

$authorization = 'Authorization';
$page = 1;
$perPage = 10;
$states = 'states';
$userId = 131;

$result = $bookings->getBookings($authorization, $page, $perPage, $states, $userId);


function createBooking(
        $authorization,
        $createBookingBody = null)

$authorization = 'Authorization';
$createBookingBody = new CreateBookingBody();

$result = $bookings->createBooking($authorization, $createBookingBody);


function getBookingById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $bookings->getBookingById($authorization, $id);


function updateBookingById(
        $authorization,
        $id,
        $updateBookingByIdBody = null)

$authorization = 'Authorization';
$id = 'id';
$updateBookingByIdBody = new UpdateBookingByIdBody();

$result = $bookings->updateBookingById($authorization, $id, $updateBookingByIdBody);


#### Errors

| Error Code | Error Description |
|------------|-------------------|
| 400 | Bad Request |
| 401 | Unauthorized/Missing Token |
| 403 | Forbidden |
| 404 | Not Found |
| 422 | Unprocessable Entity |
| 0 | Unexpected error |



#### <a name="cancel_booking_by_id"></a>![Method: ](https://apidocs.io/img/method.png ".BookingsController.cancelBookingById") cancelBookingById

> Cancel a Booking by id



$authorization = 'Authorization';
$id = 'id';
$cancelRecurring = 'cancel_recurring';
$date = date("D M d, Y G:i");
$endDate = date("D M d, Y G:i");

$result = $bookings->cancelBookingById($authorization, $id, $cancelRecurring, $date, $endDate);


$categories = $client->getCategories();

function getCategories(
        $authorization,
        $page = 1,
        $perPage = 10,
        $userId = null)

$authorization = 'Authorization';
$page = 1;
$perPage = 10;
$userId = 131;

$result = $categories->getCategories($authorization, $page, $perPage, $userId);


function createCategory(
        $authorization,
        $createCategoryBody = null)

$authorization = 'Authorization';
$createCategoryBody = new CreateCategoryBody();

$result = $categories->createCategory($authorization, $createCategoryBody);


function getCategoryById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $categories->getCategoryById($authorization, $id);


$pricingModels = $client->getPricingModels();

function getPricingModels(
        $authorization,
        $page = 1,
        $perPage = 10,
        $userId = null)

$authorization = 'Authorization';
$page = 1;
$perPage = 10;
$userId = 131;

$result = $pricingModels->getPricingModels($authorization, $page, $perPage, $userId);


function createPricingModel(
        $authorization,
        $createPricingModelBody = null)

$authorization = 'Authorization';
$createPricingModelBody = new CreatePricingModelBody();

$result = $pricingModels->createPricingModel($authorization, $createPricingModelBody);


function getPricingModelById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $pricingModels->getPricingModelById($authorization, $id);


function updatePricingModelById(
        $authorization,
        $id,
        $updatePricingModelByIdBody = null)

$authorization = 'Authorization';
$id = 'id';
$updatePricingModelByIdBody = new UpdatePricingModelByIdBody();

$result = $pricingModels->updatePricingModelById($authorization, $id, $updatePricingModelByIdBody);


$resources = $client->getResources();

function getResources(
        $authorization,
        $page = 1,
        $perPage = 10,
        $userId = null)

$authorization = 'Authorization';
$page = 1;
$perPage = 10;
$userId = 89;

$result = $resources->getResources($authorization, $page, $perPage, $userId);


function createResource(
        $authorization,
        $createResourceBody = null)

$authorization = 'Authorization';
$createResourceBody = new CreateResourceBody();

$result = $resources->createResource($authorization, $createResourceBody);


function getResourceThings(
        $authorization,
        $page = 1,
        $perPage = 10)

$authorization = 'Authorization';
$page = 1;
$perPage = 10;

$result = $resources->getResourceThings($authorization, $page, $perPage);


function getResourceById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $resources->getResourceById($authorization, $id);


function updateResourceById(
        $authorization,
        $id,
        $updateResourceByIdBody = null)

$authorization = 'Authorization';
$id = 'id';
$updateResourceByIdBody = new UpdateResourceByIdBody();

$result = $resources->updateResourceById($authorization, $id, $updateResourceByIdBody);


function deleteResourceById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $resources->deleteResourceById($authorization, $id);


$schedules = $client->getSchedules();

function getSchedules(
        $authorization,
        $page = 1,
        $perPage = 10,
        $userId = null)

$authorization = 'Authorization';
$page = 1;
$perPage = 10;
$userId = 89;

$result = $schedules->getSchedules($authorization, $page, $perPage, $userId);


function createSchedule(
        $authorization,
        $createScheduleBody = null)

$authorization = 'Authorization';
$createScheduleBody = new CreateScheduleBody();

$result = $schedules->createSchedule($authorization, $createScheduleBody);


function getScheduleById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $schedules->getScheduleById($authorization, $id);


function deleteScheduleById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $schedules->deleteScheduleById($authorization, $id);


function createScheduleTimeWindow(
        $authorization,
        $id,
        $createScheduleTimeWindowBody = null)

$authorization = 'Authorization';
$id = 'id';
$createScheduleTimeWindowBody = new CreateScheduleTimeWindowBody();

$result = $schedules->createScheduleTimeWindow($authorization, $id, $createScheduleTimeWindowBody);


function updateScheduleTimeWindowById(
        $authorization,
        $id,
        $timeWindowId,
        $updateScheduleTimeWindowByIdBody = null)

$authorization = 'Authorization';
$id = 'id';
$timeWindowId = 'time_window_id';
$updateScheduleTimeWindowByIdBody = new UpdateScheduleTimeWindowByIdBody();

$result = $schedules->updateScheduleTimeWindowById($authorization, $id, $timeWindowId, $updateScheduleTimeWindowByIdBody);


function deleteScheduleTimeWindowById(
        $authorization,
        $id,
        $timeWindowId)

$authorization = 'Authorization';
$id = 'id';
$timeWindowId = 'time_window_id';

$result = $schedules->deleteScheduleTimeWindowById($authorization, $id, $timeWindowId);


$search = $client->getSearch();

function searchQuery(
        $authorization,
        $query)

$authorization = 'Authorization';
$query = 'query';

$result = $search->searchQuery($authorization, $query);


$services = $client->getServices();

function getServices(
        $authorization,
        $page = 1,
        $perPage = 10,
        $userId = null)

$authorization = 'Authorization';
$page = 1;
$perPage = 10;
$userId = 89;

$result = $services->getServices($authorization, $page, $perPage, $userId);


function createService(
        $authorization,
        $createServiceBody = null)

$authorization = 'Authorization';
$createServiceBody = new CreateServiceBody();

$result = $services->createService($authorization, $createServiceBody);


function getServiceAvailableSlotsById(
        $authorization,
        $id,
        $date = null,
        $endDate = null,
        $startDate = null)

$authorization = 'Authorization';
$id = 'id';
$date = date("D M d, Y G:i");
$endDate = date("D M d, Y G:i");
$startDate = date("D M d, Y G:i");

$result = $services->getServiceAvailableSlotsById($authorization, $id, $date, $endDate, $startDate);


function getServiceById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $services->getServiceById($authorization, $id);


function updateServiceById(
        $authorization,
        $id,
        $updateServiceByIdBody = null)

$authorization = 'Authorization';
$id = 'id';
$updateServiceByIdBody = new UpdateServiceByIdBody();

$result = $services->updateServiceById($authorization, $id, $updateServiceByIdBody);


function deleteServiceById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $services->deleteServiceById($authorization, $id);


$users = $client->getUsers();

function getUsers(
        $authorization,
        $page = 1,
        $perPage = 10)

$authorization = 'Authorization';
$page = 1;
$perPage = 10;

$result = $users->getUsers($authorization, $page, $perPage);


function createUser(
        $authorization,
        $createUserBody = null)

$authorization = 'Authorization';
$createUserBody = new CreateUserBody();

$result = $users->createUser($authorization, $createUserBody);


function getUserById(
        $authorization,
        $id)

$authorization = 'Authorization';
$id = 'id';

$result = $users->getUserById($authorization, $id);


function updateUserById(
        $authorization,
        $id,
        $updateUserByIdBody = null)

$authorization = 'Authorization';
$id = 'id';
$updateUserByIdBody = new UpdateUserByIdBody();

$result = $users->updateUserById($authorization, $id, $updateUserByIdBody);