Example of changing the order of photos
You can change the order of the ad photos and the main photo in three ways. The rules are the same for all of them, see Order and main photo.
1. Several photos at once: the sub-agenda photo/sort
Read the photos of the ad:
GET https://api.tipmoto.com/c/{dealer ID}/moto/{ad ID}/photo.xml
The output contains id and sortOrder (position, 1 = main photo) for each photo. Put the photos in the order you need and send them in photos – id is enough:
PUT https://api.tipmoto.com/c/{dealer ID}/moto/{ad ID}/photo/sort.xml
<tipmoto>
<photos>
<!-- the first item becomes the main photo -->
<photo><id>11</id></photo>
<photo><id>2</id></photo>
<photo><id>3</id></photo>
<!-- photos that are not in the list are placed after them in their existing order -->
</photos>
</tipmoto>
The same in JSON (PUT to …/photo/sort.json):
{
"tipmoto": {
"photos": {
"photo": [
{"id": "11"},
{"id": "2"},
{"id": "3"}
]
}
}
}
You can try the result first with the parameter ?dry-run=true – nothing is saved and the response shows the resulting order.
You can also send the whole reordered photo.xml output (the photos wrapped in photos); the other elements are ignored, only the sortOrder elements have to be left out.
Details are described in the sub-agenda photo/sort.
2. One photo: PUT /photo/{id}
To move photo 7 to position 2 (the main photo stays the same):
PUT https://api.tipmoto.com/c/{dealer ID}/moto/{ad ID}/photo/7.xml
<tipmoto>
<photo>
<sortOrder>2</sortOrder>
</photo>
</tipmoto>
To make photo 7 the main photo (it moves to position 1, the other photos keep their relative order):
<tipmoto>
<photo>
<main>1</main>
</photo>
</tipmoto>
3. In the ad import: photos
In the import of the whole ad (example), the order changes only on explicit request: main = 1 or sortOrder for a photo, or the attribute reorder="true", which sorts the gallery by the order of the photos in photos:
<photos reorder="true">
<photo><url>https://www.sellersweb.com/ph/AB-198_3.jpg</url></photo>
<photo><url>https://www.sellersweb.com/ph/AB-198_1.jpg</url></photo>
<photo><url>https://www.sellersweb.com/ph/AB-198_2.jpg</url></photo>
</photos>
Without reorder, main and sortOrder, the import does not change the order of the photos – the order the dealer set in the administration is kept as well.
