Git Product home page Git Product logo

avitotest's Introduction

avitotest1022


Микросервис для работы с балансом пользователей


Этот сервис API, состоящий из базы данных PostgreSQL, в которую записываются данные работы балансом и сервис golang API, который обрабатывает POST и GET запросы.

Описание API

Query: Header POST: URL/create

Body:

{
"initial_balance": 10000
}

Response on success:

{
    "client_id": 1234
}

Body:

{
    "initial_balance": -10000
}

Response on error:

{
    "error": "unable to create user"
}

Query: Header GET: URL/balance

Body:

{
    "client_id": 3480
}

Response on success:

{
    "balance": 10000
}

Response on error:

{
    "balance": 0,
    "error": "unable to create user"
}

Query: Header POST: URL/refill

Body:

{
    "client_id": 3480,
    "amount": 3000
}

Response on success:

{
    "approved": true
}

Response on error:

{
    "approved": false,
    "error": "unable to refill balance"
}

Query: Header POST: URL/withdrawal

Body:

{
    "client_id": 3480,
    "service_id": 256,
    "order_id": 500,
    "amount": 4500
}

Response on success:

{
    "success": true
}

Response on error:

{
    "success": false,
    "error": "unable to create withdrawal"
}

Query: Header POST: URL/processWithdrawal

Body:

{
    "client_id": 3480,
    "service_id": 256,
    "order_id": 500,
    "amount": 4500
}

Response on success:

{
    "success": true
}

Response on error:

{
    "success": false,
    "error": "unable to process withdrawal"
}

Query: Header POST: URL/cancelWithdrawal

Body:

{
    "client_id": 3480,
    "service_id": 256,
    "order_id": 500,
    "amount": 4500
}

Response on success:

{
    "success": true
}

Response on error:

{
    "success": false,
    "error": "unable to cansel withdrawal"
}

Запуск сервиса локально

2. Используйте docker-compose для создания контейнеров с помощью PostgreSQL и сервиса API

docker compose up

3. Откройте браузер или приложение для тестирования API, введите localhost:80/create и сделайте несколько запросов!


avitotest's People

Contributors

giusepperoro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.