gonebusy/gonebusy-php-client

This is a PHP client for communicating with the full Gonebusy API

v0.1.3 2017-06-19 00:09 UTC

This package is not auto-updated.

Last update: 2025-02-02 02:56:35 UTC


README

Build Status PHP version

PHP SDK for the Gonebusy REST API

Sandbox

We have a Sandbox environment to play with!

To point at the Sandbox, just use sandbox.gonebusy.com instead of where you see beta.gonebusy.com referenced, including where to create an account to retrieve your API Key.

The Sandbox environment is completely separate from the Live site - that includes meaning your Sandbox API Key will not work in the Live environment.

How to Use

Summary of Gonebusy objects

(more info on the Developer Portal):

  • A User is required to perform operations.
  • A Resource (WHO) performs Services and is needed for all scheduling operations. Each User is assigned a default Resource (her/himself) automatically.
  • A Service (WHAT) is performed by Resources according to a Schedule. Services are assigned a Pricing Model. Services can be assigned a Category as well.
  • A Schedule (WHEN) defines when a Service is performed by a Resource. Pieces of a Schedule are called Time Windows.
  • Finally, a Booking is placed (at a particular Time Window) in a Schedule, linking it to a Resource-Service combo.
  • A Search of users and services can be performed.

API Key

If testing with Sandbox, Signup/Logon at https://sandbox.gonebusy.com/login.

If using Production site, Signup/Logon at https://beta.gonebusy.com/login.

Once logged in, navigate to the API Key page and request an API key.

Initialization/Authentication

In order to setup authentication and initialization of the API client, you need the following information.

API client can be initialized as following.

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

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

How to Build

Composer Install

> composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
  - Installing apimatic/jsonmapper (v1.2.0)
    Loading from cache

  [ ... snip ... ]

  - Installing squizlabs/php_codesniffer (2.9.0)
    Downloading: 100%

symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.1)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Generating autoload files

[For Windows Users Only] Configuring CURL Certificate Path in php.ini

CURL used to include a list of accepted CAs, but no longer bundles ANY CA certs. So by default it will reject all SSL certificates as unverifiable. You will have to get your CA's cert and point curl at it. The steps are as follows:

  1. Download the certificate bundle (.pem file) from https://curl.haxx.se/docs/caextract.html on to your system.
  2. Add curl.cainfo = "PATH_TO/cacert.pem" to your php.ini file located in your php installation. “PATH_TO” must be an absolute path containing the .pem file.
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =

How to Test

Unit tests in this SDK can be run using PHPUnit. The test cases are located in the test/Controllers/ dir.

  1. Make sure you've installed the dependencies using composer including the require-dev dependencies.
  2. Run vendor/bin/phpunit from command line to execute the test suite. See https://phpunit.de/manual/current/en/textui.html for info on test output format as well as more command-line options.
  3. Optionally, to check the code standards you may run vendor/bin/phpcs (See phpcs.xml). (No output means no problems.)

Class Reference

List of Controllers

Class: BookingsController

Get singleton instance

The singleton instance of the BookingsController class can be accessed from the API Client.

$bookings = $client->getBookings();

Method: getBookings

Return list of Bookings.

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

Parameters

Example Usage

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

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

Errors

Method: createBooking

Create a Booking with params

function createBooking(
        $authorization,
        $createBookingBody = null)

Parameters

Example Usage

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

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

Errors

Method: getBookingById

Return a Booking by id.

function getBookingById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Method: updateBookingById

Update a Booking by id

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

Parameters

Example Usage

$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


