From a68d2fe91e3879cb27c49c680659d55db9b00c2a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 11:37:16 +0200 Subject: [PATCH 1/3] NEW API get thirdparty by barcode --- .../societe/class/api_thirdparties.class.php | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 1efe6287c66..f6ff117a846 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -67,7 +67,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param int $id ID of thirdparty + * @param int $id Id of third party to load * @return array|mixed data without useless information * * @throws RestException @@ -82,7 +82,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param string $email Sort field + * @param string $email Email of third party to load * @return array|mixed data without useless information * * @url GET byEmail/{email} @@ -93,6 +93,23 @@ class Thirdparties extends DolibarrApi { return $this->_fetch('', '', '', '', '', '', '', '', '', '', $email); } + + /** + * Get properties of a thirdparty object by barcode. + * + * Return an array with thirdparty informations + * + * @param string $Barcode Barcode of third party to load + * @return array|mixed data without useless information + * + * @url GET barcode/{barcode} + * + * @throws RestException + */ + public function getByBarcode($barcode) + { + return $this->_fetch('', '', '', $barcode); + } /** * List thirdparties @@ -1810,7 +1827,7 @@ class Thirdparties extends DolibarrApi * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) - * @param string $ref_int Internal reference of third party (not used by dolibarr) + * @param string $barcode Barcode of third party to load * @param string $idprof1 Prof id 1 of third party (Warning, this can return several records) * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) @@ -1823,14 +1840,14 @@ class Thirdparties extends DolibarrApi * * @throws RestException */ - private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') + private function _fetch($rowid, $ref = '', $ref_ext = '', $barcode = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') { global $conf; if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias); + $result = $this->company->fetch($rowid, $ref, $ref_ext, $barcode, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias); if (!$result) { throw new RestException(404, 'Thirdparty not found'); } From 26f812b73bc5ecda3171eda0e62f73d1f4176929 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 29 Aug 2020 09:39:10 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/societe/class/api_thirdparties.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index f6ff117a846..514d92bfaee 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -93,7 +93,7 @@ class Thirdparties extends DolibarrApi { return $this->_fetch('', '', '', '', '', '', '', '', '', '', $email); } - + /** * Get properties of a thirdparty object by barcode. * From 12676d020a237e718742c6627a0baa25f5d9ab82 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 11:43:56 +0200 Subject: [PATCH 3/3] Update api_thirdparties.class.php --- htdocs/societe/class/api_thirdparties.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 514d92bfaee..ba807fa1706 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -99,7 +99,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param string $Barcode Barcode of third party to load + * @param string $barcode Barcode of third party to load * @return array|mixed data without useless information * * @url GET barcode/{barcode}