Skip to content

Instantly share code, notes, and snippets.

@m-bo-one
Last active September 28, 2016 12:13
Show Gist options
  • Save m-bo-one/ca99bd6193dfa37856eaeb2a32596a70 to your computer and use it in GitHub Desktop.
Save m-bo-one/ca99bd6193dfa37856eaeb2a32596a70 to your computer and use it in GitHub Desktop.
frigg(cloudapp) API description

Changelog

v2.0

  • Restructured back-end part of project - moved on web api;
  • removed banner section;
  • removed get latest video and text lessons section;
  • changed some parts of api (see all sections which key is changed/removed):
    • patronymic -> middle_name;
    • photo -> image;
    • text -> description (not in all parts);

v2.1

  • added translation for error;
  • added remove thank and need (see corresponding sections below);

Project API link

http://5.101.119.32:8488/api/v2/m/

Installation

  1. git clone http://5.101.125.14/Iskander/frigg.git
  2. virtualenv .env
  3. source .env/bin/activate
  4. (.env) pip install -r requirements.txt
  5. (.env) python manage.py migrate
  6. (.env) python manage.py runserver

General information

Admin user creadentials:

Headers:

  • Authorization: Token 1af538baa9045a84c0e889f672baf83ff24 - exclude auth routes such as login, logout, registration;
  • Content-Type: application/json - except GET request;
  • Accept-Language: ru;q=1 - for russian error messages (changes locale);
  • Content-Type: multipart/form-data - for file upload (thanks, needs, user profile routes);

Filters and search:

  • for searching lessons, thanks and wishes user ?search=(title:str), where title - title of some video, text lessons or thanks or wishes.
  • for filtering lessons by some period use such query ?time_filter=(id:int), where id - time filter id from the list below:
    • 1 - за последнюю неделю;
    • 2 - за последний месяц;
    • 3 - за последний квартал (3 месяца);
    • 4 - за последние пол года;
    • 5 - за последний год;
  • examples:
    • /api/v1/video-lessons/?filter_time=2 (we filter for last month);
    • /api/v1/video-lessons/?search=Title%2020 (Title 20 with urlencode);

Admin panel

FAQ

Сколько приоритетов нужд?

  • Есть только 2 приоритета - Обычная (0) и Срочная (1)

Как получить список всего сразу без пагинации?

  • добавить приставку /all/ к юрлу

Quick search

Auth

Consultants (Консультатнты)

Favorites (Фавориты)

Views (Просмотры)

Text lessons (Текстовые уроки)

Video lessons (Видео уроки)

Online lesson (Онлайн урок)

Supports (Спросить вопрос у поддержки)

Wishes (Пожелания)

Needs (Нужды)

Thanks (Благодарности)

Global errors

If user not authenticated

  • Code: 403 Forbidden
  • Content:
{
    "error": "Учетные данные не были предоставлены."
}

If detailed resource not found

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

Auth

API for registration

POST: registration/

Description

Registration of user by email, username and password.

Send Params

Parameter Description
username required(max=30)
email required(max=254 - RFC 3696)
password required(min=6)

Response Params

Parameter Description
key Token key on success response

Success Response

  • Code: 200 OK
  • Content:
{
    "key": "08a75440e13e76c941f3936fbd4423e08bb04b55"
}

Error Response

If username already taken

  • Code: 400 Bad Request
  • Content:
{
    "username": "Такое имя пользователя уже используется на сайте. Пожалуйста выберите другое."
}

If email already taken

  • Code: 400 Bad Request
  • Content:
{
    "email": "Юзер уже зарегистрирован по этому адресу."
}

If email or password not specified

  • Code: 400 Bad Request
  • Content:
{
    "password": "Это поле не может быть пустым."
}
or
{
    "email": "Это поле не может быть пустым."
}

If password less than 6

  • Code: 400 Bad Request
  • Content:
{
    "password": "Минимальное количество символов в пароле: 6."
}

API for login user

POST: login/

Description

Authentification of user by email and password.

Data Params

Parameter Description
email required
password required

Response Params

Parameter Description
key Token key on success response

Success Response

  • Code: 200 OK
  • Content:
{
    "key": "08a75440e13e76c941f3936fbd4423e08bb04b55"
}

Error Response

If invalid credentials

  • Code: 400 Bad Request
  • Content:
{
    "error": "Невозможно войти с предоставленными учетными данными."
}

If not email

  • Code: 400 Bad Request
  • Content:
{
    "error": "Должен включать в себя либо email пользователя либо пароль."
}

