From 6df4a5eded603ef6ff51fae451b70eca7fe0acd4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Mar 2024 16:41:33 +0100 Subject: [PATCH] Use a better name for thirdparties site account --- ChangeLog | 2 +- htdocs/core/lib/company.lib.php | 3 -- .../societe/class/api_thirdparties.class.php | 46 +++++++++---------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a123336552..25688ef0ccb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,7 +29,7 @@ The following changes may create regressions for some external modules, but were * Use of dol_eval with parameter $returnvalue=0 is deprecated. * The signature for all ->delete() method has been modified to match the modulebuilder template (so first paramis now always $user), except the delete for thirdparty (still accept the id of thirdparty to delete as first parameter). Will probably be modified into another version. - +* Route for API /thirdparties/gateways has been renamed into /thirdparties/accounts ***** ChangeLog for 19.0.1 compared to 19.0.0 ***** diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 7fca6289c95..7c7fc412669 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -197,9 +197,6 @@ function societe_prepare_head(Societe $object) $title = $langs->trans("PaymentModes"); if (isModEnabled('stripe')) { - //$langs->load("stripe"); - //$title = $langs->trans("BankAccountsAndGateways"); - $servicestatus = 0; if (getDolGlobalString('STRIPE_LIVE') && !GETPOST('forcesandbox', 'alpha')) { $servicestatus = 1; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 0f88fefbd2c..612c9c7852c 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1371,7 +1371,7 @@ class Thirdparties extends DolibarrApi } /** - * Get a specific gateway attached to a thirdparty (by specifying the site key) + * Get a specific account attached to a thirdparty (by specifying the site key) * * @param int $id ID of thirdparty * @param string $site Site key @@ -1380,7 +1380,7 @@ class Thirdparties extends DolibarrApi * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty * - * @url GET {id}/gateways/ + * @url GET {id}/accounts/ */ public function getSocieteAccounts($id, $site = null) { @@ -1404,7 +1404,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) == 0) { - throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.'); + throw new RestException(404, 'This thirdparty does not have any account attached or does not exist.'); } $i = 0; @@ -1440,7 +1440,7 @@ class Thirdparties extends DolibarrApi } /** - * Create and attach a new gateway to an existing thirdparty + * Create and attach a new account to an existing thirdparty * * Possible fields for request_data (request body) are specified in llx_societe_account table.
* See Table llx_societe_account wiki page for more information

@@ -1452,11 +1452,11 @@ class Thirdparties extends DolibarrApi * @return array|mixed * * @throws RestException 401 Unauthorized: User does not have permission to read thirdparties - * @throws RestException 409 Conflict: A SocieteAccount entity (gateway) already exists for this company and site. + * @throws RestException 409 Conflict: An Account already exists for this company and site. * @throws RestException 422 Unprocessable Entity: You must pass the site attribute in your request data ! * @throws RestException 500 Internal Server Error: Error creating SocieteAccount account * - * @url POST {id}/gateways + * @url POST {id}/accounts */ public function createSocieteAccount($id, $request_data = null) { @@ -1501,10 +1501,10 @@ class Thirdparties extends DolibarrApi } /** - * Create and attach a new (or replace an existing) specific site gateway to a thirdparty + * Create and attach a new (or replace an existing) specific site account to a thirdparty * * You MUST pass all values to keep (otherwise, they will be deleted) !
- * If you just need to update specific fields prefer PATCH /thirdparties/{id}/gateways/{site} endpoint.

+ * If you just need to update specific fields prefer PATCH /thirdparties/{id}/accounts/{site} endpoint.

* When a SocieteAccount entity does not exist for the id and site * supplied, a new one will be created. In that case fk_soc and site members form * request body payload will be ignored and id and site query strings parameters @@ -1520,7 +1520,7 @@ class Thirdparties extends DolibarrApi * @throws RestException 422 Unprocessable Entity: You must pass the site attribute in your request data ! * @throws RestException 500 Internal Server Error: Error updating SocieteAccount entity * - * @url PUT {id}/gateways/{site} + * @url PUT {id}/accounts/{site} */ public function putSocieteAccount($id, $site, $request_data = null) { @@ -1564,7 +1564,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) !== 0) { - throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site']." but another SocieteAccount entity already exists with this site key."); + throw new RestException(409, "You are trying to update this thirdparty Account for $site to ".$request_data['site']." but another Account already exists with this site key."); } } @@ -1601,7 +1601,7 @@ class Thirdparties extends DolibarrApi } /** - * Update specified values of a specific gateway attached to a thirdparty + * Update specified values of a specific account attached to a thirdparty * * @param int $id Id of thirdparty * @param string $site Site key @@ -1614,7 +1614,7 @@ class Thirdparties extends DolibarrApi * @throws RestException 409 Conflict: Another SocieteAccount entity already exists for this thirdparty with this site key. * @throws RestException 500 Internal Server Error: Error updating SocieteAccount entity * - * @url PATCH {id}/gateways/{site} + * @url PATCH {id}/accounts/{site} */ public function patchSocieteAccount($id, $site, $request_data = null) { @@ -1626,7 +1626,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) == 0) { - throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist."); + throw new RestException(404, "This thirdparty does not have $site account attached or does not exist."); } else { // If the user tries to edit the site member, we check first if if (isset($request_data['site']) && $request_data['site'] !== $site) { @@ -1634,7 +1634,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) !== 0) { - throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from ".$site." to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key."); + throw new RestException(409, "You are trying to update this thirdparty Account for ".$site." to ".$request_data['site']." but another Account already exists for this thirdparty with this site key."); } } @@ -1663,17 +1663,17 @@ class Thirdparties extends DolibarrApi } /** - * Delete a specific site gateway attached to a thirdparty (by gateway id) + * Delete a specific site account attached to a thirdparty (by account id) * * @param int $id ID of thirdparty * @param int $site Site key * * @return void - * @throws RestException 401 Unauthorized: User does not have permission to delete thirdparties gateways + * @throws RestException 401 Unauthorized: User does not have permission to delete thirdparties accounts * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty * @throws RestException 500 Internal Server Error: Error deleting SocieteAccount entity * - * @url DELETE {id}/gateways/{site} + * @url DELETE {id}/accounts/{site} */ public function deleteSocieteAccount($id, $site) { @@ -1692,22 +1692,22 @@ class Thirdparties extends DolibarrApi $account->fetch($obj->rowid); if ($account->delete(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, "Error while deleting $site gateway attached to this third party"); + throw new RestException(500, "Error while deleting $site account attached to this third party"); } } } /** - * Delete all gateways attached to a thirdparty + * Delete all accounts attached to a thirdparty * * @param int $id ID of thirdparty * * @return void - * @throws RestException 401 Unauthorized: User does not have permission to delete thirdparties gateways + * @throws RestException 401 Unauthorized: User does not have permission to delete thirdparties accounts * @throws RestException 404 Not Found: Specified thirdparty ID does not belongs to an existing thirdparty * @throws RestException 500 Internal Server Error: Error deleting SocieteAccount entity * - * @url DELETE {id}/gateways + * @url DELETE {id}/accounts */ public function deleteSocieteAccounts($id) { @@ -1725,7 +1725,7 @@ class Thirdparties extends DolibarrApi $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) == 0) { - throw new RestException(404, 'This third party does not have any gateway attached or does not exist.'); + throw new RestException(404, 'This third party does not have any account attached or does not exist.'); } else { $i = 0; @@ -1736,7 +1736,7 @@ class Thirdparties extends DolibarrApi $account->fetch($obj->rowid); if ($account->delete(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error while deleting gateways attached to this third party'); + throw new RestException(500, 'Error while deleting account attached to this third party'); } $i++; }