Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Updated usage documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Oct 16, 2016
1 parent 188b97e commit f35789f
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,43 @@ Similarly to obtain informations about a specific user you can make a request li

response = mkm.market_place.user(user='SampleUser')

Note that if you need to send data to MKM backend it has to be XML or it will return a 400 Bad Request.
Data can be posted directly as an XML string or formatted in a way that the XMLSerializer can parse it to correctly generate an XML string.

[1]: http://docs.python-requests.org/en/latest/api/?highlight=response#requests.Response
For example this:

data = {
'action': 'add',
'article': [
{'idArticle': 666, 'amount': 2},
{'idArticle': 101, 'amount': 5}
]
}

serializes to:

"""
<?xml version="1.0" encoding="utf-8"?>
<request>
<action>add</action>
<article>
<idArticle>666</idArticle>
<amount>2</amount>
</article>
<article>
<idArticle>101</idArticle>
<amount>5</amount>
</article>
</request>
"""

It's important that dictionaries are always inside a list or they won't be serialized correctly, so if you have only one article to serialize you format it like this:

data = {
'article': [
{'idArticle': 101, 'amount': 10}
]
}

This is the same format used by the MKM backend for their JSON responses.

[1]: http://docs.python-requests.org/en/latest/api/?highlight=response#requests.Response

0 comments on commit f35789f

Please sign in to comment.