Coder Social home page Coder Social logo

billing-web-service's Introduction

Asynchronous Web Service

This billing web-service works by json-rpc 2.0 protocol.

Web service use aiohttp for asynchronous request processing and aiopg engine for work with PostgreSQL database.

You can use three methods:

  • create_account
  • transfer_money
  • get_balance

(Batch requests are not supported yet.)

Examples

create_account

  • create_account user_1

    • request: {'method': 'create_account', 'params': ['user_1', True], 'jsonrpc': '2.0', 'id': 1}
    • response: {'result': 1, 'id': 1, 'jsonrpc': '2.0'}
  • create_account user_2

    • request: {'method': 'create_account', 'params': {'name': 'user_2', 'overdraft': True}, 'jsonrpc': '2.0'}
    • response: {'result': 2, 'id': None, 'jsonrpc': '2.0'}

transfer_money

  • transfer_money money from user_1 to user_2

    • request: {'method': 'transfer_money', 'params': {'donor_id': 1, 'recipient_id': 2, 'amount': 5 }, 'jsonrpc': '2.0'}
    • response: {'result': True, 'id': None, 'jsonrpc': '2.0'}
  • transfer_money money from user_2 to user_1

    • request: {'method': 'transfer_money', 'params': [2, 1, 300], 'jsonrpc': '2.0', 'id': 2}
    • response: {'result': True, 'id': 2, 'jsonrpc': '2.0'}

get_balance

  • get_balance user_1

    • request: {'method': 'get_balance', 'params': [1], 'jsonrpc': '2.0', 'id': 3}
    • response: {'result': 295.0, 'id': 3, 'jsonrpc': '2.0'}
  • get_balance user_2

    • request: {'method': 'get_balance', 'params': {'account_id': 2}, 'jsonrpc': '2.0'}
    • response: {'result': -295.0, 'id': None, 'jsonrpc': '2.0'}

Requirements

  • Python >= 3.7
  • PostgreSQL

Installation and launch

  1. Clone the repository:

    git clone https://github.com/antauren/billing-web-service.git
    cd billing-web-service
  2. Install requirements:

    pip install -r requirements.txt
    
  3. Create environment file from example:

    cp .env.example .env
  4. Personalize settings by modifying .env with your preferable text editor.

  5. Run server:

    python server.py
    
  6. Launch client:

    python client.py
    

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.