InSales API - изображения товаров — различия между версиями

Материал из Insales Wiki
Перейти к: навигация, поиск
(Новая: =Получение всех изображений= Запрос: GET /admin/products/#{product_id}/images.xml Ответ: <pre> HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?>...)
(нет различий)

Версия 12:53, 20 мая 2011

Получение всех изображений

Запрос: GET /admin/products/#{product_id}/images.xml

Ответ:

HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<images type="array">
    <image>
        <created-at type="timestamp">2011-04-04 15:48:33 +0400</created-at>
        <id type="integer">1489191</id>
        <position type="integer">1</position>
        <product-id type="integer">2336153</product-id>
        <url>http://static.insales.ru/images/products/1/6439/1489191/thumb_yhst-71326348041790_2147_5697670.jpg</url>
        <original-url>http://static.insales.ru/images/products/1/6439/1489191/yhst-71326348041790_2147_5697670.jpg</original-url>
        <title nil="true"/>
    </image>
    <image>
        <created-at type="timestamp">2011-04-04 15:48:27 +0400</created-at>
        <id type="integer">1489187</id>
        <position type="integer">2</position>
        <product-id type="integer">2336153</product-id>
        <url>http://static.insales.ru/images/products/1/6435/1489187/thumb_yhst-71326348041790_2147_5571401.jpg</url>
        <original-url>http://static.insales.ru/images/products/1/6435/1489187/yhst-71326348041790_2147_5571401.jpg</original-url>
        <title nil="true"/>
    </image>
</images>

Получение изображения

Запрос: GET /admin/products/#{product_id}/images/#{id}.xml

Ответ:

HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<image>
    <created-at type="timestamp">2011-04-04 15:48:33 +0400</created-at>
    <id type="integer">1489191</id>
    <position type="integer">1</position>
    <product-id type="integer">2336153</product-id>
    <url>http://static.insales.ru/images/products/1/6439/1489191/thumb_yhst-71326348041790_2147_5697670.jpg</url>
    <original-url>http://static.insales.ru/images/products/1/6439/1489191/yhst-71326348041790_2147_5697670.jpg</original-url>
    <title nil="true"/>
</image>

Добавление изображения

Добавлении изображения выложенного в интернет

Запрос: POST /admin/products/#{product_id}/images.xml

<?xml version="1.0" encoding="UTF-8"?>
<image>
    <title>ImageTile</title>
    <src>http://some-hosting.ru/some_image.jpg</src>
</image>

Ответ:

HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<image>
    <created-at type="timestamp">2011-04-04 15:48:33 +0400</created-at>
    <id type="integer">1489191</id>
    <position type="integer">1</position>
    <product-id type="integer">2336153</product-id>
    <url>http://static.insales.ru/images/products/1/6439/1489191/some_image.jpg</url>
    <original-url>http://static.insales.ru/images/products/1/6439/1489191/some_image.jpg</original-url>
    <title>ImageTile</title>
</image>

Передача изображения в теле запроса

Запрос: POST /admin/products/#{product_id}/images.xml

<?xml version="1.0" encoding="UTF-8"?>
<image>
    <title>ImageTile</title>
    <filename>myimage.jpg</filename>
    <attachment>
/9j/4AAQSkZJRgABAQEAAQABAAD/2wBDAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0i
IiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5Ojf/2wBDAQoKCg0MDRoPDxo3JR8l
Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzf/wAAR
CABrAJYDAREAAhEBAxEB/8QAHAABAAMBAQEBAQAAAAAAAAAAAAEGBwUEAgMI/8QAPBAAAAUD
AgQDBAcGBwAAAAAAAAECAwQFBhEHEiExQVETYXEUgZHBIiMyN1KhsQgVFzRidRYzQlR0lOH/
xAAaAQEAAwEBAQAAAAAAAAAAAAAAAwQFBgIB/8QAJhEBAAICAQQDAAEFAAAAAAAAAAECAwQR
BRIhMQYTIlEUMkGBsf/aAAwDAQACEQMRAD8A3EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAEAAAAD4JH0AAAAAAAAAAAAAEZAMgGQDID4cWlCFLWokpSWTMzwR
EPkzEe32ImZ4iFGreplNhuKZprapziTwayPa2R+vUVcm3WniPLoNL49n2I7sn5h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P/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<image>
    <id type="integer">1489191</id>
    <product-id type="integer">2336153</product-id>
    <position type="integer">1</position>
    <url>http://static.insales.ru/images/products/1/6439/1489191/myimage.jpg</url>
    <original-url>http://static.insales.ru/images/products/1/6439/1489191/myimage.jpg</original-url>
    <title>ImageTile</title>
    <created-at type="timestamp">2011-04-04 15:48:33 +0400</created-at>
</image>


Изменение изображения

Запрос: PUT /admin/products/#{product_id}/images/#{id}.xml

<?xml version="1.0" encoding="UTF-8"?>
<image>
    <position type="integer">5</position>
    <title>Other ImageTile</title>
</image>

Ответ:

HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<image>
    <id type="integer">1489191</id>
    <product-id type="integer">2336153</product-id>
    <position type="integer">5</position>
    <url>http://static.insales.ru/images/products/1/6439/1489191/myimage.jpg</url>
    <original-url>http://static.insales.ru/images/products/1/6439/1489191/myimage.jpg</original-url>
    <title>Other ImageTile</title>
    <created-at type="timestamp">2011-04-04 15:48:33 +0400</created-at>
</image>

Удаление изображения

Запрос: DELETE /admin/products/#{product_id}/images/#{id}.xml

Ответ:

HTTP/1.1 200 OK