If not password

  • Code: 400 Bad Request
  • Content:
{
    "password": "Это поле не может быть пустым."
}

API for logout user

POST: logout/

Description

Disconnect user from the server.

Success Response

  • Code: 200 OK
  • Content:
{
    "success": "Вы успешно вышли из системы."
}

API for password change

POST: password/change/

Data Params

Parameter Description
old_password required
new_password1 required(min=8, max=128)
new_password2 required(min=8, max=128)

Success Response

  • Code: 200 OK
  • Content:
{
    "success": "Новый пароль успешно сохранен."
}

Error Response

If old_password or new_password1 or new_password2 missed

  • Code: 400 Bad Request
  • Content:
{ 
    "old_password": "Это поле не может быть пустым."
}
or
{ 
    "new_password1": "Это поле не может быть пустым."
}
or
{
    "new_password2": "Это поле не может быть пустым."
}

If old password is not valid

  • Code: 400 Bad Request
  • Content:
{
    "old_password": "Неправильный пароль"
}

If new passwords did not match

  • Code: 400 Bad Request
  • Content:
{
    "new_password2": "Пароли не совпадают."
}

If new password is too short (<8)

  • Code: 400 Bad Request
  • Content:
{
    "new_password2": "Введённый пароль слишком короткий. Он должен содержать как минимум 8 символов."
}

API for send password reset link

POST: password/reset/

Description

Reset current password of user and send password recover link on the email.

Data Params

Parameter Description
email required(max=254, RFC 3696)

Success Response

  • Code: 200 OK
  • Content:
{
    "success": "На вашу почту была отправлена инструкция о востановлении пароля."
}

Error Response

If email is empty

  • Code: 400 Bad Request
  • Content:
{
    "email": "Это поле не может быть пустым."
}

If email is invalid

  • Code: 400 Bad Request
  • Content:
{
    "email": "Введите корректный адрес электронной почты."
}

API for get profile page

GET: user/

Description

Get current logged user profile data

Response Params

Parameter Description
id logged user id
email user email
image user photo link for render
first_name user first name
last_name user last name
middle_name user middle name
city user city
phone_number user phone number
start_url user page start url
latest_text_lessons latest 10 text lessons
latest_video_lessons latest 10 video lessons
completed_lessons total count of viewed lessons
favorite_lessons total count of favorite lessons

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 2,
    "email": "admin@example.com",
    "image": "http://5.101.125.15:8484/media/images/users/example_i4mu6yE.jpg",
    "first_name": "Carina",
    "last_name": "Marvin",
    "middle_name": "Patronymic 0",
    "city": "Lake Neola",
    "phone_number": "01234567890",
    "start_url": "http://www.howell-brown.com/",
    "latest_text_lessons": [
        {
            "id": 50,
            "text_author": "Автор текстовог оурока",
            "title": "Title 49",
            "seen_count": 0,
            "created_at": "2016-06-29T10:01:40.117670Z",
            "description": "Blanditiis nisi totam quasi deleniti quo qui. Adipisci similique excepturi molestias blanditiis. Officia amet molestias magnam.",
            "image": "http://5.101.125.15:8484/media/images/text-lessons/example_A0dAEqf.jpg"
        }
        
        ...

    ],
    "latest_video_lessons": [
        {
            "id": 50,
            "video_author": "Niger",
            "title": "Title 49",
            "seen_count": 0,
            "created_at": "2016-06-29T10:01:40.138831Z",
            "description": "Odio dolorum nulla totam fuga magni. Itaque porro esse modi quasi mollitia quo nihil. Labore consectetur similique animi nam quis labore officia.",
            "video_url": "http://5.101.125.15:8484/media/videos/video-lessons/test_video_F3WhkEx.mp4",
            "preview_image": "http://5.101.125.15:8484/media/images/video-lessons/example_F9gApEd.jpg"
        },
        
        ...

    ],
    "completed_lessons": 3,
    "favorite_lessons": 3
}

API for change profile page data

PUT | PATCH: user/

Description

Update current user profile data

Data Params

