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

Jump to navigation Jump to search
m
Tag: 2017 source edit
Tag: 2017 source edit
Line 451: Line 451:
=Develop your own service / API=
=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'''.
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'''
You can take an example into '''htdocs/commande/class/api_orders.class.php'''


Note that if you use the '''modulebuilder''' tool, the file may be generated for you.
Note that if you use the '''modulebuilder''' tool, this file may be generated for you.


The framework detects automatically the API and it should be visible into the explorer.
The framework detects automatically the API files 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.
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.
Line 462: Line 462:
These are just the basics.
These are just the basics.


Some more informations in the Dolibarr code. You can look here : htdocs/<directory>/class/api_xxx_class.php<br />
To find all existing API files in Dolibarr, you can search all files htdocs/<directory>/class/api_xxx_class.php
Ex : htdocs/societe/class/api_thirdparties.class.php for thirdparties.<br />
Ex : htdocs/societe/class/api_contacts.class.php for contacts.<br />
Ex : htdocs/compta/facture/class/api_invoice_class.php for invoices.<br />
Ex : htdocs/mrp/class/api_mos_class.php for manufacturing orders.<br />
Ex : htdocs/product/class/api_products.class.php for contacts.<br />

Navigation menu