larsnieuwenhuizen/clubhouse-connector

Service package to connect and interface with Clubhouse through php

1.0.0 2020-08-06 20:01 UTC

This package is auto-updated.

Last update: 2024-04-20 19:00:41 UTC


README

68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39643062303365393962653731626136633333352f6d61696e7461696e6162696c697479 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39643062303365393962653731626136633333352f746573745f636f766572616765 Build Status

Clubhouse connector

This library allows you to easily make use of the Clubhouse api integrations through one connector.

Single point of entry

All you need to do is construct the Connector object with a configuration file. The configuration is done throught yaml and looks like this.

config.yaml

Clubhouse:
  api:
    uri: 'https://api.clubhouse.io/api/v3/'
    token: 'myApiTokenHere'

Creating the connector

$connector = new Connector('config.yaml');

Using clubhouse components

The components are accessed through their respective services like this:

$connector->getEpicsService()->list();

This as you probably expects call the list of epics. This will return you a collection on Epic objects.

Objectification

All the Clubhouse resources will translated into Domain objects per component.

Resource models and collections

All resource types will have their own Model and when retrieving multiple items, the models will be gathered in IteratorAggregate Collections.

This is done so collections retrieved can be iterated over instantly and data is converted into models, so we can use the data in a more specified way and make better use of the data later on.

So for example:

$epics = $connector->epics()->list();

foreach ($epics as $epic) {
    echo $epic->getName();
    echo $epic->getCreatedAt()->format('d-m-Y');
}

Using the services

There will be services created for all components within Clubhouse and subcomponents (labels, categories, comments etc...)

To use a service you'll access it throught the connector as described above.

CRUD examples

  1. Create an Epic
$epic = new Epic();
$epic->setName('My first created Epic')
    ->setDescription('This is the description for my Epic');

$createdEpic = $connector->epics()->create($epic);
  1. Update an existing Epic
$existingEpic = $connector->epics()->get(1);
$existingEpic->setName('A new name for this Epic');

$updatedEpic = $connector->epics()->update($existingEpic);
  1. Delete an Epic
$connector->epics()->delete(1);
  1. List all Epics
$collection = $connector->epics()->list();

Currently usable resources

  • Epics
  • Milestones
  • Projects
  • Stories
$connector->epics()
$connector->milestones()
$connector->projects()
$connector->stories()

PSR Logging

You can add your own logger if you feel the need to catch the logs somewhere :) All you need is a logger which interfaces with PSR-3 logger interface.

When you have that simply construct the connector with it as such:

$logger = new MyOwnPsrLogger();
$connector = new Connector('config.yaml', $logger);

Magic methods

The method and variable names I used in the connector are like getEpicsService() But to make it a bit more relatable with Clubhouse naming and simply a bit shorter, I added magic method calls for the services.

So instead of calling $connector->getEpicsService()->list() You can also call $connector->epics()->list()