InSales API - Скидки по купонам
Материал из Insales Wiki
Содержание |
Получение списка купонов
Запрос: GET /admin/discount_codes.xml
Ответ:
HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<discount-codes type="array">
<discount-code>
<act-once type="boolean">true</act-once>
<code>DC1</code>
<created-at type="datetime">2011-11-07T13:28:42+04:00</created-at>
<description>discount campaign</description>
<disabled type="boolean">false</disabled>
<discount type="decimal">10.0</discount>
<expired-at type="date">2012-06-09</expired-at>
<id type="integer">628</id>
<type-id type="integer">1</type-id>
<updated-at type="datetime">2011-11-07T13:28:42+04:00</updated-at>
</discount-code>
<discount-code>
<act-once type="boolean">true</act-once>
<code>DC2</code>
<created-at type="datetime">2011-10-24T16:29:42+04:00</created-at>
<description>discount campaign</description>
<disabled type="boolean">false</disabled>
<discount type="decimal">12.0</discount>
<expired-at type="date">2012-06-09</expired-at>
<id type="integer">626</id>
<type-id type="integer">1</type-id>
<updated-at type="datetime">2011-11-01T19:49:14+04:00</updated-at>
</discount-code>
<discount-code>
<act-once type="boolean">true</act-once>
<code>DC3</code>
<created-at type="datetime">2011-10-24T16:29:42+04:00</created-at>
<description>discount campaign</description>
<disabled type="boolean">false</disabled>
<discount type="decimal">13.0</discount>
<expired-at type="date">2012-06-09</expired-at>
<id type="integer">627</id>
<type-id type="integer">2</type-id>
<updated-at type="datetime">2011-11-01T19:49:14+04:00</updated-at>
</discount-code>
<discount-code>
<act-once type="boolean">false</act-once>
<code>DC4</code>
<created-at type="datetime">2011-10-24T16:29:42+04:00</created-at>
<description>discount campaign</description>
<disabled type="boolean">true</disabled>
<discount type="decimal">14.0</discount>
<expired-at type="date">2012-06-09</expired-at>
<id type="integer">628</id>
<type-id type="integer">1</type-id>
<updated-at type="datetime">2011-11-01T19:49:14+04:00</updated-at>
</discount-code>
<discount-code>
<act-once type="boolean">true</act-once>
<code>DC5</code>
<created-at type="datetime">2011-10-24T16:29:42+04:00</created-at>
<description>discount campaign</description>
<disabled type="boolean">false</disabled>
<discount type="decimal">12.0</discount>
<expired-at type="date">2012-06-09</expired-at>
<id type="integer">629</id>
<type-id type="integer">1</type-id>
<updated-at type="datetime">2011-11-01T19:49:14+04:00</updated-at>
</discount-code>
</discount-codes>
Примечание: Надо передавать параметры limit и page , чтобы пролистать все страницы с купонами.
Получение информации о купоне
Запрос: GET /admin/discount_codes/#{id}.xml
Ответ:
HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <discount-code> <act-once type="boolean">true</act-once> <code>DC2</code> <created-at type="datetime">2011-10-24T16:29:42+04:00</created-at> <description>discount campaign</description> <disabled type="boolean">false</disabled> <discount type="decimal">12.0</discount> <expired-at type="date">2012-06-09</expired-at> <id type="integer">626</id> <type-id type="integer">1</type-id> <updated-at type="datetime">2011-11-01T19:49:14+04:00</updated-at> </discount-code>
Добавление купона
Запрос: POST /admin/discount_codes.xml
<discount_code> <code>frandom2</code> <act_once>true</act_once> <discount>10</discount> <type_id>1</type_id> <description>API code</description> <disabled>0</disabled> <expired-at>2013-06-09</expired-at> </discount_code>
Ответ:
<?xml version="1.0" encoding="UTF-8"?> <discount-code> <act-once type="boolean">true</act-once> <code>frandom2</code> <created-at type="datetime">2011-10-24T16:29:42+04:00</created-at> <description>API code</description> <disabled type="boolean">false</disabled> <discount type="decimal">10.0</discount> <expired-at type="date">2013-06-09</expired-at> <id type="integer">626</id> <type-id type="integer">1</type-id> <updated-at type="datetime">2011-11-01T19:49:14+04:00</updated-at> </discount-code>
Редактирование купона
Запрос: PUT /admin/discount_codes/#{id}.xml
<discount_code> <code>frandom3</code> <act_once>true</act_once> <discount>15</discount> <type_id>1</type_id> <description>API code</description> <disabled>0</disabled> <expired-at>2013-06-09</expired-at> </discount_code>
Ответ:
HTTP/1.1 200 OK
Удаление купона
Запрос: DELETE /admin/discount_codes/#{id}.xml
Ответ:
HTTP/1.1 200 OK
Описание полей
act-once (допустимые значения 1 или 0) - одноразовый или многоразовый купон
сode - код купона
description - описание купона
disabled (допустимые значения 0 или 1) - активный/неактивный купон
type-id (допустимые значения 1 или 2) - тип скидки: процент/денежная величина
discount - величина скидки
expired-at (формат 2013-06-09) - срок окончания действия скидки
