Skip to content

Cервис c HTTP API для учета личных финансов

Notifications You must be signed in to change notification settings

kekuchh/finance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cервис c HTTP API для учета личных финансов

Cервис c HTTP API для учета личных финансов (расходы, доходы, банковские счета).


В файле MEGAADDER.sql содержится конфигурация базы данных.

Параметры для подключения к базе данных задаются в файле DatabaseManager.

API

В случае успешной обработки запроса отправляется соответсвующий ответ (приведен в примере к каждому типу запроса).

В случае ошибки при обработке запроса отправляется ответ с описанием ошибки:

HTTP/1.1 400 Bad Request
content-length: ...
content-type: text/plain
server: Boost.Beast/345

"Описание ошибки..."

POST /accounts добавление нового счета

Request example

POST /accounts HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 41

{
  "name": "Sber",
  "amount": "10000"
}

Success response example

HTTP/1.1 201 Created
content-length: 0
content-type: text/plain
server: Boost.Beast/345
POST /expenses добавление новой опервции (расход)

Request example

POST /expenses HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 131

{
  "id_cat": "3",
  "id_account": "1",
  "amount": "1000",
  "date": "2022-12-12",
  "time": "12:12",
  "comment": "Pyaterochka"
}

Success response example

HTTP/1.1 201 Created
content-length: 0
content-type: text/plain
server: Boost.Beast/345
POST /income добавление новой опервции (доход)

Request example

POST /income HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 128

{
  "id_cat": "5",
  "id_account": "2",
  "amount": "1000",
  "date": "2022-12-12",
  "time": "12:12",
  "comment": "Cashback"
}

Success response example

HTTP/1.1 201 Created
content-length: 0
content-type: text/plain
server: Boost.Beast/345
POST /categories/expenses добавление новой категории расходов

Request example

POST /categories/expenses HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 20

{
  "name": "Cafe"
}

Success response example

HTTP/1.1 201 Created
content-length: 0
content-type: text/plain
server: Boost.Beast/345
POST /categories/income добавление новой категории доходов

Request example

POST /categories/income HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 20

{
  "name": "Cashback"
}

Success response example

HTTP/1.1 201 Created
content-length: 0
content-type: text/plain
server: Boost.Beast/345

PUT /accounts изменение данных счета

Request example

PUT /accounts HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 61

{
  "id_account": "1",
  "name": "VTB",
  "amount": "10000"
}

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345
PUT /expenses изменение данных операции (расходы)

Request example

PUT /expenses HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 152

{
  "id_expense": "2",
  "id_cat": "3",
  "id_account": "1",
  "amount": "1000",
  "date": "2022-12-12",
  "time": "12:12",
  "comment": "Pyaterochka"
}

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345
PUT /income изменение данных операции (доходы)

Request example

PUT /income HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 151

{
  "id_income": "123",
  "id_cat": "12",
  "id_account": "2",
  "amount": "1000",
  "date": "2022-12-12",
  "time": "12:12",
  "comment": "Cashback"
}

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345
PUT /categories /expenses изменение данных категории расходов

Request example

PUT /categories/expenses HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 37

{
  "id_cat": "2",
  "name": "Cafe"
}

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345
PUT /categories /income изменение данных категории доходов

Request example

PUT /categories/income HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 41

{
"id_cat": "2",
"name": "Cashback"
}

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345

GET /accounts?{id}=some_id информация о счете

Request example

GET /accounts?id=1 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 135
content-type: application/json
server: Boost.Beast/345

{
    "account": [
        {
            "id_account": "2",
            "name": "Tinkoff",
            "amount": "10000"
        }
    ]
}
GET /expenses?{id}=some_id информация об операции (расходы)

Request example

GET /expenses?id=3 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 257
content-type: application/json
server: Boost.Beast/345

{
    "expenses": [
        {
            "id_expense": "2",
            "id_cat": "2",
            "id_account": "2",
            "amount": "980",
            "date": "2023-01-29",
            "time": "13:31:00",
            "comment": ""
        }
    ]
}
GET /income?{id}=some_id информация об операции (доходы)

Request example

GET /income?id=3 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 257
content-type: application/json
server: Boost.Beast/345

{
    "income": [
        {
            "id_income": "2",
            "id_cat": "2",
            "id_account": "2",
            "amount": "20000",
            "date": "2023-01-15",
            "time": "16:31:00",
            "comment": ""
        }
    ]
}
GET /expenses?{begin}=some_date&{end}=some_date информация об операциях за период (расходы)

