Skip to content

Instantly share code, notes, and snippets.

@klinkin
Last active October 23, 2017 09:34
Show Gist options
  • Save klinkin/ee526b5e35d540e162d29b40d9c29ab3 to your computer and use it in GitHub Desktop.
Save klinkin/ee526b5e35d540e162d29b40d9c29ab3 to your computer and use it in GitHub Desktop.
Products Resource

List products with all available filter parameters

Request

REQUSET: 
  TYPE:
    POST 
  PATH:
    api.quelle.ru/cnt/v1/products?nav_id=123&page=2&per_page=100

  CONTENT-TYPE: 
    application-json

  QUERY_PARAMS:
    nav_id - navigation id
    page - requested page
    per_page - amount of products in the response

  HEADERS:
    Authorization: <token> - jwt token 
    
  BODY:
    {
      "filters": [
        {
          "id": "32432",
          "slug": "fas_multiple_filter_basecolor",
          "values": [123, 567]
        },
        {
          "id": "657567",
          "slug": "fas_price_range_from",
          "values": 25
        },
        {
          "id": "5555",
          "slug": "fas_price_range_to",
          "values": 1024
        }, 
        {
          "id": "999",
          "slug": "fas_has_fast_delivery",
          "values": true
        }, ...
      ],
      "sort": "anzahl_verkauft"
    }

Respons must contain 4 groups:

  • count of all product with filter
  • list of products
  • available and already selected filter parameters
  • available and already selected sort parameters

Response:

Status: 200 OK
Link: 
	<https://api.quelle.ru/cnt/v1/products?nav_id=1&page=5&per_page=100>; rel="next",
	<https://api.quelle.ru/cnt/v1/products?nav_id=1&page=3&per_page=100>; rel="prev",
	<https://api.quelle.ru/cnt/v1/products?nav_id=1&page=1&per_page=100>; rel="first",
	<https://api.quelle.ru/cnt/v1/products?nav_id=1&page=10&per_page=100>; rel="last"
{
  "meta":
  {
    "total": 12345
  },
  "products": [
    {
      "id": 1234,
      "name": "Стринги LASCANA",
      "brand_id": 1234,
      "order_num": 0,
      "is_brand_viewable": true, -- brand can be displayed in UI
      "images": [
        {
          "url": "https://quelle.ru/img.jpg",
          "is_main": true,
          "order_num": 0
        }
        {
          "url": "https://quelle.ru/img2.jpg",
          "is_main": false,
          "order_num": 2
        }
      ],
      "prices": [
        {
          "type": "vip",
          "value": 123
        },
        {
          "type": "regular",
          "value": 200
        },
        {
          "type": "old",
          "value": 300
        }
      ],
      "lables": [
      	{
          "color": "123456", -- HEX for label color
          "icon_url": "https://quelle.ru/icon.svg", -- for example,  for fast delivery  we display just an icon
          "text": "New", -- optional, for text labels (flags) such as New or Sale - 35%
          "order_num": 0 -- if  array doesn’t contain objects,  display the label with the minimum value for the parameter
      	},
      ],
      "is_liked": true -- true, if user has liked this product
    }, ...
  ],
  "filters":
  [
    {
      "id": 123,
      "slug": "fas_multiple_filter_basecolor", -- NEED TO BE DISCUSSED We are not sure if there is IDs for filter and sorting, but there are slugs (we found it on the html code of web-site)
      "name": "Color",
      "type": "multiselect",
      "icon_url": "https://quelle.ru/icon.svg",
      "order_num": 0,
      "placeholder": "Select color", -- Default text to show until any filter is selected
      "checked": true, -- true if filter selected 
      "options":
      [
        {
          "id": 123,
          "name": "Green",
          "order_num": 0,
          "extra": "extra information", -- unified parameter, in particular, for the filter "COLOR" we expect here the value of HEX color for rendering
          "checked": true
        },
        {
          "id": 567,
          "name": "Blue",
          "order_num": 1,
          "extra": "extra information",
          "checked": false
        }, ...
      ]
    },
    {
      "id": 2321,
      "slug": "category",
      "name": "Категории",
      "type": "multiselect",
      "icon_url": "https://quelle.ru/icon.svg",
      "order_num": 0,
      "placeholder": "any", -- default text for filter until any value is selected
      "checked": true,
      "options":
      [
        {
          "id": 123,
          "name": "Куртки и ветровки",
          "order_num": 0,
          "extra": "",
          "checked": true 
        },
        {
          "id": 567,
          "name": "Кожанные плащи",
          "order_num": 1,
          "extra": "",
          "checked": false
        }, ...
      ]
    },
    {
      "id": 123,
      "name": "Free shiping",
      "type": "boolean", -- Expected there are YES/NO filter types
      "icon_url": "https://quelle.ru/icon.svg",
      "order_num": 3,
      "placeholder": "",
      "checked": true
    }, ...
  ],
  "sorts": 
  [
    {
      "id": 1,
      "slug": "fgdgdfg",
      "name": "Best choice",
      "order_num": 0,
      "checked": true
    },
    {
      "id": 123,
      "slug": "anzahl_verkauft",
      "name": "Бестселлер",
      "order_num": 0,
      "checked": false
    }, ...
  ]
}

