InSales API - Модификации товара
Материал из Insales Wiki
Содержание |
Получение всех модификаций товара
Запрос: GET /admin/products/#{product_id}/variants.xml
Ответ:
HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<variants type="array">
<variant>
<id type="integer">1157664</id>
<product-id type="integer">182183</product-id>
<cost-price type="decimal" nil="true"/>
<old-price type="decimal" nil="true"/>
<price type="decimal">440.0</price>
<quantity type="integer" nil="true"/>
<sku nil="true"/>
<created-at type="timestamp">2010-07-03 20:04:28 +0400</created-at>
<updated-at type="timestamp">2010-07-03 20:04:28 +0400</updated-at>
<option-values type="array">
<option-value>
<id type="integer">8093</id>
<option-name-id type="integer">1576</option-name-id>
<position type="integer">3</position>
<title>Черный</title>
</option-value>
<option-value>
<id type="integer">8092</id>
<option-name-id type="integer">1575</option-name-id>
<position type="integer">24</position>
<title>96</title>
</option-value>
</option-values>
</variant>
<variant>
<id type="integer">1157665</id>
<product-id type="integer">182183</product-id>
<cost-price type="decimal" nil="true"/>
<old-price type="decimal" nil="true"/>
<price type="decimal">440.0</price>
<quantity type="integer" nil="true"/>
<sku nil="true"/>
<created-at type="timestamp">2010-07-03 20:04:39 +0400</created-at>
<updated-at type="timestamp">2010-07-03 20:04:39 +0400</updated-at>
<option-values type="array">
<option-value>
<id type="integer">7941</id>
<option-name-id type="integer">1576</option-name-id>
<position type="integer">2</position>
<title>Белый</title>
</option-value>
<option-value>
<id type="integer">8094</id>
<option-name-id type="integer">1575</option-name-id>
<position type="integer">25</position>
<title>100</title>
</option-value>
</option-values>
</variant>
<variant>
<id type="integer">1157666</id>
<product-id type="integer">182183</product-id>
<cost-price type="decimal" nil="true"/>
<old-price type="decimal" nil="true"/>
<price type="decimal">440.0</price>
<quantity type="integer" nil="true"/>
<sku nil="true"/>
<created-at type="timestamp">2010-07-03 20:04:39 +0400</created-at>
<updated-at type="timestamp">2010-07-03 20:04:39 +0400</updated-at>
<option-values type="array">
<option-value>
<id type="integer">8093</id>
<option-name-id type="integer">1576</option-name-id>
<position type="integer">3</position>
<title>Черный</title>
</option-value>
<option-value>
<id type="integer">8094</id>
<option-name-id type="integer">1575</option-name-id>
<position type="integer">25</position>
<title>100</title>
</option-value>
</option-values>
</variant>
</variants>
Получение модификации
Запрос: GET /admin/products/#{product_id}/variants/#{id}.xml
Ответ:
HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<variant>
<id type="integer">1157664</id>
<product-id type="integer">182183</product-id>
<cost-price type="decimal" nil="true"/>
<old-price type="decimal" nil="true"/>
<price type="decimal">440.0</price>
<quantity type="integer" nil="true"/>
<sku nil="true"/>
<created-at type="timestamp">2010-07-03 20:04:28 +0400</created-at>
<updated-at type="timestamp">2010-07-03 20:04:28 +0400</updated-at>
<option-values type="array">
<option-value>
<id type="integer">8093</id>
<option-name-id type="integer">1576</option-name-id>
<position type="integer">3</position>
<title>Черный</title>
</option-value>
<option-value>
<id type="integer">8092</id>
<option-name-id type="integer">1575</option-name-id>
<position type="integer">24</position>
<title>96</title>
</option-value>
</option-values>
</variant>
Добавление модификации
Запрос: POST /admin/products/#{product_id}/variants.xml
<?xml version="1.0" encoding="UTF-8"?>
<variant>
<price type="decimal">440.0</price>
<options type="array">
<option>
<option-name-id type="integer">1576</option-name-id>
<value>Черный</value>
</option>
<option>
<option-name-id type="integer">1575</option-name-id>
<value>96</value>
</option>
</options>
</variant>
Ответ:
HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<variant>
<id type="integer">1157664</id>
<product-id type="integer">182183</product-id>
<cost-price type="decimal" nil="true"/>
<old-price type="decimal" nil="true"/>
<price type="decimal">440.0</price>
<quantity type="integer" nil="true"/>
<sku nil="true"/>
<created-at type="timestamp">2010-07-03 20:04:28 +0400</created-at>
<updated-at type="timestamp">2010-07-03 20:04:28 +0400</updated-at>
<option-values type="array">
<option-value>
<id type="integer">8093</id>
<option-name-id type="integer">1576</option-name-id>
<position type="integer">3</position>
<title>Черный</title>
</option-value>
<option-value>
<id type="integer">8092</id>
<option-name-id type="integer">1575</option-name-id>
<position type="integer">24</position>
<title>96</title>
</option-value>
</option-values>
</variant>
Изменение модификации
Запрос: PUT /admin/products/#{product_id}/variants/#{id}.xml
<?xml version="1.0" encoding="UTF-8"?>
<variant>
<id type="integer">1157664</id>
<price type="decimal">440.0</price>
</variant>
Ответ:
HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<variant>
<id type="integer">1157664</id>
<product-id type="integer">182183</product-id>
<cost-price type="decimal" nil="true"/>
<old-price type="decimal" nil="true"/>
<price type="decimal">440.0</price>
<quantity type="integer" nil="true"/>
<sku nil="true"/>
<created-at type="timestamp">2010-07-03 20:04:28 +0400</created-at>
<updated-at type="timestamp">2010-07-03 20:04:28 +0400</updated-at>
<option-values type="array">
<option-value>
<id type="integer">8093</id>
<option-name-id type="integer">1576</option-name-id>
<position type="integer">3</position>
<title>Черный</title>
</option-value>
<option-value>
<id type="integer">8092</id>
<option-name-id type="integer">1575</option-name-id>
<position type="integer">24</position>
<title>96</title>
</option-value>
</option-values>
</variant>
Удаление модификации
Запрос: DELETE /admin/products/#{product_id}/variants/#{id}.xml
Ответ:
HTTP/1.1 200 OK
