Download the PHP package hapio/hapio-sdk-php without Composer
On this page you can find all versions of the php package hapio/hapio-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package hapio-sdk-php
Hapio SDK for PHP
The Hapio SDK for PHP allows you to easily interact with the Hapio API for bookings and scheduling when using the PHP programming language.
Requirements
- PHP 8.2 or later
Getting started
The easiest way to install the Hapio SDK is by using Composer to require the package in your project:
To use the SDK in your project you simply instantiate an API client, and then get to work:
Documentation
API client
Provide your API token when you instantiate the API client:
Models
The following models are available in the SDK:
Hapio\Sdk\Models\Project
Hapio\Sdk\Models\Location
Hapio\Sdk\Models\Resource
Hapio\Sdk\Models\Service
Hapio\Sdk\Models\ScheduleBlock
Hapio\Sdk\Models\RecurringSchedule
Hapio\Sdk\Models\RecurringScheduleBlock
Hapio\Sdk\Models\Booking
Hapio\Sdk\Models\BookingGroup
Hapio\Sdk\Models\BookableSlot
Hapio\Sdk\Models\TimeSpan
Hapio\Sdk\Models\ResourceServiceAssociation
These models are returned when fetching entities, as well as when you create or update entities. When instantiating a new model, you can provide an array of properties to set:
You can also set and get individual properties on the model object:
You can use either snake_case
or camelCase
for the property names. Property names in camelCase
will be automatically converted to snake_case
internally, since that is used when communicating with the API.
You can only set values for valid property names:
Repositories
The Hapio SDK provides a repository class for each type of entity available in Hapio:
Hapio\Sdk\Repositories\ProjectRepository
Hapio\Sdk\Repositories\LocationRepository
Hapio\Sdk\Repositories\ResourceRepository
Hapio\Sdk\Repositories\ServiceRepository
Hapio\Sdk\Repositories\ScheduleBlockRepository
Hapio\Sdk\Repositories\RecurringScheduleRepository
Hapio\Sdk\Repositories\RecurringScheduleBlockRepository
Hapio\Sdk\Repositories\BookingRepository
Hapio\Sdk\Repositories\BookingGroupRepository
These repositories are the communication gateway to the API, and are used to send and retrieve data.
The repositories are accessible through methods on the ApiClient
class:
Each repository has a set of methods, corresponding to the endpoints available for the entity. These are listed for each repository below.
Hapio\Sdk\Repositories\ProjectRepository
Hapio\Sdk\Repositories\LocationRepository
Hapio\Sdk\Repositories\ResourceRepository
Hapio\Sdk\Repositories\ServiceRepository
Hapio\Sdk\Repositories\ScheduleBlockRepository
Hapio\Sdk\Repositories\RecurringScheduleRepository
Hapio\Sdk\Repositories\RecurringScheduleBlockRepository
Hapio\Sdk\Repositories\Booking
Hapio\Sdk\Repositories\BookingGroupRepository
Paginated responses
All the methods for API endpoints that respond with a paginated list, will return an instance of Hapio\Sdk\PaginatedResponse
. This class has a set of methods that make it easier for you to work with these paginated responses.
Exceptions
Whenever the API responds with a 4XX
or 5XX
response, an exception will be thrown. Validation error responses with a status code of 422
will throw a Hapio\Sdk\Exceptions\ValidationException
, and all other 4XX
and 5XX
status codes will throw a Hapio\Sdk\Exceptions\ErrorException
. For both of these exceptions you can access the original Guzzle exception using the getPrevious()
method, the message
property of the response is available using the getMessage()
method, and the status code can be fetched using the getCode()
method. The ValidationException
class also has a method for accessing validation errors, called getValidationErrors()
. Other Guzzle exceptions are not caught by the SDK.