salamek / moje-olomouc
MojeOlomouc Client
v0.3
2018-11-30 04:28 UTC
Requires
- php: >=7.1.0
- ext-json: *
- guzzlehttp/guzzle: ~6.2
Requires (Dev)
- phpunit/phpunit: ^7.4
This package is auto-updated.
Last update: 2024-10-29 05:34:27 UTC
README
It's been designed to be object oriented, testable and uses Guzzle as a transport layer.
Install
The recommended way to use MojeOlomouc is through composer.
$ composer require salamek/moje-olomouc
Usage
All API operations are implemented:
- articleCategories
- articles
- eventCategories
- events
- importantMessages
- placeCategories
- places
Usage is as fallows:
use Salamek\MojeOlomouc\MojeOlomouc; use Salamek\MojeOlomouc\Model\ImportantMessage; use Salamek\MojeOlomouc\Model\Identifier; use Salamek\MojeOlomouc\Enum\ImportantMessageSeverityEnum; use Salamek\MojeOlomouc\Enum\ImportantMessageTypeEnum; $apiKey = 'YOUR_API_KEY'; $isProduction = false; $mojeOlomouc = new MojeOlomouc($apiKey, $isProduction); $importantMessage = new ImportantMessage( 'Warning', new \DateTime('2018-11-10'), ImportantMessageTypeEnum::TRAFFIC_SITUATION, ImportantMessageSeverityEnum::WARNING, new \DateTime('2018-11-12') ); // Create new important-message $response = $mojeOlomouc->importantMessages->create([$importantMessage]); if (!$response->isError()) { echo 'SUCCESS'.PHP_EOL; print_r($response->getData()); echo 'New important message have ID: '.$importantMessage->getId(); } else { echo 'ERROR'.PHP_EOL; echo $response->getMessage().PHP_EOL; } // Update important-message $importantMessage->setExpireAt(new \DateTime('2018-11-20')); $response = $mojeOlomouc->importantMessages->update([$importantMessage]); if (!$response->isError()) { echo 'SUCCESS'.PHP_EOL; print_r($response->getData()); } else { echo 'ERROR'.PHP_EOL; echo $response->getMessage().PHP_EOL; } // Delete important-message $response = $mojeOlomouc->importantMessages->delete([$importantMessage]); if (!$response->isError()) { echo 'SUCCESS'.PHP_EOL; print_r($response->getData()); } else { echo 'ERROR'.PHP_EOL; echo $response->getMessage().PHP_EOL; } // Or $idToDelete = 10; $response = $mojeOlomouc->importantMessages->delete([new Identifier($idToDelete)]); if (!$response->isError()) { echo 'SUCCESS'.PHP_EOL; print_r($response->getData()); } else { echo 'ERROR'.PHP_EOL; echo $response->getMessage().PHP_EOL; }
License
This project is licensed under the LGPL-3.0 license.