Skip to content

Instantly share code, notes, and snippets.

@stepun
Last active November 21, 2018 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stepun/abc58553c1a7c98640dd to your computer and use it in GitHub Desktop.
Save stepun/abc58553c1a7c98640dd to your computer and use it in GitHub Desktop.
API Groups

API Groups

Получение и управление списками категорий и свойств (размеры и серии)

List groups

Resource URL

https://storencash.com/api/v1_groups.json

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

none

Example Request

GET /api/v1_groups.json HTTP/1.1
Host: storencash.com
token: 15da7169ee5272b97692ff680cab97f5
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

Example Result

{
    "status": "success",
    "data": {
        "collection": [
            {
                "id": 1,
                "name": "Первая категория",
                "level_id": 4,
                "offerId": 0
            },
            {
                "id": 927,
                "name": "Размеры",
                "level_id": 2,
                "offerId": 0
            },
            {
                "id": 928,
                "name": "31",
                "level_id": 2,
                "offerId": 0
            },
        ],
        "handbooks": {
        "levels": [
                {
                    "id": 2,
                    "name": "размеры",
                    "group_id": 927,
                    "zu": 1
                },
                {
                    "id": 4,
                    "name": "Первая категория",
                    "group_id": 1,
                    "zu": 0
                }
            ],
        "linked_groups": [
                {
                    "id": 10,
                    "groups_parent_id": 1,
                    "groups_id": 1,
                    "ves": 10
                },
                {
                    "id": 1210,
                    "groups_parent_id": 927,
                    "groups_id": 928,
                    "ves": 1210
                },
                {
                    "id": 1211,
                    "groups_parent_id": 927,
                    "groups_id": 929,
                    "ves": 1211
                },
                {
                    "id": 1212,
                    "groups_parent_id": 927,
                    "groups_id": 930,
                    "ves": 1212
                },
                {
                    "id": 1213,
                    "groups_parent_id": 927,
                    "groups_id": 931,
                    "ves": 1213
                },
                {
                    "id": 1214,
                    "groups_parent_id": 927,
                    "groups_id": 932,
                    "ves": 1214
                },
                {
                    "id": 1215,
                    "groups_parent_id": 927,
                    "groups_id": 927,
                    "ves": 9999
                },
            ]
        }
    }
}

Add groups

Resource URL

https://storencash.com/api/v1_groups.json

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
level_id yes bigint(10) default = null. Level ID.
groups_parent_id no bigint(10) default = null. Parent group ID.
name no varchar(80) default = null. Name group or value.

Example Request

POST /api/v1_groups.json HTTP/1.1
Host: storencash.com
token: 15da7169ee5272b97692ff680cab97f5
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

level_id=2&groups_parent_id=927&name=45

Example Result

{
    "status": "success",
    "data": {
        "id": 814
    }
}

Update groups

Resource URL

https://storencash.com/api/v1_groups.json

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
id no bigint(10) default = null. Level ID.
level_id no bigint(10) default = null. Parent group ID.
name no varchar(80) default = null. Name group or value.
external_id no varchar(100) default = null. External group ID.

Example Request

PUT /api/v1_groups.json/918 HTTP/1.1
Host: storencash.com
token: 15da7169ee5272b97692ff680cab97f5
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

name=%D1%81%D1%82%D0%B0%D1%80%D1%8B%D0%B52&offerId=10303-1

Example Result

{
    "status": "success",
    "data": {
        "id": 918
    }
}

Add new category

Тот же метод что и ADD groups за исключением обязательного параметра level_id если его не задать, создается новое дерево категорий

Resource URL

https://storencash.com/api/v1_category.json

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
level_id no bigint(10) default = null. Level ID.
groups_parent_id no bigint(10) default = null. Parent group ID.
name no varchar(80) default = 'empty'. Name group or value.

Example Request

POST /api/v1_category.json HTTP/1.1
Host: storencash.com
token: 15da7169ee5272b97692ff680cab97f5
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

name=new category

Example Result

{
    "status": "success",
    "data": {
        "id": 814
    }
}

Add new property

Тот же метод что и ADD groups за исключением обязательного параметра level_id если его не задать, создается новое дерево свойств

Resource URL

https://storencash.com/api/v1_property.json

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
level_id no bigint(10) default = null. Level ID.
groups_parent_id no bigint(10) default = null. Parent group ID.
name no varchar(80) default = 'empty'. Name group or value.

Example Request

POST /api/v1_property.json HTTP/1.1
Host: storencash.com
token: 15da7169ee5272b97692ff680cab97f5
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

name=new property

Example Result

{
    "status": "success",
    "data": {
        "id": 815
    }
}

DELETE group

Уделение группы(категории или свойства). Проверяется наличие пруппы в остатках и номенклатуре, если все условия выполнены - группа удаляется, если нет - выдается соответсвующее сообщение. Если группа содержит деревья - проверяются все ноды перед удалением.

Resource URL

https://storencash.com/api/v1_groups.json

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
id yes bigint(10) default = null. Идентификатор удаляемой группы.

Example Request

DELETE /api/v1_groups.json/1 HTTP/1.1
Host: storencash.com
token: e1ec049b388fbc7f2f9dca44dcbfde06
Cache-Control: no-cache

Example Result

{
    "status": "success",
        "data": {
           "message": "ID:1 deleted"
        }
}

Error codes

Code Description
'04001' Данное свойство уже используется, удалять нельзя
'04002' Данной группы не найдено в справочнике
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment