GithubHelp home page GithubHelp logo

ewallet's Introduction

ewallet

This web api is using framework Flask from python and database using MySQL

Installation instructions

  1. Make sure you have python > 3.7 Installed on your machine. Download Python.
  2. Clone this repo using command on your terminal git clone https://github.com/adityamuhammad/ewallet.git
  3. Copy .env.example to .env, and fill the value of the variable, (fill JWT_SECRET_KEY and DATABASE_URI_DEV value. example: Since I use mysql database for this project, so fill the DATABASE_URI_DEV value with mysql+pymysql://<username>:<password>@localhost/ewallet_dev. Also dont forget to create database with the name ewallet_dev.
  4. Run command on your terminal pip install pipenv if you dont have install pipenv yet.
  5. Run command pipenv shell to activate the virtual environment.
  6. Run command pip install -r requirements.txt to install modules.
  7. Set variable FLASK_ENV to development. Run command on terminal export FLASK_ENV=development, if you are using Windows use command set FLASK_ENV=development
  8. Set variable CONFIG_SETTING to config.Devconfig . Run command on terminal export CONFIG_SETTING=config.DevConfig, if you are using Windows use command set CONFIG_SETTING=config.DevConfig
  9. Run migration for database using command make migrate_dev. After that, run command make seed_dev for creating seed data.
  10. To run application, use command flask run.

Endpoint

1. Login

Used for authenticating registered user, get access token stored in cookie with httponly set to true.

URL : /token/auth

Method : POST

Auth required : NO

Request Body

{
    "email": "[valid email address]",
    "password": "[password in plain text]"
}

Request Header use default request header

Success Response

set access_token_cookie,csrf_access_token,refresh_token_cookie,csrf_refresh_token in header response

Code : 200 OK

Response body

{
    "msg": "login success."
}

Error Response

Condition : If 'email' and 'password' combination is wrong.

Code : 400 BAD REQUEST

Content :

{
    "msg": "login failed."
}

2. Refresh token

Used for refresh access token

URL : /token/refresh

Method : POST

Auth required : NO

Request Body None

Request Header

{
    "X-CSRF-TOKEN": "[csrf_refresh_token]",
    "refresh_token_cookie": "[refresh_token_cookie]"
}

Success Response

Code : 200 OK

Response body

{
    "msg": "token refreshed."
}

Error Response

Condition : If request header invalid.

Code : 401 UNAUTHORIZED

Content :

{
    "msg": "whether csrf token refresh or refresh token invalid"
}

3. remove token or logout

Used for remove access token

URL : /token/remove

Method : POST

Auth required : NO

Request Body None

Request Header None

Success Response

Code : 200 OK

Response body

{
    "msg": "logout success."
}

4. Topup

Used for topup

URL : /api/topup

Method : POST

Auth required : YES

Request Body

{
    "amount": "[amount]",
}

Request Header

{
    "X-CSRF-TOKEN": "[csrf_access_token]",
    "location": "[client location]",
    "ip-address": "[ip-address client]"
}

Success Response

Code : 200 OK

Response body

{
    "msg": "transaction success."
}

Error Response

Condition : If request send is invalid. Code : 400 BAD REQUEST

Content :

{
    "msg": "transaction failed."
}

5. Transfer

Used for transfer

URL : /api/transfer

Method : POST

Auth required : YES

Request Body

{
    "amount": "[amount]",
    "code": "[code]"
}

Request Header

{
    "X-CSRF-TOKEN": "[csrf_access_token]",
    "location": "[client location]",
    "ip-address": "[ip-address client]"
}

Success Response

Code : 200 OK

Response body

{
    "msg": "transaction success."
}

Error Response

Condition : If request send is invalid. Code : 400 BAD REQUEST

Content :

{
    "msg": "transaction failed."
}

ewallet's People

Contributors

adityamuhammad avatar

Stargazers

 avatar

Watchers

 avatar  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.