tuc0w / timeular-public-api-bundle
Provides a Timeular integration for your Symfony 4 Project.
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.1.3
- ext-json: *
- guzzlehttp/guzzle: ^6.4
- symfony/config: ^4.0
- symfony/dependency-injection: ^4.0
- symfony/http-kernel: ^4.0
- symfony/serializer: ^4.3
Requires (Dev)
- captainhook/captainhook: ^4.5
- captainhook/plugin-composer: ^4.0
- friendsofphp/php-cs-fixer: ^2.16
- phpmd/phpmd: ^2.7
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.11.19
- phpstan/phpstan-phpunit: ^0.11.2
- phpstan/phpstan-symfony: ^0.11.6
- symfony/phpunit-bridge: ^4.3
This package is auto-updated.
Last update: 2024-04-06 01:53:20 UTC
README
TimeularPublicApiBundle is a way to integrate your time tracking with the Timeular ZEI° device into your Symfony application, but with a bit less work, an easy configuration and predefined useful filters.
Install the package with:
composer require tuc0w/timeular-public-api-bundle --dev
And that's it! If you're not using Symfony Flex, you'll also
need to enable the Tuc0w\TimeularPublicApiBundle\Tuc0wTimeularPublicApiBundle
in your AppKernel.php
file.
Configuration
A few things needs be configured directly by creating a new
config/packages/tuc0w_timeular_public_api.yaml
file.
The default values are:
# config/packages/tuc0w_timeular_public_api.yaml tuc0w_timeular_public_api: timeular: api_base_url: https://api.timeular.com api_key: your_api_key api_secret: your_api_secret api_timeout: 30.0 api_version: /api/v2
Usage
This bundle provides a single service to access the API, which
you can autowire by using the TimeularClient
type-hint:
// src/Controller/SomeController.php use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Annotation\Route; use Tuc0w\TimeularPublicApiBundle\Service\Client as TimeularClient; class SomeController extends AbstractController { private $timeular; public function __construct(TimeularClient $timeular) { $this->timeular = $timeular; } /** * @Route("/", name="app_homepage") */ public function index() { $this->timeular->signIn(); // get the time entries from today return new JsonResponse( $this->timeular->getTimeEntries( new \DateTime(), new \DateTime() ) ); } }
You can also access this service directly using the id
tuc0w_timeular_public_api.client
.
$timeular = $container->get('tuc0w_timeular_public_api.client');
Available methods
Currently there are only a few methods available:
Method | Parameter | Description |
---|---|---|
getActivities() | none | Returns a list of created activities. |
getCurrentTracking() | none | Returns the time entry that is currently tracked. |
getDevices() | none | Returns a list of registered devices. |
getTagsAndMentions() | none | Returns a list of used tags and mentions. |
getTimeEntries($stoppedAfter, $startedBefore) | DateTimeInterface | Returns all time entries between the given start/end date. |
signIn() | none | Uses the api key/secret to generate a token to sign in. |
Todos
- Basic functionality
- Create custom filter methods
- Integrate missing endpoints
Contributing
Please feel comfortable submitting issues or pull requests: all contributions and questions are warmly appreciated :)