Parameter Description
image optional(max=100 - for name)
first_name optional(max=30)
last_name optional(max=30)
middle_name optional(max=30)
email optional(max=254 - RFC 3696 standart)
city optional(max=30)
phone_number optional(max=30)
start_url optional(max=200)

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "email": "dev1dor@ukr.net",
    "image": "http://localhost:8000/media/user_default.png",
    "first_name": "",
    "last_name": "",
    "middle_name": "",
    "city": "",
    "phone_number": null,
    "latest_text_lessons": [
        {
            "id": 1,
            "title": "Текстовый урок",
            "description": "цуацуацуа",
            "text_author": "Автор текстовог оурока",
            "created_at": "2016-09-03T13:10:06Z",
            "image": "http://localhost:8000/media/text/images_4VI9QYG.jpg"
        }
        ...
    ],
    "latest_video_lessons": [
        {
            "id": 1,
            "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
            "video_author": "Niger",
            "title": "Видео",
            "description": "Видео декср",
            "created_at": "2016-09-03T13:08:35Z",
            "preview_image": "http://localhost:8000/media/text/images.jpg"
        }
        ...
    ],
    "completed_lessons": 0,
    "favorite_lessons": 0
}

Error Response

If image invalid

  • Code: 400 Bad Request
  • Content:
{
    "image": "Загруженный файл не является корректным файлом. "
}

Consultants

API for consultant list

GET: consultants/

Description

Get consultant list with their rmail, phone, skype and photo.

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 3,
            "first_name": "Name",
            "last_name": "Fak",
            "image": "http://localhost:8000/media/user_default.png",
            "email": "",
            "phone_number": "+380938321243",
            "skype": "Skyper"
        }
        ...
    ]
}

Favorites

API for get user favorites video lessons

GET: user/favorites/video-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
            "video_author": "Niger",
            "title": "Видео",
            "description": "Видео декср",
            "created_at": "2016-09-03T13:08:35Z",
            "preview_image": "http://localhost:8000/media/text/images.jpg",
            "is_favorited": true,
            "is_viewed": false
        }
        ...
    ]
}

API for get user favorites text lessons

GET: user/favorites/text-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "title": "Текстовый урок",
            "description": "цуацуацуа",
            "text_author": "Автор текстовог оурока",
            "created_at": "2016-09-03T13:10:06Z",
            "image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
            "is_favorited": true,
            "is_viewed": false
        }
        ...
    ]
}

Views

API for get user viewed video lessons

GET: user/views/video-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
            "video_author": "Niger",
            "title": "Видео",
            "description": "Видео декср",
            "created_at": "2016-09-03T13:08:35Z",
            "preview_image": "http://localhost:8000/media/text/images.jpg",
            "is_viewed": false,
            "is_favorited": false
        }
    ]
}

API for get user favorites text lessons

GET: user/views/text-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "title": "Текстовый урок",
            "description": "цуацуацуа",
            "text_author": "Автор текстовог оурока",
            "created_at": "2016-09-03T13:10:06Z",
            "image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
            "is_favorited": true,
            "is_viewed": false
        }
    ]
}

Text lessons

API for text lessons

GET: text-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 50,
    "next": "http://localhost:8000/text-lessons/?page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "title": "Текстовый урок",
            "description": "цуацуацуа",
            "text_author": "Автор текстовог оурока",
            "created_at": "2016-09-03T13:10:06Z",
            "image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
            "is_viewed": false,
            "is_favorited": true
        }
    ]
}

API for detailed text lessons

GET: text-lessons/:id/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "title": "Текстовый урок",
    "description": "цуацуацуа",
    "text_author": "Автор текстовог оурока",
    "created_at": "2016-09-03T13:10:06Z",
    "image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
    "is_viewed": false,
    "is_favorited": false
}

API for add text lesson to favorites

POST: text-lessons/:id/favorites/

Success Response

  • Code: 200 OK (if already added, otherwise 201 Created)
  • Content:
{
    "id": 1,
    "title": "Текстовый урок",
    "description": "цуацуацуа",
    "text_author": "Автор текстовог оурока",
    "created_at": "2016-09-03T13:10:06Z",
    "image": "http://localhost:8000/media/text/images_4VI9QYG.jpg",
    "is_viewed": false,
    "is_favorited": false
}

Error Response

If not such text lesson

  • Code: 400 Bad Request
  • Content:
{
    "error": "Feed matching query does not exist."
}

API for remove text lesson from favorites

DELETE: text-lessons/:id/favorites/

Success Response

  • Code: 204 No Content

Video lessons

API for video lessons

GET: video-lessons/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 50,
    "next": "http://localhost:8000/video-lessons/?page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
            "video_author": "Niger",
            "title": "Видео",
            "description": "Видео декср",
            "created_at": "2016-09-03T13:08:35Z",
            "preview_image": "http://localhost:8000/media/text/images.jpg",
            "is_viewed": false,
            "is_favorited": true
        }
    ]
}

API for detailed video lessons

