...
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <customers> <customer id="1" xlink:href="http://example.com/api/customers/1"/> <customer id="12" xlink:href="http://example.com/api/customers/2"/> <customer id="13" xlink:href="http://example.com/api/customers/3"/> <customer id="14" xlink:href="http://example.com/api/customers/4"/> <customer id="15" xlink:href="http://example.com/api/customers/5"/> <customer id="16" xlink:href="http://example.com/api/customers/76"/> <customer id="17" xlink:href="http://example.com/api/customers/87"/> ... </customers> </prestashop> |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <customer> <id><![CDATA[1]]></id> <id_default_group xlink:href="http://example.com/api/groups/3"><![CDATA[3]]></id_default_group> <id_lang xlink:href="http://example.com/api/languages/1"><![CDATA[1]]></id_lang> <newsletter_date_add><![CDATA[2013-04-23 11:40:52]]></newsletter_date_add> <ip_registration_newsletter></ip_registration_newsletter> <last_passwd_gen><![CDATA[2013-04-23 05:40:52]]></last_passwd_gen> <secure_key><![CDATA[5b402973df21cd42a303a2fdfce91df7]]></secure_key> <deleted><![CDATA[0]]></deleted> <passwd><![CDATA[a747961318242111b33ed551dcff10a9]]></passwd> <lastname><![CDATA[DOE]]></lastname> <firstname><![CDATA[John]]></firstname> <email><![CDATA[[email protected]]]></email> <id_gender><![CDATA[1]]></id_gender> <birthday><![CDATA[1970-01-15]]></birthday> <newsletter><![CDATA[1]]></newsletter> <optin><![CDATA[1]]></optin> <website></website> <company></company> <siret></siret> <ape></ape> <outstanding_allow_amount><![CDATA[0.000000]]></outstanding_allow_amount> <show_public_prices><![CDATA[0]]></show_public_prices> <id_risk><![CDATA[0]]></id_risk> <max_payment_days><![CDATA[0]]></max_payment_days> <active><![CDATA[1]]></active> <note></note> <is_guest><![CDATA[0]]></is_guest> <id_shop><![CDATA[1]]></id_shop> <id_shop_group><![CDATA[1]]></id_shop_group> <date_add><![CDATA[2013-04-23 11:40:52]]></date_add> <date_upd><![CDATA[2013-04-23 11:40:52]]></date_upd> <associations> <groups node_type="group"> <group xlink:href="http://example.com/api/groups/3"> <id><![CDATA[3]]></id> </group> </groups> </associations> </customer> </prestashop> |
Adding and editing a resource
The http://example.com/api/customers/1
example is not only available using the HTTP GET method, but also using POST, PUT, DELETE, HEAD.
Example
The XML file found at http://example.com/api/customers/1
, whose link is found in the list of resources (see above), gives you the properties of customer account that has "1" as its ID.
Thus, by jumping from link to link, you can browse the web service to access all resources in XMLTo add a customer (or any other resource, for that matter), you simply need to GET the XML blank data for the resource (/api/customer?schema=blank
), fill it with your changes, and POST the whole XML file to the /api/customers/
URL again. PrestaShop will take care of adding everything in the database, and will return an XML file indicating that the operation has been successful, along with the ID of the newly created customer.
To edit an existing resource: GET the full XML file for the resource you want to change (/api/customers/7
), edit its content as needed, then PUT the whole XML file back to the same URL again.