Skip to content

Instantly share code, notes, and snippets.

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

API Product

Product by id

Resource URL

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

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
id yes int(10) identifier product. Primary key.

Example Request

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

Example Result

{
    "status": "success",
    "data": {
        "model": {
            "id": 22,
            "barcode": "",
            "sku": "ad101",
            "vendor": "adidas",
            "price_p": 100,
            "price": 110,
            "measureId": "101",
            "name": "Худи112",
            "external_id": "2D0021",
            "date": "2015-05-14",
            "time": "",
            "picture": "https://***.s3.amazonaws.com/***.jpg",
            "s3_key": "***.jpg",
            "measure_short_name": "ШТ",
            "measure_full_name": "ШТУКА",
            "groups": {
                "2": "933",
                "4": "922"
            }
        }
    }
}

List product

Resource URL

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

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
type no int(10) identifier product Type. If type = null get list remains in all product types. Possible type=1,2 or type=3
page no int(10) default = 0. Page.
count no int(10) default = 1000. Count models in page. Limit max 1000 models in one request!
date no date(Y-m-d) default = 0. Change the date. (2016-01-01)
storage_id no int(10) default = null. Идентификатор склада, для запросов цены установленной для выбранного склада (price_sp)

Example Request

GET /api/v1_product.json?page=0&limit=100&date=2016-05-06&type=1,2 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": 858,
                "barcode": "4603586008529",
                "sku": "104293",
                "vendor": "АВЗ",
                "price_p": 25.1,
                "price": 38.905,
                "price2": 0,
                "price3": 0,
                "price4": 0,
                "price5": 0,
                "measureId": 101,
                "name": "СЕРА АВЗ МЕДИЦИНСКАЯ 2,5Г",
                "external_id": "104293",
                "date": "2016-05-06",
                "time": "12:09:34",
                "isDel": 0,
                "type": 1,
                "picture": "",
                "s3_key": "",
                "group_id": 19,
                "category": "КОРМ ДЛЯ СОБАК КОНСЕРВЫ",
                "level": "Категории",
                "zu": 0,
                "groups": {
                    "2": "19"
                }
            },
            {
                "id": 15,
                "barcode": "",
                "sku": "ad1",
                "vendor": "adidas",
                "price_p": 100,
                "price": 10,
                "measureId": "101",
                "name": "трусы",
                "external_id": 15,
                "date": "2015-04-14",
                "time": "",
                "is_del": "0",
                "picture": "https://***.s3.amazonaws.com/***.jpg",
                "s3_key": "***.jpg",
                "groups": {
                    "2": "927",
                    "4": "922"
                }
            }
        ],
        "total": 22,
        "count": 2
    }
}

Add product

Resource URL

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

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
sku no varchar(50) default = null. sku product.
vendor no varchar(50) default = null. vendor product.
name no varchar(50) default = null. name product.
measureId yes int(10) default = null. Measure identifier.
price no double default = 0. Recommendet selling price.
price_p no double default = 0. Purchase price.
picture no varchar(255) default = null. URL picture. Picture moved to Amazone S3 stream service.
external_id no varchar(100) default = null. External identificator product. ID product in yous system.
barcode no String default - '' Штрихкод номенклатуры
stnds no Int(2) default - 0 Ставка НДС для номенклатуры
category_name no String(80) Название категории, создает в корне новую если такой не существует
groups no Array() default = null. Categories an Properties related with product.

Example Request

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

vendor=adidas&sku=ad101&name=%D0%A5%D1%83%D0%B4%D0%B8&measureId=102&price=10&price_p=100&picture=https%3A%2F%2Fsklimages.s3.amazonaws.com%2Fgood.png&groups=%7B%222%22%3A%22927%22%2C%224%22%3A%22922%22%7D&external_id=20021

Example Request for snc-sdk-php

$client = new SyncSnc();
$params = [
    'vendor' => 'adidas',
    'sku'    => 'ad101',
    'name'   => 'Худи',
    'measureId' => 102,
    'price'  => 100,
    'price_p' => 130,
    'picture' => 'https://sklimages.s3.amazonaws.com/good.png',
    'groups' => [2 => 927, 4 => 927],
    'external_id' => "2D0021",
    'stnds'   => 10,
    'barcode' => '7100000000148'
];
$response = $client->getClient()->postApi('v1_product.json', null, null, $params);

Example Result

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

Add list product

Resource URL

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

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
products yes array Список передаваемой номенлатуры
properties no array Список параметров со значениями

List products

