A PHP package to access the Holded API by a comprehensive way
The preferred way to install this extension is through composer.
With Composer installed, you can then install the extension using the following commands:
$ php composer.phar require homedoctor-es/holded-php-sdk
or add
...
"require": {
"homedoctor-es/holded-php-sdk": "*"
}
to the require
section of your composer.json
file.
You can set the HOLDED_API_TOKEN as environment variables or add them later on Holded class instantiation.
The name of the environment var is HOLDED_API_KEY.
Endpoints calls must done through the Holded class.
If you haven't set the environment variable previously, remember to provide the key on instantiation.
$holded = new \HomedoctorEs\Holded\Holded($holdedApiKey); // or Holded::make($holdedApiKey)
$holded->contact()->list();
At this moment, only can be managed 2 entities with this SDK: contacts and documents
To check contacts entity requirements and fields, you can see https://developers.holded.com/reference#contacts
The contacts entity use these methods
$holded->contact()->list();
$holded->contact()->get($id);
$holded->contact()->create($data); //$data = []
$holded->contact()->update($data); //$data = []
$holded->contact()->delete($id);
To check documents entity requirements and fields, you can see https://developers.holded.com/reference#documents
The contacts entity use these methods
$holded->document()->list();
$holded->document()->get($id);
$holded->document()->create($data); //$data = []
$holded->document()->update($data); //$data = []
$holded->document()->delete($id); //$data = []
"docType" default value is invoice, if you want to instantiate another kind of document, you can pass docType param to document method
$document = $holded->document(Document::PURCHASE_ORDER);
Check Document class constants to see the kind of docType you can use
If you want to instantiate directly and invoice document you can do it using ->invoice() method
$invoice = $holded->invoice();