2017 © Pedro Peláez
 

library teamleader-api-client

PHP client to connect to the Teamleader API

image

nascom/teamleader-api-client

PHP client to connect to the Teamleader API

  • Tuesday, April 17, 2018
  • by stijndm
  • Repository
  • 4 Watchers
  • 6 Stars
  • 554 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 12 Versions
  • 18 % Grown

The README.md

The updated API client is currently under development at the v2 branch, (*1)

TeamleaderApiClient

PHP client to connect to the Teamleader API., (*2)

Installation

The package is available via composer:, (*3)

$ composer require nascom/teamleader-api-client

Basic usage

Setup

First, you'll need to provide a client that can make HTTP requests. It has to implement the HttpClientInterface. A client using Guzzle is already available in the package. This requires installing guzzlehttp/guzzle., (*4)

<?php

use Nascom\TeamleaderApiClient\Http\HttpClient\GuzzleHttpClient;

$guzzle = new \GuzzleHttp\Client(['base_uri' => 'https://www.teamleader.be/api/']);
$httpClient = new GuzzleHttpClient($guzzle);

You can use this HttpClient to instantiate the actual API client. You'll have to provide your Teamleader API credentials as well., (*5)

<?php

use Nascom\TeamleaderApiClient\Http\ApiClient\ApiClient;

$teamleaderParameters = [
    'api_group' => '12345',
    'api_secret' => 'XXXXXXXXXXXXXXX'
];

$client = new ApiClient(
    $httpClient, // A client implementing HttpClientInterface.
    $teamleaderParameters // An array containing the Teamleader credentials.
);

Making requests

Every API endpoint has a corresponding Request class. These classes have to be passed to the client's handle() method, which will return a Response object. All available requests can be found here., (*6)

For example, here is how you could fetch the details of a project:, (*7)

<?php

use Nascom\TeamleaderApiClient\Request\Project\RetrieveProjectRequest;

$projectRequest = new RetrieveProjectRequest(23);
$response = $client->handle($projectRequest);

echo $response->getData(); // Returns the Teamleader JSON response as a string.

Advanced features

Providing extra options

Extra options can be passed to the ApiClient. These will be merged with some default options, and passed to the HttpClient on making a request., (*8)

<?php

$client = new ApiClient(
    $httpClient,
    $teamleaderParameters,
    ['connect_timeout' => 5.0] // This will override the default timeout.
);

Creating a custom HttpClient

You can create a custom HttpClient to handle requests. All it has to do is implement the HttpClientInterface. You could, for example, implement a client using curl., (*9)

<?php

use Nascom\TeamleaderApiClient\Http\HttpClient\HttpClientInterface;

class CurlHttpClient implements HttpClientInterface
{
    public function request($method, $uri, array $options = [])
    {
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => 'https://www.teamleader.be/api/' . $uri,
            CURLOPT_POST => 1,
            CURLOPT_POSTFIELDS => $options['form_params']
        ));

        $response = curl_exec($curl);
        curl_close($curl);

        return $response;
    }
}

$client = new ApiClient(
    new CurlHttpCLient(),
    $teamleaderParameters
);

The Versions

17/04 2018

dev-master

9999999-dev

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

17/04 2018

v1.x-dev

1.9999999.9999999.9999999-dev

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

17/04 2018

v2.x-dev

2.9999999.9999999.9999999-dev

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

04/10 2017

v1.0.6

1.0.6.0

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

04/10 2017

dev-update-creditnote-variables

dev-update-creditnote-variables

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

04/10 2017

v1.0.5

1.0.5.0

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

31/05 2017

v1.0.4

1.0.4.0

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

26/05 2017

v1.0.3

1.0.3.0

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

26/05 2017

dev-develop

dev-develop

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

12/04 2017

v1.0.2

1.0.2.0

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

12/04 2017

v1.0.1

1.0.1.0

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader

12/04 2017

v1.0.0

1.0.0.0

PHP client to connect to the Teamleader API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Gerarts
by Stijn De Meyere
by Stephan Bisschop

api teamleader