```php
function cancelBookingById(
        $authorization,
        $id,
        $cancelRecurring = null,
        $date = null,
        $endDate = null)

Parameters

Example Usage

$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);

Errors

Back to List of Controllers

Class: CategoriesController

Get singleton instance

The singleton instance of the CategoriesController class can be accessed from the API Client.

$categories = $client->getCategories();

Method: getCategories

Return list of Categories.

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

Parameters

Example Usage

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

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

Errors

Method: createCategory

Create a Category

function createCategory(
        $authorization,
        $createCategoryBody = null)

Parameters

Example Usage

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

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

Errors

Method: getCategoryById

Return a Category by id.

function getCategoryById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Back to List of Controllers

Class: PricingModelsController

Get singleton instance

The singleton instance of the PricingModelsController class can be accessed from the API Client.

$pricingModels = $client->getPricingModels();

Method: getPricingModels

Return list of PricingModels.

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

Parameters

Example Usage

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

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

Errors

Method: createPricingModel

Create a PricingModel with params

function createPricingModel(
        $authorization,
        $createPricingModelBody = null)

Parameters

Example Usage

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

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

Errors

Method: getPricingModelById

Return a PricingModel by id.

function getPricingModelById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Method: updatePricingModelById

Update a PricingModel by id, with params

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

Parameters

Example Usage

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

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

Errors

Back to List of Controllers

Class: ResourcesController

Get singleton instance

The singleton instance of the ResourcesController class can be accessed from the API Client.

$resources = $client->getResources();

Method: getResources

Return list of Resources.

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

Parameters

Example Usage

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

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

Errors

Method: createResource

Create a Resource with params

function createResource(
        $authorization,
        $createResourceBody = null)

Parameters

Example Usage

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

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

Errors

Method: getResourceThings

Return all Resource Things.

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

Parameters

Example Usage

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

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

Errors

Method: getResourceById

Return a Resource by id.

function getResourceById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Method: updateResourceById

Update a Resource by id, with params

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

Parameters

Example Usage

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

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

Errors

Method: deleteResourceById

Delete a Resource by id

function deleteResourceById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Back to List of Controllers

Class: SchedulesController

Get singleton instance

The singleton instance of the SchedulesController class can be accessed from the API Client.

$schedules = $client->getSchedules();

Method: getSchedules

Return all Schedules that your account has access to. Includes Schedules for your own User as well as any Users for which you are the Account Manager.

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

Parameters

Example Usage

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

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

Errors

Method: createSchedule

Create a Schedule with params.

function createSchedule(
        $authorization,
        $createScheduleBody = null)

Parameters

Example Usage

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

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

Errors

Method: getScheduleById

Return a Schedule by id.

function getScheduleById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Method: deleteScheduleById

Delete a Schedule

function deleteScheduleById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Method: createScheduleTimeWindow

Add a TimeWindow to a Schedule.

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

Parameters

Example Usage

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

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

Errors

Method: updateScheduleTimeWindowById

Update a TimeWindow for a Schedule.

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

Parameters

Example Usage

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

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

Errors

Method: deleteScheduleTimeWindowById

Delete a TimeWindow from a Schedule

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

Parameters

Example Usage

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

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

Errors

Back to List of Controllers

Class: SearchController

Get singleton instance

The singleton instance of the SearchController class can be accessed from the API Client.

$search = $client->getSearch();

Method: searchQuery

Search for Providers and Provided Services.

function searchQuery(
        $authorization,
        $query)

Parameters

Example Usage

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

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

Errors

Back to List of Controllers

Class: ServicesController

Get singleton instance

The singleton instance of the ServicesController class can be accessed from the API Client.

$services = $client->getServices();

Method: getServices

Return list of Services.

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

Parameters

Example Usage

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

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

Errors

Method: createService

Create a Service with params.

function createService(
        $authorization,
        $createServiceBody = null)

Parameters

Example Usage

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

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

Errors

Method: getServiceAvailableSlotsById

Return available times for a Service.

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

Parameters

Example Usage

$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);

Errors

Method: getServiceById

Return a Service by id.

function getServiceById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Method: updateServiceById

Update a Service with params.

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

Parameters

Example Usage

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

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

Errors

Method: deleteServiceById

Delete a Service by id

function deleteServiceById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Back to List of Controllers

Class: UsersController

Get singleton instance

The singleton instance of the UsersController class can be accessed from the API Client.

$users = $client->getUsers();

Method: getUsers

Return all Users that your account has access to. Includes your own User as well as any Users for which you are the Account Manager.

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

Parameters

Example Usage

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

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

Errors

Method: createUser

Create a User

function createUser(
        $authorization,
        $createUserBody = null)

Parameters

Example Usage

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

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

Errors

Method: getUserById

Return a User by id.

function getUserById(
        $authorization,
        $id)

Parameters

Example Usage

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

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

Errors

Method: updateUserById

Update a User by id, with params.

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

Parameters

Example Usage

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

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

Errors

Back to List of Controllers