Request example

GET /expenses?begin=2022-12-12&end=2023-12-01 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 1004
content-type: application/json
server: Boost.Beast/345

{
    "begin": "2022-12-12",
    "end": "2023-12-01",
    "expenses": [
        {
            "id_expense": "3",
            "id_cat": "3",
            "id_account": "3",
            "amount": "1238",
            "date": "2023-01-12",
            "time": "16:01:00",
            "comment": ""
        },
        {
            "id_expense": "2",
            "id_cat": "2",
            "id_account": "2",
            "amount": "98",
            "date": "2023-01-29",
            "time": "13:31:00",
            "comment": ""
        },
        {
            "id_expense": "5",
            "id_cat": "5",
            "id_account": "2",
            "amount": "365",
            "date": "2023-02-25",
            "time": "09:32:00",
            "comment": ""
        }
    ]
}
GET /income?{begin}=some_date&{end}=some_date информация об операциях за период (доходы)

Request example

GET /income?begin=2022-12-12&end=2023-12-01 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 1005
content-type: application/json
server: Boost.Beast/345

{
    "begin": "2022-12-12",
    "end": "2023-12-01",
    "income": [
        {
            "id_income": "3",
            "id_cat": "3",
            "id_account": "3",
            "amount": "30000",
            "date": "2023-01-01",
            "time": "04:16:00",
            "comment": ""
        },
        {
            "id_income": "2",
            "id_cat": "2",
            "id_account": "2",
            "amount": "20000",
            "date": "2023-01-15",
            "time": "16:31:00",
            "comment": ""
        },
        {
            "id_income": "5",
            "id_cat": "5",
            "id_account": "2",
            "amount": "50000",
            "date": "2023-02-17",
            "time": "21:17:00",
            "comment": ""
        }
    ]
}
GET /categories/expenses?{id}=some_id&{begin}=some_date&{end}=some_date информация о всех операциях за период в категории (расходы)

Request example

GET /categories/expenses?id=3&begin=2022-12-12&end=2023-12-01 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 330
content-type: application/json
server: Boost.Beast/345

{
    "id_cat": "3",
    "begin": "2022-12-12",
    "end": "2023-12-01",
    "expenses": [
        {
            "id_expense": "3",
            "id_cat": "3",
            "id_account": "3",
            "amount": "1238",
            "date": "2023-01-12",
            "time": "16:01:00",
            "comment": ""
        },
        {
            "id_expense": "2",
            "id_cat": "3",
            "id_account": "2",
            "amount": "98",
            "date": "2023-01-29",
            "time": "13:31:00",
            "comment": ""
        },
        {
            "id_expense": "5",
            "id_cat": "3",
            "id_account": "2",
            "amount": "9999",
            "date": "2023-02-25",
            "time": "09:32:00",
            "comment": ""
        }
    ]
}
GET /categories/income?{id}=some_id&{begin}=some_date&{end}=some_date информация о всех операциях за период в категории (доходы)

Request example

GET /categories/income?id=2&begin=2022-12-12&end=2023-12-01 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 328
content-type: application/json
server: Boost.Beast/345

{
    "id_cat": "2",
    "begin": "2022-12-12",
    "end": "2023-12-01",
    "income": [
        {
            "id_income": "2",
            "id_cat": "2",
            "id_account": "2",
            "amount": "20000",
            "date": "2023-01-15",
            "time": "16:31:00",
            "comment": ""
        }
    ]
}

DELETE /accounts?{id}=some_id удаляет счет и все связанные с ним расходы и доходы

Request example

DELETE /accounts?id=3 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345
DELETE /expenses?{id}=some_id удаляет операцию (расходы)

Request example

DELETE /expenses?id=5 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345
DELETE /income?{id}=some_id удаляет операцию (доходы)

Request example

DELETE /income?id=5 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345
DELETE /categories/expenses?{id}=some_id удаляет категорию доходов (связанные с ней операции переходят в категорию "Other")

Request example

DELETE /categories/expenses?id=5 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345
DELETE /categories/income?{id}=some_id удаляет категорию расходов (связанные с ней операции переходят в категорию "Other")

Request example

DELETE /categories/income?id=5 HTTP/1.1
Host: localhost

Success response example

HTTP/1.1 200 OK
content-length: 0
content-type: text/plain
server: Boost.Beast/345

About

Cервис c HTTP API для учета личных финансов

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published