saccas / hitobito-json-api-model
There is no license information available for the latest version (v1.2.1) of this package.
v1.2.1
2024-12-18 09:36 UTC
Requires
- saccas/json-api-model: @dev
README
PHP model for the Hitobito API. This model was automatically generated on the basis of the OpenAPI specification and requires the abstract saccas/json-api-model
.
Installation
Extend your composer.json
{ "repositories": [ { "type": "git", "url": "git@github.com:saccas/json-api-model.git" }, { "type": "git", "url": "git@github.com:saccas/hitobito-json-api-model.git" } ] }
Require this package:
composer require saccas/hitobito-json-api-model @dev
Usage
<?php require __DIR__.'/vendor/autoload.php'; $baseUri = 'https://sac-cas.puzzle.ch'; $defaultHeaders = [ 'X-TOKEN' => '…', ]; $hitobitoApi = new \Saccas\HitobitoApi\HitobitoApi(new \GuzzleHttp\Client(), $baseUri, $defaultHeaders); $coursesRepository = $hitobitoApi->getCoursesRepository(); $allCourses = $coursesRepository->getAll(); foreach($allCourses as $course) { echo $course->getId() . ' ' . $course->getName() . "\n"; echo 'Location: ' . $course->getLocation() . "\n"; echo 'Start: ' . $course->getDates()->get(0)->getStartAt()->format('Y-m-d') . "\n"; $contact = $course->getContact(); if (isset($contact)) { echo 'Contact: ' . $contact->getFirstName() . ' ' . $contact->getLastName() . "\n"; } echo 'Accommodation: ' . $course->getAccommodation() . "\n"; echo "\n"; }