GET: video-lessons/:id/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
    "video_author": "Niger",
    "title": "Видео",
    "description": "Видео декср",
    "created_at": "2016-09-03T13:08:35Z",
    "preview_image": "http://localhost:8000/media/text/images.jpg",
    "is_viewed": false,
    "is_favorited": false,
    "similar_lessons": [
        {
            "id": 1,
            "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
            "video_author": "Niger",
            "title": "Видео",
            "description": "Видео декср",
            "created_at": "2016-09-03T13:08:35Z",
            "preview_image": "http://localhost:8000/media/text/images.jpg",
            "is_viewed": false,
            "is_favorited": true
        },
        
        ...
        
    ]
}

Error Response

If not lesson

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

API for video preview

POST: video-lessons/:id/views/

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 1,
    "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
    "video_author": "Niger",
    "title": "Видео",
    "description": "Видео декср",
    "created_at": "2016-09-03T13:08:35Z",
    "preview_image": "http://localhost:8000/media/text/images.jpg",
    "is_viewed": false,
    "is_favorited": false,
    "similar_lessons": [
        {
            "id": 1,
            "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
            "video_author": "Niger",
            "title": "Видео",
            "description": "Видео декср",
            "created_at": "2016-09-03T13:08:35Z",
            "preview_image": "http://localhost:8000/media/text/images.jpg",
            "is_viewed": false,
            "is_favorited": true
        },
        
        ...
        
    ]
}

Error Response

If user already seen

  • Code: 400 Bad Request
  • Content:
{
    "error": "Вы уже проголосовали за этот видеоурок."
}

API for add video lesson from favorites

POST: video-lessons/:id/favorites/

Success Response

  • Code: 200 OK (if already added, otherwise 201 Created)
  • Content:
{
    "id": 1,
    "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
    "video_author": "Niger",
    "title": "Видео",
    "description": "Видео декср",
    "created_at": "2016-09-03T13:08:35Z",
    "preview_image": "http://localhost:8000/media/text/images.jpg",
    "is_viewed": false,
    "is_favorited": true
}

Error Response

If not such video lesson

  • Code: 400 Bad Request
  • Content:
{
    "error": "Feed matching query does not exist."
}

API for remove video lesson to favorites

DELETE: video-lessons/:id/favorites/

Success Response

  • Code: 204 No Content

Online lesson

API for online lesson

GET: online-lesson/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 1,
    "created_at": "2016-06-23T14:55:58.206588Z",
    "show_date": "2016-08-12T14:55:58.205825Z",
    "link": "http://kessler.org/",
    "preview_image": "/media/images/online-lessons/example_9WaO8ln.jpg",
    "similar_lessons": [
        {
            "id": 1,
            "video_url": "https://translate.google.com.ua/?hl=ru#en/ru/instance",
            "video_author": "Niger",
            "title": "Видео",
            "description": "Видео декср",
            "created_at": "2016-09-03T13:08:35Z",
            "preview_image": "http://localhost:8000/media/text/images.jpg",
            "is_viewed": false,
            "is_responded": false
        },
        ...
    ]
}

Error Response

If not online lesson

  • Code: 404 Not Found
  • Content:
{
    "error": "Онлайн трансляция не найдена."
}

Supports

API for question to support

POST: supports/

Data Params

Parameter Description
text required(200)

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 102,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "middle_name": null
    },
    "created_at": "2016-06-22T10:02:18.058116Z",
    "text": "2323f23"
}

Wishes

API for add wish

POST: wishes/

Data Params

Parameter Description
text required(200)

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 102,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "middle_name": null
    },
    "created_at": "2016-06-22T10:02:18.058116Z",
    "text": "2323f23"
}

Needs

API for add need

POST: needs/

Data Params

Parameter Description
title required(50)
text required(200)
priority required(8, choices=[0, 1])
image optional
where priority:
  • 0 is "Обычная";
  • 1 is "Срочная";

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 6,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "middle_name": ""
    },
    "created_at": "2016-09-03T12:11:39.413390Z",
    "title": "Title image",
    "description": "Description some",
    "priority": 0,
    "image": "http://localhost:8000/media/need_default.png",
    "response_count": 0,
    "is_responded": false
}

API for get all needs

GET: needs/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 102,
    "next": "http://localhost:8000/needs/?page=2",
    "previous": null,
    "results": [
        {
            "id": 6,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "middle_name": ""
            },
            "created_at": "2016-09-03T12:11:39.413390Z",
            "title": "Title image",
            "description": "Description some",
            "priority": 0,
            "image": "http://localhost:8000/media/need_default.png",
            "response_count": 0,
            "is_responded": false
        }
    ]
}

