Vaisonet/Sellsy-api

retrieve the value doc_id

Closed this issue · 2 comments

Hello
in the API documentation I used .$document->response->doc_id to get the invoice number.

Your plugin allows me to retrieve :
[57411503526fa]2016-05-22T04:10:11+02:00 --> {"method":"Document.create","params":{"document":{"doctype":"invoice","thirdid":"6074622","subject":"1818181818","notes":"1818181818","tags":""}}} [57411503526fa]2016-05-22T04:10:13+02:00 <-- {"doc_id":3773837} array(1) { ["doc_id"]=> int(3773837) }

how can I please retrieve this value doc_id

Thank you

Hi,

It depends on the method you used.
In the following example, doc_id is in the variable $docId:

// Synchronous
$docId = $client->getService('Document')->call('create', [...])['doc_id'];

// Asynchronous
$promise = $client->getService('Document')->callAsync('create', [...])->then(function($res) {
    $docId = $res['doc_id'];
});
$promise->wait();

Regards,

Julien

Thank you very match.