Module Web Services API REST (developer): Difference between revisions

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
Tag: 2017 source edit
mNo edit summary
Tag: 2017 source edit
Line 44: Line 44:


You can then test directly from this explorer any API. This is the recommended solution to test any Dolibarr API since any API and parameters is documented here. As a result of any test, you will get the answer but also example on how to call the API from command line using '''curl'''.
You can then test directly from this explorer any API. This is the recommended solution to test any Dolibarr API since any API and parameters is documented here. As a result of any test, you will get the answer but also example on how to call the API from command line using '''curl'''.
= Adding a new service =
Adding a new REST service is as easy than adding a file called '''api_mymoduleobject.class.php''' into the directory '''htdocs/module/class'''.
You take the example into '''htdocs/commande/class/api_orders.class.php'''
The framework detects automatically the API and it should be visible into the explorer.
Method and parameters are detected according to introspection done into PHP class of the object ('''htdocs/module/class/object.class.php''') using the '''annotations''' found into the class.
For a documentation about annotation: https://github.com/Luracast/Restler/blob/master/ANNOTATIONS.md


= Installation =
= Installation =
Line 304: Line 295:
* we get the customer ID in $clientDoliId
* we get the customer ID in $clientDoliId


= Conclusion =
= Develop your own service / API =
Adding a new REST service is as easy than adding a file called '''api_mymoduleobject.class.php''' into the directory '''htdocs/mymodule/class'''.
You take the example into '''htdocs/commande/class/api_orders.class.php'''
 
Note that if you use the '''modulebuilder''' tool, the file may be generated for you.
 
The framework detects automatically the API and it should be visible into the explorer.
 
Method and parameters are detected according to introspection done into PHP class of the object ('''htdocs/mymodule/class/object.class.php''') using the '''annotations''' found into the class.
For a documentation about annotation: https://github.com/Luracast/Restler/blob/master/ANNOTATIONS.md
 
These are just the basics.


These are just the basics.<br/>
Some more informations in the Dolibarr code. You can look here : htdocs/<directory>/class/api_xxx_class.php<br/>
Some more informations in the dolibarr code. You can look here : htdocs/<directory>/class/api_xxx_class.php<br/>
Ex : htdocs/societe/class/api_thirdparties.class.php for thirdparties.<br/>
Ex : htdocs/societe/class/api_thirdparties.class.php for thirdparties.<br/>
Invoices are in htdocs/compta/facture/class
Ex : Invoices are in htdocs/compta/facture/class<br/>

Navigation menu