Get product

Request

REQUSET: 
  TYPE:
    GET
  PATH:
    api.quelle.ru/cnt/v1/products/12345
  HEADERS:
    Authorization: <token> - jwt token

Response:

Status: 200 OK
{
  "main": {
    "id": 1234,
    "name": "Стринги LASCANA",
    "article": null,
    "effort": 263,
    "brand_id": 1234,
    "is_brand_viewable": true, -- brand can be displayed in UI
    "images": [
      {
        "url": "https://quelle.ru/img.jpg",
        "is_main": true,
        "order_num": 0
      },
      {
        "url": "https://quelle.ru/img2.jpg",
        "is_main": false,
        "order_num": 2
      }
    ],
    "dimentions": [
      {
        "dimension1": "blue"
      },
      {
        "dimension2": "string"
      },
      {
        "dimension3": "string"
      }
    ],
    "prices": [
			{
        "type": "vip",
        "value": 123
      },
      {
        "type": "regular",
        "value": 200
      },
      {
        "type": "old",
        "value": 300
      }
    ],
    "lables": [
    {
      "color": "123456", -- HEX for label color
      "icon_url": "https://quelle.ru/icon.svg", -- for example,  for fast delivery  we display just an icon
      "text": "New", -- optional, for text labels (flags) such as New or Sale - 35%
      "order_num": 0 -- if  array doesn’t contain objects,  display the label with the minimum value for the parameter
    },
    ],
    "is_liked": true, -- true, if user has liked this product
  },
  "info": {
    "description": "Элегантный мужской костюм от Class International - то, что нужно купить каждому! Классический однобортный пиджак с отложным воротником, прорезным нагрудным карманом и закругленными краями спереди составляет превосходный тандем со строгими брюками, дополненными традиционными деталями (втачные карманы по бокам, окантованные карманы сзади, петли для ремня, заутюженные складки-стрелки). Узкий крой великолепно подчеркивает телосложение, а материал с содержанием эластана обеспечивает оптимальную посадку и не сковывает движения. Деловой костюм для мужчин от Class International - превосходный выбор для офиса и торжественных мероприятий! Застежки: пиджак - 2 пуговицы, брюки - молния, пуговица и крючок. материал верха: 50% шерсть, 48% полиэстер, 2% эластан; подкладка: 100% полиэстер.",
    "product_selling_points": [
      "С содержанием эластана",
      "Материал не теряет форму и почти не мнется",
			"Узкий крой",
      "Узкий покрой, заниженная линия талии",
      "Застегивается на 2 пуговицы"
    ],
    "material": " материал верха: 50% шерсть, 48% полиэстер, 2% эластан; подкладка: 100% полиэстер ",
    "detail_attributes": [
      {
        "label": "Покрой",
        "value": "узкая модель"
      },
      {
        "label": "Покрой",
        "value": "свободный крой"
      },
      {
        "label": "Стиль",
        "value": "классический стиль"
      }
    ]
  },
  "reviews": {
    "avg_rating": 3.5,
    "list": [
      {
        "author": "string",
        "data": "string",
        "body": "string",
        "rating": 5,
        "fit": 4
      }
    ]
  },
  "recommendations": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment