2017 © Pedro Peláez
 

library api-client

CanapeCRM HTTP API client

image

canapecrm/api-client

CanapeCRM HTTP API client

  • Thursday, June 29, 2017
  • by CanapeCRM
  • Repository
  • 0 Watchers
  • 0 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

canapecrm-client

Canape CRM API implementation, (*1)

Package provides basic integration methods implementation. Deal creation and retrieving DealType and Event lists are available in the current version., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist canapecrm/api-client

or add, (*5)

canapecrm/api-client

to the require section of your composer.json file., (*6)

Usage

Configure your canapecrm.ru domain and access token. The Deal creation example is below:, (*7)

$oClient = new CanapeCrmApi\ClientLib( '<domain>.canapecrm.ru', CANAPECRM_ACCESS_TOKEN );

For security, keep access token definition CANAPECRM_ACCESS_TOKEN in the secure place out from version control., (*8)

try {
    $oResponse = $oClient->createDeal(
        (new CanapeCrmApi\models\NewDeal())
            ->setDomain( $_SERVER['SERVER_NAME'] )
            ->setDealTitle( 'Deal Castle Manufacture website ' . date( "H:i:s d.m.Y" ) )
            ->setDealContent( 'A cannonball for riding on' )
            ->setContactClient( 'Baron Munchausen' )
            ->setContactEmail( 'baron@crm.saas' )
            ->setContactPhone( '+1720 (0511) 97-02-22' )
            /* Works only with auto invoice settings */
            ->addCatalogItem(
                (new CanapeCrmApi\models\Catalog())
                    ->setIndex('CB690')
                    ->setTitle( 'Pumhart von Steyr cannonball' )
                    ->setCount( 1 )
                    ->setPrice( 2000 )
            )
    );

    /**
     * Array with new deal id
     * [ 'id' => <id> ]
     * Optionally returns a href to the generated document
     * [ 'id' => <id>,
     *    'form|offer|invoice' => <url>
     * ]
     */
    $oResponse->json();

} catch ( \CanapeCrmApi\exception\CanapeCrmClientException $e ) {

    /**
     * Catch api-client exceptions such as required fields validation errors
     */

} catch ( GuzzleHttp\Exception\RequestException $e ) {
    echo $e->getRequest() . "\n";
    if ( $e->hasResponse() ) {


        $e->getResponse()->json();
    }
}

To perform Deal separation by type and event use method results:, (*9)

$oResponse = $oClient->getDealTypes(); // ->getEvents()
$oResponse->json();

Then you can set it on deal creation:, (*10)

$oResponse = $oClient->createDeal(
    (new CanapeCrmApi\models\NewDeal())
        ...
        ->setEventId( <id> )
        ->setDealTypeId( <id> )
        ...
);

Provide a result of javascript counter via method: ... ->setCanapeUuid( <uuid> ) ..., (*11)

The Versions

29/06 2017

dev-master

9999999-dev https://www.canapecrm.ru/

CanapeCRM HTTP API client

  Sources   Download

Apache-2.0

The Requires

 

29/06 2017

dev-develop

dev-develop https://www.canapecrm.ru/

CanapeCRM HTTP API client

  Sources   Download

Apache-2.0

The Requires

 

29/06 2017

1.0.0

1.0.0.0 https://www.canapecrm.ru/

CanapeCRM HTTP API client

  Sources   Download

Apache-2.0

The Requires

 

28/06 2017

1.0.0-alpha

1.0.0.0-alpha https://www.canapecrm.ru/

CanapeCRM HTTP API client

  Sources   Download

Apache-2.0

The Requires