coderjerk / scoro-php
Scoro API Client
v0.1.1
2023-02-03 18:30 UTC
Requires
- guzzlehttp/guzzle: ^7.0
- guzzlehttp/oauth-subscriber: ^0.6.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^5.1
- vlucas/phpdotenv: ^5.2
README
This an unofficial library for interacting with the Scoro Rest API.
Install
Install with composer.
composer require coderjerk/scoro-php
Examples
Instantiate the class
use Coderjerk\ScoroPhp\ScoroPhp; //add your company account id and api key, which you've stored safely in your env, for example. $scoro = new ScoroPhp( $_ENV['SCORO_COMPANY_ACCOUNT_ID'], $_ENV['SCORO_API_KEY'], );
The library provides a fluent interface, allowing you to build your query with method chaining
$contacts = $scoro->module('contacts')->action('list')->call(); foreach ($contacts->data as $contact) { echo "<li>{$contact->name}</li>"; }
Add filters to your query
$scoro->module('contacts') ->action('list') ->filter(['contact_type' => 'company']) ->call(); // you can dig in deep by nesting arrays depending on your data/module: $filters = [ 'contact_type' => 'company', 'means_of_contact' => [ 'website' => 'www.exampleclienta.co.uk' ] ]; $scoro->module('contacts') ->action('list') ->filter($filters)->call();
Use the id()
method to target a single entity
$scoro->module('contacts') ->action('view') ->id(36) ->call();
Use the paginate()
method to set page and per page values
$scoro->module('contacts') ->action('list') ->paginate(10, 2) ->call();
Method Reference
All methods are optional bar module which must always be specified. In practice, this applies to action too in the vast majority of cases. End with call()
to make the request.
Reference
Obviously you'll need a Scoro account to use the API. Read their API Reference for information about restrictions and rate limiting, and details of available endpoints.