GithubHelp home page GithubHelp logo

timekit-php-sdk's Introduction

Timekit.io PHP SDK

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:

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

timekit-php-sdk's People

Contributors

van-dev avatar superh2m avatar privyreza avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.