openagenda/api-sdk

This package is abandoned and no longer maintained. The author suggests using the erwane/openagenda-api package instead.

PHP sdk to request OpenAgenda api

3.1.2 2025-01-21 14:09 UTC

README

Software License codecov Build Status Packagist Downloads Packagist Version

This package will help you to query OpenAgenda API. It supports all endpoints with all methods (HEAD, GET, POST, PATCH & DELETE).

Version map

Installation

The sdk is not directly usable.
You need to use one client wrapper, compatible with your PSR-18 http client or framework.

Wrappers

Please check version map in the README of your desired wrapper.

CakePHP

erwane/openagenda-wrapper-cakephp

composer require erwane/openagenda-wrapper-cakephp

Guzzle

erwane/openagenda-wrapper-guzzle

composer require erwane/openagenda-wrapper-guzzle

Documentations and examples

Quick start

This package require wrapper compatible with your PSR-18 Http client (psr/http-client).

For performance and reduce queries in post, patch & delete (authenticated request), you can configure a PSR 16 cache (psr/simple-cache).

use OpenAgenda\OpenAgenda;
use OpenAgenda\Wrapper\GuzzleWrapper

// PSR-18 Http client.
$guzzleOptions = ['timeout'  => 2.0];
$wrapper = new GuzzleWrapper($guzzleOptions);

// PSR-16 Simple cache. Optional
$cache = new Psr16Cache();

// Create the OpenAgenda client. The public key is required for reading data (GET)
// The private key is optional and only needed for writing data (POST, PUT, DELETE)
$oa = new OpenAgenda([
    'public_key' => 'my public key', // Required
    'secret_key' => 'my secret key', // Optional, only for create/update/delete
    'wrapper' => $wrapper, // Required
    'cache' => $cache, // Optional
    'defaultLang' => 'fr', // Optional
]);

Usages

Agendas

$agendas = $oa->myAgendas(['limit' => 2]);
$agenda = $oa->agendas(['slug' => 'agenda-slug'])->first();

See agendas for more details.

Locations

// Search
$locations = $oa->locations(['agendaUid' => 123, 'name' => 'My Location']);
// Exists and get
$exists = $oa->location(['uid' => 456, 'agendaUid' => 123])->exists();
$location = $oa->location(['uid' => 456, 'agendaUid' => 123])->get();
// Create
$location = $oa->location($data)->create();

See locations for more details.

Events

// Search
$events = $oa->events(['agendaUid' => 123, 'title' => 'My event']);
// Exists and get
$exists = $oa->event(['uid' => 456, 'agendaUid' => 123])->exists();
$event = $oa->event(['uid' => 456, 'agendaUid' => 123])->get();
// Create
$event = $oa->event($data)->create();

See events for more details.