Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple API routes in the same module #27601

Open
Monsieur76 opened this issue Jan 18, 2024 · 3 comments
Open

Multiple API routes in the same module #27601

Monsieur76 opened this issue Jan 18, 2024 · 3 comments
Labels
Feature request This is a feature request

Comments

@Monsieur76
Copy link

Monsieur76 commented Jan 18, 2024

Feature Request

added several api files in the same module to make it more readable

Use case

I have a module with several different types of routes created

Suggested implementation

I will be brief
Here are the ones that I added personally to search for the different files of but external module and to be able to create several different routes and several different api_XXX files in a single module

I wanted to know what when to think about community
Thank you
Sorry if my English is not very good

@Monsieur76 Monsieur76 added the Feature request This is a feature request label Jan 18, 2024
@JonBendtsen
Copy link
Contributor

I think it is unclear what you are asking for

@rycks
Copy link
Contributor

rycks commented Mar 12, 2024

Hello @Monsieur76 and @JonBendtsen

i have a dream with PSR-4 for api routes at least for modules. PSR-4 will not imply "composer" but with PSR-4 we could adopt a more "classic way" of file naming convention and objects manipulation.

as @Monsieur76 try to explain, here is an example of a api_file.class.php made with module builder:

use Luracast\Restler\RestException;

/**
 * \file    indirectcustomers/class/api_indirectcustomers.class.php
 * \ingroup indirectcustomers
 * \brief   File for API management of saleshistory.
 */

/**
 * API class for indirectcustomers saleshistory
 *
 * @access protected
 * @class  DolibarrApiAccess {@requires user,external}
 */
class IndirectCustomersApi extends DolibarrApi
{
	/**
	 * @var SalesHistory $saleshistory {@type SalesHistory}
	 */
	public $saleshistory;

	/*begin methods CRUD*/
	/*CRUD FOR SALESHISTORY*/

	/**
	 * Get properties of a saleshistory object
	 *
	 * Return an array with saleshistory informations
	 *
	 * @param 	int 	$id 			ID of saleshistory
	 * @return  Object              	Object with cleaned properties
	 *
	 * @url	GET saleshistory/{id}
	 *
	 * @throws RestException 401 Not allowed
	 * @throws RestException 404 Not found
	 */
	public function get($id)
         {
         }
.../...

ok, that "get" function is entry point for ONE object from my module, but now how could we implement an OTHER get entry point for an OTHER object of the same module ?

@rycks
Copy link
Contributor

rycks commented Mar 12, 2024

@eldy as you explain to me on french forum, here is one of the point i try to explain on https://www.dolibarr.fr/forum/t/rfc-api-dolibarr-applications-mobiles/45780/18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request This is a feature request
Projects
None yet
Development

No branches or pull requests

3 participants