API for detailed needs

GET: needs/:id/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 6,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "middle_name": ""
    },
    "created_at": "2016-09-03T12:11:39.413390Z",
    "title": "Title image",
    "description": "Description some",
    "priority": 0,
    "image": "http://localhost:8000/media/need_default.png",
    "response_count": 0,
    "is_responded": false
}

Error Response

If not need

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

API for delete need

DELETE: needs/:id/

Success Response

  • Code: 204 No Content

Error Response

If not need

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

If need not belongs to user

  • Code: 400 Bad Request
  • Content:
{
    "error": "You can not remove feed that don't belongs to you."
}

API for response on need

POST: needs/:id/responses/

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 6,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "middle_name": ""
    },
    "created_at": "2016-09-03T12:11:39.413390Z",
    "title": "Title image",
    "description": "Description some",
    "priority": 0,
    "image": "http://localhost:8000/media/need_default.png",
    "response_count": 0,
    "is_responded": true
}

Error Response

If user already responsed on need

  • Code: 400 Bad Request
  • Content:
{
    "error": "Вы уже откликнулись на эту нужду"
}

API for get all user needs

GET: user/needs/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 12,
    "next": "http://localhost:8000/user/needs/?page=2",
    "previous": null,
    "results": [
        {
            "id": 6,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "middle_name": ""
            },
            "created_at": "2016-09-03T12:11:39.413390Z",
            "title": "Title image",
            "description": "Description some",
            "priority": 0,
            "image": "http://localhost:8000/media/need_default.png",
            "response_count": 0,
            "is_responded": false
        }
    ]
}

Thanks

API for add thanks

POST: thanks/

Data Params

Parameter Description
title required(50)
text required(200)
address required(100)
photo optional

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 10,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "middle_name": ""
    },
    "created_at": "2016-09-03T12:16:36.778923Z",
    "title": "Title image23f2",
    "description": "Description some23f23",
    "address": null,
    "image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
    "views_count": 0,
    "is_viewed": false
}

API for get all thanks

GET: thanks/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 201,
    "next": "http://localhost:8000/thanks/?page=2",
    "previous": null,
    "results": [
        {
            "id": 10,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "middle_name": ""
            },
            "created_at": "2016-09-03T12:16:36.778923Z",
            "title": "Title image23f2",
            "description": "Description some23f23",
            "address": null,
            "image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
            "views_count": 0,
            "is_viewed": false
        }
        ...
    ]
}

API for detailed thanks

GET: thanks/:id/

Success Response

  • Code: 200 OK
  • Content:
{
    "id": 10,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "middle_name": ""
    },
    "created_at": "2016-09-03T12:16:36.778923Z",
    "title": "Title image23f2",
    "description": "Description some23f23",
    "address": null,
    "image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
    "views_count": 0,
    "is_viewed": false
}

Error Response

If not thank

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

API for delete thank

DELETE: thanks/:id/

Success Response

  • Code: 204 No Content

Error Response

If not thank

  • Code: 404 Not Found
  • Content:
{
    "error": "Не найдено."
}

If thank not belongs to user

  • Code: 400 Bad Request
  • Content:
{
    "error": "You can not remove feed that don't belongs to you."
}

API for thank view

POST: thanks/:id/views/

Success Response

  • Code: 201 Created
  • Content:
{
    "id": 10,
    "user": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "middle_name": ""
    },
    "created_at": "2016-09-03T12:16:36.778923Z",
    "title": "Title image23f2",
    "description": "Description some23f23",
    "address": null,
    "image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
    "views_count": 0,
    "is_viewed": true
}

Error Response

If user already viewed this thank

  • Code: 400 Bad Request
  • Content:
{
    "error": "Вы уже просмотрели эту благодарность."
}

API for get all user thanks

GET: user/thanks/

Success Response

  • Code: 200 OK
  • Content:
{
    "count": 201,
    "next": "http://localhost:8000/thanks/?page=2",
    "previous": null,
    "results": [
        {
            "id": 10,
            "user": {
                "id": 1,
                "first_name": "",
                "last_name": "",
                "middle_name": ""
            },
            "created_at": "2016-09-03T12:16:36.778923Z",
            "title": "Title image23f2",
            "description": "Description some23f23",
            "address": null,
            "image": "http://localhost:8000/media/feeds/images_7G6dtEm.jpg",
            "views_count": 0,
            "is_viewed": false
        }
        ...
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment