Giter VIP home page Giter VIP logo

teamgate-php-sdk's Introduction

Teamgate API SDK for PHP

A cloud-based intelligent Sales CRM for small and mid-size teams. With its simple yet playful interface, Teamgate is a great sales stack for today’s business. See https://www.teamgate.com for details. This is the official Teamgate API wrapper-client for PHP based apps, distributed by Teamgate Ltd. freely under the MIT licence.

Prerequisites

You will need to make sure your server meets the following requirements:

  • PHP >= 5.5
  • The PHP cURL extension

Getting Started

You can install via composer or by downloading the source. Teamgate API client utilizes Composer to manage its dependencies. So, before using Teamgate API client, make sure you have Composer installed on your machine.

Install Composer In Your Project

Run this in your command line:

curl -sS https://getcomposer.org/installer | php

Installation

To install run:

composer require teamgate/php-api-sdk:dev-master

Autoloading

For libraries that specify autoload information, Composer generates a vendor/autoload.php file. You can simply include this file and you will get autoloading for free.

require __DIR__ . '/vendor/autoload.php';

Basic Usage

Here's a quick example that will list some deals from your Teamgate account:

require __DIR__ . '/vendor/autoload.php';

$api = new \Teamgate\API([
    'apiKey' => '_YOUR_ACCOUNT_API_KEY_', // located at account settings -> additional features -> external apps
    'authToken' => '_YOUR_PERSONAL_AUTH_TOKEN_' // located at user settings -> preferences
]);

$result = $api->deals->get([
        'offset' => 0, 
        'limit' => 10
    ]
);
var_dump($result);

Lead management is an important part of any sales process. Create a new lead automatically whenever a visitor fills out a form on your site:

require __DIR__ . '/vendor/autoload.php';

$api = new \Teamgate\API([
    'apiKey' => '_YOUR_ACCOUNT_API_KEY_', // located at account settings -> additional features -> external apps
    'authToken' => '_YOUR_PERSONAL_AUTH_TOKEN_' // located at user settings -> preferences
]);

$result = $api->leads->create(
  [
    'title' => 'The Company Name'
  ]
);
var_dump($result);

Error Handling

When you instantiate a client or make any request via service objects, exceptions can be raised for multiple of reasons e.g. a server error, an authentication error, an invalid params and etc.

Below shows how to properly handle exceptions:

require __DIR__ . '/vendor/autoload.php';

try 
{
  $api = new \Teamgate\API([
      'apiKey' => '_YOUR_ACCOUNT_API_KEY_', // located at account settings -> additional features -> external apps
      'authToken' => '_YOUR_PERSONAL_AUTH_TOKEN_' // located at user settings -> preferences
  ]);
  $result = $api->leads->create(
    [
      'title' => 'The Company Name'
    ]
  ));
  var_dump($result);
} 
catch (Teamgate\Exception\ValidationException $e) 
{
  /* Invalid client configuration */
} 
catch (Teamgate\Exception\TransportException $e) 
{
  var_dump($e->getCode()); // HTTP Status Code
  var_dump($e->output); // Teamgate API Output
}
catch (Teamgate\Exception\ResponseException $e) 
{
  /* Invalid query parameters or etc. */
}
catch (Exception $e)
{
  /* Other kind of exception */
}

Advanced Usage

For example retrieve all companies from your Teamgate account and change their logos by website domain through Clearbit API:

require __DIR__ . '/vendor/autoload.php';

$api = new \Teamgate\API([
    'apiKey' => '_YOUR_ACCOUNT_API_KEY_', // located at account settings -> additional features -> external apps
    'authToken' => '_YOUR_PERSONAL_AUTH_TOKEN_' // located at user settings -> preferences
]);

$result = $api->companies->get([
        'offset' => 0, 
        'limit' => 10
    ]
);

foreach($result as $company) {
    if (!empty($company->data['urls']) && !empty($company->data['urls'][0] && !empty($company->data['urls'][0]['value']))
    {
        list($domain) = parse_url($company->data['urls'][0]['value'], PHP_URL_HOST);
        $logo = file_get_contents('https://logo.clearbit.com/' . $domain);
        if ($logo) {
            $company->changeLogo(
                [
                    'size' => strlen($logo),
                    'content' => base64_encode($logo)
                ]
            );
        }
    }
}

var_dump($result);

Documentation

The documentation for the Teamgate API is located at http://docs.teamgate.com/reference/

Getting Help

If you need help installing or using the library, please contact Teamgate Support at [email protected]. If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

teamgate-php-sdk's People

Contributors

outsidaz 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.