getJsonContent("thirdparties" , [ "limit" => "1", "sqlfilters" => "ref_int=" . $organizationId])[0]; } /** * Get the first active contract for the given dolibarr society * * @param int $socId * @return array|null */ public function getActiveContract(int $socId): ?array { try { return $this->getJsonContent( "contracts", ["limit" => "1", "sqlfilters" => "statut=1", "thirdparty_ids" => $socId] )[0]; } catch (HttpException $e) { if ($e->getStatusCode() === 404) { // /!\ The dolibarr API will return a 404 error if no results are found... return null; } throw $e; } } /** * Get a society bills by their society id * * @param int $socId * @return array */ public function getBills(int $socId): array { try { return $this->getJsonContent( "invoices", ["sortfield" => "datef", "sortorder" => "DESC", "limit" => 5, "sqlfilters" => "fk_soc=" . $socId]); } catch (HttpException $e) { if ($e->getStatusCode() === 404) { // /!\ The dolibarr API will return a 404 error if no results are found... return []; } throw $e; } } /** * Get all the societies which are Opentalent client * @throws HttpException */ public function getAllClients(): array { return $this->getJsonContent( "thirdparties", ["limit" => "1000000", "sqlfilters" => "client=1"] ); } /** * Get the society contacts * * @throws HttpException */ public function getContacts(int $socId): array { try { return $this->getJsonContent( "contacts", ['limit' => 1000, 'thirdparty_ids' => $socId], ); } catch (HttpException $e) { if ($e->getStatusCode() === 404) { // /!\ The dolibarr API will return a 404 error if no results are found... return []; } throw $e; } } /** * Get the society contacts that have a non-null personId * * @throws HttpException */ public function getActiveOpentalentContacts(int $socId): array { // On est obligé ici de passer la query en dur, sinon les parenthèses sont encodées, // et dolibarr est pas content :( try { return $this->getJsonContent( "contacts?limit=1000&t.statut=1&thirdparty_ids=" . $socId . "&sqlfilters=(te.2iopen_person_id%3A%3E%3A0)" ); } catch (HttpException $e) { if ($e->getStatusCode() === 404) { // /!\ The dolibarr API will return a 404 error if no results are found... return []; } throw $e; } } }