slotify / php-sdk
PHP SDK for Slotify API
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.0
README
The Slotify SDK is a PHP-based API client designed to simplify interactions with the Slotify scheduling app API. It provides a flexible and easy-to-use interface for making HTTP requests, managing configurations, and handling API responses, tailored specifically for Slotify's scheduling features.
Dependencies
This SDK uses the following library for HTTP requests:
- Guzzle - A PHP HTTP client that makes it easy to send HTTP requests and integrate with web services.
Features
- Configurable Base URL and API Key: Easily set the base URL and API key.
- CRUD Operations: Perform Create, Read, Update, and Delete operations on Slotify resources like bookings.
- Method Chaining: Chain methods for building complex queries with ease.
- Include Related Data: Fetch related data (e.g., customers, events) with a single request.
- Built-in Guzzle Integration: Powered by Guzzle for handling HTTP requests.
Installation
Install the library via Composer:
composer require slotify/sdk
Initialization
To use the SDK, initialize it with your API key and the Slotify base URL. Using api key, you can access app level data only. You can not use same key for multiple apps.
use SlotifySDK\ApiService;
$slotifyApi = new ApiService([
'apiKey' => '8c99a81c-dcbb-4de3-b316-f43b8a902cae',
]);
Usage (endpoints)
Documentation : https://slotify.ca/api
Endpoints/methods:
// App Endpoints
$slotifyApi->getApps();
// Customer Endpoints
$slotifyApi->getCustomers();
$slotifyApi->getCustomer('uuid');
$slotifyApi->createCustomer(['name' => 'John Doe']);
$slotifyApi->deleteCustomer('uuid');
$slotifyApi->updateCustomer('uuid', ['name' => 'Updated Name']);
// Group Endpoints
$slotifyApi->getGroups();
$slotifyApi->getGroup('uuid');
$slotifyApi->createGroup(['name' => 'Group Name']);
$slotifyApi->deleteGroup('uuid');
$slotifyApi->updateGroup('uuid', ['name' => 'Updated Group Name']);
// Resource Endpoints
$slotifyApi->getResources();
$slotifyApi->getResource('uuid');
$slotifyApi->createResource(['name' => 'Resource Name']);
$slotifyApi->deleteResource('uuid');
$slotifyApi->updateResource('uuid', ['name' => 'Updated Resource Name']);
// Scheduler Endpoints
$slotifyApi->getSchedulers();
$slotifyApi->getScheduler('uuid');
$slotifyApi->createScheduler(['title' => 'Scheduler Title']);
$slotifyApi->deleteScheduler('uuid');
$slotifyApi->updateScheduler('uuid', ['title' => 'Updated Scheduler Title']);
// Booking Endpoints
$slotifyApi->getBookings();
$slotifyApi->getBooking('uuid');
$slotifyApi->deleteBooking('uuid');
$slotifyApi->updateBooking('uuid', ['status' => 'confirmed']);
$slotifyApi->createBooking(['customer_id' => 'customer_uuid']);
// Booking Actions
$slotifyApi->completeBooking('uuid');
$slotifyApi->confirmBooking('uuid', [
'resource_id' => 'resource_uuid',
'customer_id' => 'customer_uuid'
]);
$slotifyApi->cancelBookingByCustomer('uuid', [
'customer_id' => 'customer_uuid',
'cancellation_message' => 'I am unable to attend'
]);
$slotifyApi->cancelBookingByResource('uuid', [
'resource_id' => 'resource_uuid',
'cancellation_message' => 'Resource unavailable'
]);
$slotifyApi->declineBooking('uuid', [
'resource_id' => 'resource_uuid',
'decline_message' => 'Service not available at this time'
]);
$slotifyApi->bookCustomer([
'customer' => [
'seats' => 10,
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'john.doe@example.com',
'customer_notes' => 'Please arrive early'
]
]);
$slotifyApi->reassignBooking('uuid', [
'resources' => [
[
'old_resource_id' => 'old_resource_uuid',
'new_resource_id' => 'new_resource_uuid'
]
]
]);
$slotifyApi->rescheduleBookingByCustomer('uuid', [
'start' => '2024-11-06T09:00:00-05:00',
'end' => '2024-11-06T10:00:00-05:00',
'customer_id' => 'customer_uuid'
]);
// Event Endpoints
$slotifyApi->getEvents();
$slotifyApi->getEvent('uuid');
$slotifyApi->createEvent(['title' => 'Event Title']);
$slotifyApi->deleteEvent('uuid');
$slotifyApi->updateEvent('uuid', ['title' => 'Updated Event Title']);
// Service Endpoints
$slotifyApi->getServices();
$slotifyApi->getService('uuid');
$slotifyApi->createService(['name' => 'Service Name']);
$slotifyApi->deleteService('uuid');
$slotifyApi->updateService('uuid', ['name' => 'Updated Service Name']);
// Workflow Endpoints
$slotifyApi->getWorkflows();
$slotifyApi->getWorkflow('uuid');
$slotifyApi->createWorkflow(['name' => 'Workflow Name']);
$slotifyApi->deleteWorkflow('uuid');
$slotifyApi->updateWorkflow('uuid', ['name' => 'Updated Workflow Name']);
// Availability Endpoints
$slotifyApi->getAvailability(['date' => '2024-01-01']);
$slotifyApi->getUnAvailability(['date' => '2024-01-01']);
$slotifyApi->getAvailabilityCount(['date' => '2024-01-01']);
Usage (Dynamic Includes)
The Slotify SDK supports dynamic includes, allowing you to fetch related data in a single request.
Example:
$slotifyApi->include('customers', 'resources')
->getBookings();
Usage (Query Params)
If you want to use query params you can use it as below example. Check doc for more advance usage for search parameters.
Example:
$slotifyApi->queryParams([
'limit' => 10,
'search' => 'name~:john',
])->getCustomers();