Name Require Type Description
sku no varchar(50) default = null. sku product.
vendor no varchar(50) default = null. vendor product.
name no varchar(50) default = null. name product.
measureId yes int(10) default = null. Measure identifier.
price no double default = 0. Recommendet selling price.
price_p no double default = 0. Purchase price.
picture no varchar(255) default = null. URL picture. Picture moved to Amazone S3 stream service.
external_id no varchar(100) default = null. External identificator product. ID product in yous system.
barcode no String default - '' Штрихкод номенклатуры
stnds no Int(2) default - 0 Ставка НДС для номенклатуры
category_name no String(80) Название категории, создает в корне новую если такой не существует, можно передать уровни через двоеточие ":", в этом случае создастся новая ветка если таковая не существует.
uparams no varchar(500) default - null. Список учетных параметров разделенных двоеточием ":". Пример: 'Серийный номер:Срок годности'
params no varchar(500) default - null. Список не учетных параметров разделенных двоеточием, значения параметров передаеются через разделитель "=>". Пример: 'Цвет=>синий:Вес=>100гр'
property no varchar(200) default - null. Свойство номенклатуры, доступные свойства и их значения должны быть переданы в массиве properties

List properties

Name Require Type Description
name yes varchar(80) Название свойства
values yes varchar(500) Значения свойства разделенные двоеточием ":"

Example Request

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

products=[{"name":"test product1","price": 123.12,"measureId":102}]

Error codes

Code Description
'03001' Не передан список номенлатуры, или формат данных не соответсвует описанию
'03002' Свойство "%s" не найдено в списке

####Example error response

{
    "errors": [
    {
      "code": "03001",
      "message": "Не передан список номенлатуры, или формат данных не соответсвует описанию"
    }
  ],
  "status": "fail",
  "message": "Не передан список номенлатуры, или формат данных не соответсвует описанию"
}

Update product

Resource URL

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

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
id yes int(10) default = null. Store&Cash Product identifier.
sku no varchar(50) default = null. sku product.
vendor no varchar(50) default = null. vendor product.
name no varchar(50) default = null. name product.
measureId yes int(10) default = null. Measure identifier.
price no double default = 0. Recommendet selling price.
price_p no double default = 0. Purchase price.
picture no varchar(255) default = null. URL picture. Picture moved to Amazone S3 stream service.
external_id no varchar(100) default = null. External identificator product. ID product in yous system.
barcode no String default - '' Штрихкод номенклатуры
stnds no Int(2) default - 0 Ставка НДС для номенклатуры
category_name no String(80) Название категории, создает в корне новую если такой не существует
groups no Array() default = null. Categories an Properties related with product. Example: {"2":"927","4":"922"} where 2 or 4 = handbook=>levels=>id and 927 or 922 = groups=>collection=>id

Example Request

PUT /api/v1_product.json/22 HTTP/1.1
Host: storencash.com
token: 61e76bf664a0597144194eeee660cdc9
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

vendor=adidas&sku=ad101&name=%D0%A5%D1%83%D0%B4%D0%B81&measureId=101&price=10&price_p=100&picture=http%3A%2F%2Fdasonlightinginc.com%2Fuploads%2F2%2F9%2F4%2F2%2F2942625%2F4781952_orig.jpg&groups=%7B%222%22%3A%22927%22%2C%224%22%3A%22922%22%7D&external_id=20021

Example Request for snc-sdk-php

$client = new SyncSnc();
$params = [
    'vendor' => 'adidas',
    'sku'    => 'ad101',
    'name'   => 'Худи',
    'measureId' => 102,
    'price'  => 100,
    'price_p' => 130,
    'picture' => 'https://sklimages.s3.amazonaws.com/good.png',
    'groups' => [2 => 927, 4 => 927],
    'external_id' => '2D0021',
    'barcode' => '7100000000148',
    'stnds'   => 5
];
$response = $client->getClient()->putApi('v1_product.json/22', null, null, $params);

Example Result

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

Delete product

Resource URL

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

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Parameters

Name Require Type Description
id yes int(10) identifier product ID

Example Request

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

Example Result

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

Get discount

Получение ID скидки. В случае если на сервере еще не заведена скидка, она будет создана.

Resource URL

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

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Example Request

GET /api/v1_product.json?action=getDiscount HTTP/1.1
Host: my2can.com
token: 15da7169ee5272b97692ff680cab97f5
Cache-Control: no-cache

Example Result

{
  "status": "success",
  "data":{
    "discount": 1
  },
  "base_id": 3
}

Get discount contractor

Получение ID клиентской скидки. В случае если на сервере еще не заведена скидка, она будет создана.

Resource URL

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

Resource Information

  • Response formats JSON
  • Requires authentication? Yes

Example Request

GET /api/v1_product.json?action=getDiscountContractor HTTP/1.1
Host: my2can.com
token: 15da7169ee5272b97692ff680cab97f5
Cache-Control: no-cache

Example Result

{
  "status": "success",
  "data":{
    "discount": 421
  },
  "base_id": 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment