School HxH

Интро

В данной спецификации описаны требования REST API для курсового приложения школы мобильной разработки.

А. Общие сведения
A.1 Версионирование

Версионирование осуществляется путем передачи стандартного заголовка Accept, в котором указывается требуемая версия метода

Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json
A.2 Авторизация

Для авторизации используется Bearer-токен, который передается через стандартный заголовок Authorization

X-Auth-Token
string optional

Кастомный заголовок. Авторизация происходит путем передачи токена, ранее выданного при аутентификация

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
A.3 Ошибки
@Ошибка
Object
Example:
{
    "message": "У вас отсутствуют права для доступа к этому ресурсу",
    "fields": [
        {
            "field": "login",
            "message": "Поле заполнено неверно"
        }
    ]
}
message
string required

Сообщение об ошибке

Example:
У вас отсутствуют права для доступа к этому ресурсу
fields
Array nullable

Список ошибок валидации

Example:
[
    {
        "field": "login",
        "message": "Поле заполнено неверно"
    }
]
Object
field
string required

Поле с ошибкой

Example:
login
message
string required

Сообщение об ошибке

Example:
Поле заполнено неверно
1. Пользователи
1.1 Аутентификация
PUT /user/signin

Request headers

Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json

Request body

Object
login
string email

Логин

Example:
me@coldmail.org
password
string password

Пароль

Example:
passWORD123?
Examples
{
    "login": "me@coldmail.org",
    "password": "passWORD123?"
}

Responses

200 OK
Body
Object
data
Object
accessToken
string

Access Token для доступа к закрытым ресурсам

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
Example:
{
    "name": "Анна",
    "surname": "Виноградова",
    "occupation": "Садовник"
}
Examples
{
    "data": {
        "accessToken": "AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx",
        "profile": {
            "name": "Анна",
            "surname": "Виноградова",
            "occupation": "Садовник",
            "avatarUrl": "https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200"
        }
    }
}
400 Bad Request
Body
Object
Examples
{
    "error": {
        "message": "Ошибка в теле запроса"
    }
}
422 Unprocessable Entity
Body
Object
Examples
{
    "error": {
        "message": "В одном или нескольких полях были обнаружены ошибки",
        "fields": [
            {
                "field": "login",
                "message": "Поле заполнено неверно"
            }
        ]
    }
}
1.2 Получить профиль
GET /user

Request headers

X-Auth-Token
string optional

Кастомный заголовок. Авторизация происходит путем передачи токена, ранее выданного при аутентификация

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json

Responses

200 OK
Body
Object
Examples
{
    "data": {
        "profile": {
            "name": "Анна",
            "surname": "Виноградова",
            "occupation": "Садовник",
            "avatarUrl": "https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200"
        }
    }
}
400 Bad Request
Body
Object
Examples
{
    "error": {
        "message": "Ошибка в теле запроса"
    }
}
403 Forbidden
Body
Object
Examples
{
    "error": {
        "message": "У вас отсутствуют права для доступа к этому ресурсу"
    }
}
1.3 Изменить профиль
PATCH /user

Request headers

X-Auth-Token
string optional

Кастомный заголовок. Авторизация происходит путем передачи токена, ранее выданного при аутентификация

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json

Request body

multipart/mixed
Object
name
string nullable

Имя пользователя

Example:
Константин
surname
string nullable

Фамилия пользователя

Example:
Петров
occupation
string nullable

Род деятельности

Example:
Сантехник
avatar
string binary nullable

Файл аватара

Examples
{
    "name": "Константин",
    "surname": "Петров",
    "occupation": "Сантехник",
    "avatar": ""
}

Responses

201 Created
Body
Object
Examples
{
    "data": {
        "profile": {
            "name": "Анна",
            "surname": "Виноградова",
            "occupation": "Садовник",
            "avatarUrl": "https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200"
        }
    }
}
400 Bad Request
Body
Object
Examples
{
    "error": {
        "message": "Ошибка в теле запроса"
    }
}
403 Forbidden
Body
Object
Examples
{
    "error": {
        "message": "У вас отсутствуют права для доступа к этому ресурсу"
    }
}
@Профиль пользователя
Object
Example:
{
    "name": "Анна",
    "surname": "Виноградова",
    "occupation": "Садовник",
    "avatarUrl": "https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200"
}
name
string

Имя пользователя

Example:
Анна
surname
string

Фамилия пользователя

Example:
Виноградова
occupation
string

Род деятельности

Example:
Садовник
avatarUrl
string

URL аватара пользователя

Example:
https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200
2.1 Получить список товаров
GET /products

Request parameters

fields
string optional

Список включенных полей в ответ запроса через запятую

Example:
id,title,department,price,badge,preview
limit
string optional

Размер страницы для постраничной загрузки. По умолчанию 20

Example:
20
offset
string optional

Смещение страница для постраничной загрузки. По умолчанию 0

Example:
0

Request headers

X-Auth-Token
string optional

Кастомный заголовок. Авторизация происходит путем передачи токена, ранее выданного при аутентификация

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json

Responses

200 OK
Body
Object
data
Object
products
Array of @Товар
Examples
{
    "data": {
        "products": [
            {
                "id": "047eae74-1efd-11ec-9621-0242ac130002",
                "title": "Men's Nike J.J. Watt Black Arizona Cardinals Legend Jersey",
                "department": "Джерси",
                "price": 9000,
                "badge": {
                    "value": "Хит сезона",
                    "color": "#3C72BF"
                },
                "preview": "https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_3533000/ff_3533150-d9254664c08370f8572c_full.jpg&w=340",
                "images": [
                    ""
                ],
                "sizes": [
                    {
                        "value": "M",
                        "isAvailable": "true"
                    }
                ],
                "description": "We want fans to celebrate their fandom by customizing and personalizing certain products. For these customizable products, including jerseys, we invite customers to tell us how they would like their preferred name or other text to appear by typing that text into the field indicated. However, just because a customer is able to type proposed customization text into the field and is able to complete the order through the website, not all proposed customization text will be accepted. Please note, Fanatics may reject and cancel any customization order for any reason, including for messages that are deemed offensive or inappropriate. Take your Arizona Cardinals fandom to the next level when you grab this Custom Game Jersey. This Nike gear is perfect for an avid Arizona Cardinals fan like you who never misses a moment of the action. The crisp graphics will put your unwavering pride on full display and ensure everyone knows who you're rooting for at the next game!",
                "details": [
                    ""
                ]
            }
        ]
    }
}
2.2 Получить детальную информацию о товаре
GET /products/{product_id}

Path variables

product_id
string uuid required

ID товара

Example:
047eae74-1efd-11ec-9621-0242ac130002

Request headers

X-Auth-Token
string optional

Кастомный заголовок. Авторизация происходит путем передачи токена, ранее выданного при аутентификация

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json

Responses

200 OK
Body
Object
data
Object
product
Examples
{
    "data": {
        "product": {
            "id": "047eae74-1efd-11ec-9621-0242ac130002",
            "title": "Men's Nike J.J. Watt Black Arizona Cardinals Legend Jersey",
            "department": "Джерси",
            "price": 9000,
            "badge": {
                "value": "Хит сезона",
                "color": "#3C72BF"
            },
            "preview": "https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_3533000/ff_3533150-d9254664c08370f8572c_full.jpg&w=340",
            "images": [
                ""
            ],
            "sizes": [
                {
                    "value": "M",
                    "isAvailable": "true"
                }
            ],
            "description": "We want fans to celebrate their fandom by customizing and personalizing certain products. For these customizable products, including jerseys, we invite customers to tell us how they would like their preferred name or other text to appear by typing that text into the field indicated. However, just because a customer is able to type proposed customization text into the field and is able to complete the order through the website, not all proposed customization text will be accepted. Please note, Fanatics may reject and cancel any customization order for any reason, including for messages that are deemed offensive or inappropriate. Take your Arizona Cardinals fandom to the next level when you grab this Custom Game Jersey. This Nike gear is perfect for an avid Arizona Cardinals fan like you who never misses a moment of the action. The crisp graphics will put your unwavering pride on full display and ensure everyone knows who you're rooting for at the next game!",
            "details": [
                ""
            ]
        }
    }
}
@Товар
Object
Example:
{
    "id": "047eae74-1efd-11ec-9621-0242ac130002",
    "title": "Men's Nike J.J. Watt Black Arizona Cardinals Legend Jersey",
    "department": "Джерси",
    "price": 9000,
    "badge": {
        "value": "Хит сезона",
        "color": "#3C72BF"
    },
    "preview": "https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_3533000/ff_3533150-d9254664c08370f8572c_full.jpg&w=340",
    "images": [
        ""
    ],
    "sizes": [
        {
            "value": "M",
            "isAvailable": "true"
        }
    ],
    "description": "We want fans to celebrate their fandom by customizing and personalizing certain products. For these customizable products, including jerseys, we invite customers to tell us how they would like their preferred name or other text to appear by typing that text into the field indicated. However, just because a customer is able to type proposed customization text into the field and is able to complete the order through the website, not all proposed customization text will be accepted. Please note, Fanatics may reject and cancel any customization order for any reason, including for messages that are deemed offensive or inappropriate. Take your Arizona Cardinals fandom to the next level when you grab this Custom Game Jersey. This Nike gear is perfect for an avid Arizona Cardinals fan like you who never misses a moment of the action. The crisp graphics will put your unwavering pride on full display and ensure everyone knows who you're rooting for at the next game!",
    "details": [
        ""
    ]
}
id
string uuid

ID товара

Example:
047eae74-1efd-11ec-9621-0242ac130002
title
string

Название товара

Example:
Men's Nike J.J. Watt Black Arizona Cardinals Legend Jersey
department
string

Категория товара

Example:
Джерси
price
number

Цена товара в рублях

Example:
9000

Бейдж товара

preview
string

Превью товара

Example:
https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_3533000/ff_3533150-d9254664c08370f8572c_full.jpg&w=340
images
Array of string

Изображения товара

Example:
[
    "https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_3888000/altimages/ff_3888062-f848e302bef4a86eff9aalt3_full.jpg&w=900"
]

Существующие размеры

Example:
[
    {
        "value": "M",
        "is_available": "true"
    }
]
description
string

Описание товара

Example:
We want fans to celebrate their fandom by customizing and personalizing certain products. For these customizable products, including jerseys, we invite customers to tell us how they would like their preferred name or other text to appear by typing that text into the field indicated. However, just because a customer is able to type proposed customization text into the field and is able to complete the order through the website, not all proposed customization text will be accepted. Please note, Fanatics may reject and cancel any customization order for any reason, including for messages that are deemed offensive or inappropriate. Take your Arizona Cardinals fandom to the next level when you grab this Custom Game Jersey. This Nike gear is perfect for an avid Arizona Cardinals fan like you who never misses a moment of the action. The crisp graphics will put your unwavering pride on full display and ensure everyone knows who you're rooting for at the next game!
details
Array of string

Подробности

Example:
[
    "Fit: Men's Nike Game Jerseys have a Loose Fit. We recommend ordering one size larger than you normally wear for a looser fit or up two sizes if you plan on layering underneath the jersey."
]
@Размер товара
Object
Example:
{
    "value": "M",
    "isAvailable": "true"
}
value
string

Значение размера товара

Examples:
SMXL
isAvailable
boolean

Доступность товара

Example:
true
@Бейдж товара
Object
Example:
{
    "value": "Хит сезона",
    "color": "#3C72BF"
}
value
string

Значение бейджа

Example:
Хит сезона
color
string

Цвет бейджа по паттерну #RRGGBB или для цветов с альфа-каналом #AARRGGBB

Example:
#3C72BF
3. Заказы
3.1 Оформить заказ
POST /orders/checkout

Request headers

X-Auth-Token
string optional

Кастомный заголовок. Авторизация происходит путем передачи токена, ранее выданного при аутентификация

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json

Request body

Object
productId
string uuid

ID товара

Example:
047eae74-1efd-11ec-9621-0242ac130002
size
string

Выбранный размер

Example:
S
quantity
number

Количество единиц товара, не более 5

Example:
3
house
string

Дом доставки

Example:
г. Саранск, ул. Коммунистическая, 125
apartment
string nullable

Номер квартиры

Example:
55
etd
string

День доставки в формате ISO 8601 с маской YYYY-MM-DD

Example:
2021-08-09

Responses

201 Created
Body
Object
data
Object
Examples
{
    "data": {
        "order": {
            "id": "047eae74-1efd-11ec-9621-0242ac130002",
            "number": 1123,
            "productId": "455fccf6-1f03-11ec-9621-0242ac130002",
            "productPreview": "https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_4273000/ff_4273570-ad01ab376f8884cfb370_full.jpg&w=340",
            "productQuantity": 1,
            "productSize": "XL",
            "createdAt": "2021-08-09T18:31:42+03:00",
            "etd": "2021-09-30T16:00:00+03:00",
            "deliveryAddress": "г. Саранск, ул. Демократическая, 14",
            "status": "in_work"
        }
    }
}
3.2 Получить список заказов
GET /orders

Request parameters

limit
string optional

Размер страницы для постраничной загрузки. По умолчанию 20

Example:
20
offset
string optional

Смещение страница для постраничной загрузки. По умолчанию 0

Example:
0

Request headers

X-Auth-Token
string optional

Кастомный заголовок. Авторизация происходит путем передачи токена, ранее выданного при аутентификация

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json

Responses

200 OK
Body
Object
data
Object
orders
Array of @Заказ
Examples
{
    "data": {
        "orders": [
            {
                "id": "047eae74-1efd-11ec-9621-0242ac130002",
                "number": 1123,
                "productId": "455fccf6-1f03-11ec-9621-0242ac130002",
                "productPreview": "https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_4273000/ff_4273570-ad01ab376f8884cfb370_full.jpg&w=340",
                "productQuantity": 1,
                "productSize": "XL",
                "createdAt": "2021-08-09T18:31:42+03:00",
                "etd": "2021-09-30T16:00:00+03:00",
                "deliveryAddress": "г. Саранск, ул. Демократическая, 14",
                "status": "in_work"
            }
        ]
    }
}
3.3 Отменить заказ
PUT /orders/{order_id}/cancel

Path variables

order_id
string uuid required

ID заказа

Example:
455fccf6-1f03-11ec-9621-0242ac130002

Request headers

X-Auth-Token
string optional

Кастомный заголовок. Авторизация происходит путем передачи токена, ранее выданного при аутентификация

Example:
AAAAAAAAAAAAAAAAAAAAAFnz2wAAAAAACOwLSPtVT5gxxxxxxxxxxxx
Accept
string optional

Стандартный заголовок. Должен иметь определенное значение, являющееся комбинацией префикса поставщика и версии API

Example:
application/vnd.handh.school.mobile.v1+json

Responses

204 No Content
@Заказ
Object
Example:
{
    "id": "047eae74-1efd-11ec-9621-0242ac130002",
    "number": 1123,
    "productId": "455fccf6-1f03-11ec-9621-0242ac130002",
    "productPreview": "https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_4273000/ff_4273570-ad01ab376f8884cfb370_full.jpg&w=340",
    "productQuantity": 1,
    "productSize": "XL",
    "createdAt": "2021-08-09T18:31:42+03:00",
    "etd": "2021-09-30T16:00:00+03:00",
    "deliveryAddress": "г. Саранск, ул. Демократическая, 14",
    "status": "in_work"
}
id
string uuid

ID заказа

Example:
047eae74-1efd-11ec-9621-0242ac130002
number
number

Номер товара

Example:
1123
productId
string uuid

ID заказанного товара

Example:
455fccf6-1f03-11ec-9621-0242ac130002
productPreview
string

Превью заказанного товара

Example:
https://fanatics.frgimages.com/FFImage/thumb.aspx?i=/productimages/_4273000/ff_4273570-ad01ab376f8884cfb370_full.jpg&w=340
productQuantity
number

Количество заказанного товара

Example:
1
productSize
string

Размер заказанного товара

Example:
XL
createdAt
string date-time

Дата создания заказа в формате ISO 8601 с маской YYYY-MM-DDThh:mm:ss±hh:mm

Example:
2021-08-09T18:31:42+03:00
etd
string

Предполагаемая дата доставки

Example:
2021-09-30T16:00:00+03:00
deliveryAddress
string

Адрес доставки

Example:
г. Саранск, ул. Демократическая, 14
status
string

Статус заказа

Enumeration:
in_work

В работе

done

Доставлен

cancelled

Отменен

Example:
in_work