Moje Olomouc PHP API Client, https://www.olomouc.app
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Salamek/MojeOlomouc
tests
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
composer.json
phpunit.xml.dist

README.md

Moje Olomouc PHP API Client

Build Status Coverage

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.