Coder Social home page Coder Social logo

sumocoders / teamleader-oauth2 Goto Github PK

View Code? Open in Web Editor NEW
3.0 5.0 0.0 28 KB

PHP Teamleader oauth2 package to connect with Teamleader API (https://developer.teamleader.eu/)

License: BSD 2-Clause "Simplified" License

PHP 100.00%
teamleader oauth2

teamleader-oauth2's Introduction

Teamleader oauth2

Installation

composer require sumocoders/teamleader-oauth2

Setup

This package uses PSR-17 and PSR-18. You can use any implementation you want.

For saving the access we provide a TokenStorageInterface, where you'll need to implement storing and fetching of the tokens:

interface TokenStorageInterface
{
    public function getTokenType(): string;
    public function getAccessToken(): ?string;
    public function getRefreshToken(): ?string;
    public function isExpired(): bool;
    public function storeTokens(array $tokens): void;
}

Look at the default token storage class how you can make your own implementation.

The Teamleader class will need a clientId and clientSecret. Which you'll need to obtain at the Teamleader marketplace.

Usage

To obtain an access token you'll need to call:

$teamleader->acquireAccessToken($redirectUrl, $code);

Where $redirectUrl is the url you want Teamleader to come back to after Oauth2 authentication and $code is for the return when Teamleader comes back to your site and validate the authentication.

After that you can use the Teamleader class to make calls to the Teamleader API. When the access token is expired the Teamleader class will automatically refresh the token.

Getting data

$teamleader->get('users.me');
$teamleader->get('departments.list');
$teamleader->get('companies.list');

Posting data

$teamleader->post(
    'contacts.add',
    [
        'first_name' => 'John',
        'last_name' => 'Doe',
    ]
);
$teamleader->post(
    'contacts.update',
    [
        'id' => 'xxx',
        'first_name' => 'John',
        'last_name' => 'Doe',
        'emails' => [
            ['type' => 'primary', 'email' => '[email protected]'],
        ],
    ]
)

teamleader-oauth2's People

Contributors

jonasdekeukelaere avatar tijsverkoyen avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.