moovone / timekit-php-sdk
A basic PHP SDK for timekit.io API
Installs: 16 049
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 4
Open Issues: 0
Requires
- php: ^7.1
- ext-json: *
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/phpunit: ^8
- symfony/var-dumper: ^4.2
This package is auto-updated.
Last update: 2024-04-29 04:09:09 UTC
README
Warning: this library is in development. First release should be ready in few days.
This library is a basic PHP SDK for the timekit.io API.
This SDK doesn't fully cover the timekit.io API endpoints. Only the following endpoints are covered:
Covered end-point | Timekit.io documentation |
---|---|
POST /resources |
https://developers.timekit.io/reference#resources |
PUT /resources/{id} |
https://developers.timekit.io/reference#resources-id |
DELETE /resources/{id} |
https://developers.timekit.io/reference#delete-resource |
GET /resources/{id} |
https://developers.timekit.io/reference#resourcesid |
POST /bookings |
https://developers.timekit.io/reference#bookings |
DELETE /bookings/{id} |
https://developers.timekit.io/reference#delete-a-booking |
PUT /bookings/{id}/{state} |
https://developers.timekit.io/reference#bookingsidaction |
POST /availability |
https://developers.timekit.io/reference#query-availability-v2 |
Installation
composer require moovone/timekit-php-sdk
Usage
use Moovone\TimekitPhpSdk\GuzzleClient; $httpClient = new GuzzleClient($apiKey); $payload = [ 'timezone' => 'Europe/Paris', 'name' => 'John Doe', ]; $resource = $this->httpClient->createResource($payload);
Models
This SDK provides models for the following availability constraints:
- allow day and time: AllowDayAndTimeAvailabilityConstraint
- block day and time: BlockDayAndTimeAvailabilityConstraint
- allow hours: AllowHoursAvailabilityConstraint
- block hours: BlockHoursAvailabilityConstraint
- allow day: AllowDayAvailabilityConstraint
- block day: BlockDayAvailabilityConstraint
- allow period: AllowPeriodAvailabilityConstraint
- block period: BlockPeriodAvailabilityConstraint
- allow weekdays: AllowWeekdaysAvailabilityConstraint
- block weekdays: BlockWeekdaysAvailabilityConstraint
- allow weekends: AllowWeekendsAvailabilityConstraint
- block weekends: BlockWeekendsAvailabilityConstraint
All those models provide a convertToPayloadEntry
method which will convert them to a timekit-api payload-compliant json.
Examples
Create a resource
$payload = [ 'timezone' => $timezone, 'first_name' => $firstName, 'last_name' => $lastName, 'name' => sprintf('%s %s', $firstName, $lastName), ]; $resource = $this->httpClient->createResource($payload);
Update a resource
$payload = [ 'timezone' => $timezone, 'first_name' => $firstName, 'last_name' => $lastName, 'name' => sprintf('%s %s', $firstName, $lastName), ]; $this->httpClient->updateResource($resourceId, $payload);
Delete a resource
$this->httpClient->deleteResource($resourceId);
Get a resource
$resource = $this->httpClient->getResource($resourceId);
Create a booking
$start = (new \DateTime())->modify('+1 hour'); $booking = $this->httpClient->createBooking($remoteId, $start, (clone $start)->modify('+30 minutes'), 'My first booking');
Delete a booking
$this->httpClient->deleteBooking($bookingId);
Update a booking state
use MoovOne\TimekitPhpSdk\Model\Booking; $booking = $this->httpClient->updateBookingState($bookingId, Booking::STATE_CANCEL);
Get availabilities
use MoovOne\TimekitPhpSdk\Model\Availability; $payload = [ 'mode' => Availability::TYPE_ROUNDROBIN_RANDOM, 'length' => '60 minutes', 'round_to_nearest_hour' => false, 'from' => 'tomorrow', 'to' => '3 days', 'buffer' => '5 minutes', 'timeslot_increments' => '15 minutes', 'resources' => [$resourceId], ]; $availabilities = $this->httpClient->getAvailabilities($payload);