oaoa / naturhouse-api-v2
API client for Naturhouse CRM
v0.1.0
2020-02-26 16:51 UTC
Requires
- guzzlehttp/guzzle: ^6.5
- nette/utils: ^3.1
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is not auto-updated.
Last update: 2024-05-03 10:51:08 UTC
README
This library is open source client library for Naturhouse CRM, mainly for support affiliate partners. API description https://naturhouseapiv2.docs.apiary.io/
Naturhouse public API supports:
- get list of branches
- get list of packages provided for clients
- get list of contact times (possibilities when to call to created contact)
- create contact
- get created contact (to verify its state)
Instalation
using composer:
$ composer require oaoa/naturhouse-api-v2
Basic usage
The simplest scenario is:
- fetch list of active branches
- create contact
- check contact state
$configuration = [ 'hostname' => 'https://kalendar.naturhouse-cz.cz/api/v2/', 'auth_token' => 'seecret token; you can get one from Naturhouse', ]; $client = new \Naturhouse\Client($configuration); // fetch list of all active branches $branches = $client->getBranches(); // prepare contact data $contact = new \Naturhouse\Entities\Contact(); $contact->setFname('krestni'); $contact->setLname('prijmeni'); $contact->setBranch($branches[0]->getId()); $contact->setNote('testovaci kontakt'); // create contact try{ $response = $client->createContact($contact); $contactId = $response->getId(); //fetch contact state $fetchedContact = $client->getContact($contactId); // print contact state var_dump($fetchedContact->getStatus()); } catch(\Naturhouse\Exceptions\ClientException $e) { echo $e->getMessage(); }
notes
Be careful, branches can change in > 10 minutes, so do NOT cache them longer than day. If you create contact to inactive branch, API will respond with error.