Code Monkey home page Code Monkey logo

invoice-trading's Introduction

Invoice Trading

To run this project

  • You must have Golang and Postgres installed on your machine
  • Clone the repo to your pc
  • Create a postgres database and update DB_URL the dev.env config file in the project /pkg/common/config/envs

-- example: postgres://username:password@localhost:5432/dbname

  • Change directory into the cmd folder and run the main file

-- example: cd cmd go run main.go

Simulating a successful Invoice trading flow

Call the following endpoints Postman collection: https://documenter.getpostman.com/view/23691891/2s93sjUomm

Create Two users, Investor and Issuer

Create User

http://localhost:3000/users POST

{
    "name":"Kelechi",
    "balance": 1000,
    "user_type":"investor"
}
{
    "name":"AREX Corp",
    "balance": 0,
    "user_type":"issuer"
}

** "user_type" takes two values "issuer" and "investor" **

User management endpoints

Get All Investors and Balance

http://127.0.0.1:3000/users/investors GET

[
   {
       "ID": 1,
       "CreatedAt": "2023-06-15T22:38:19.606949+01:00",
       "UpdatedAt": "2023-06-15T23:55:13.101905+01:00",
       "DeletedAt": null,
       "name": "kelechi",
       "balance": 500,
       "user_type": "investor"
   },
   {
       "ID": 4,
       "CreatedAt": "2023-06-16T18:54:38.683635+01:00",
       "UpdatedAt": "2023-06-16T18:54:38.683635+01:00",
       "DeletedAt": null,
       "name": "john",
       "balance": 1000,
       "user_type": "investor"
   }
]

Get Back an Issuer

http://127.0.0.1:3000/users/issuers/2 GET

{
  "ID": 2,
  "CreatedAt": "2023-06-15T22:38:31.794711+01:00",
  "UpdatedAt": "2023-06-15T23:55:36.953562+01:00",
  "DeletedAt": null,
  "name": "kcorp",
  "balance": 6500,
  "user_type": "issuer"
}
Create Invoice

http://127.0.0.1:3000/invoices/ POST

{
   "amount": 500,
   "issuer_id": 2
}
Place Bid

http://127.0.0.1:3000/invoices/bid POST

{
   "amount":1000,
   "investor_id":4,
   "invoice_id": 6
}

Fetch Back Invoice,status and associated bids

http://127.0.0.1:3000/invoices/6 GET

response

{
   "ID": 5,
   "CreatedAt": "2023-06-15T23:54:54.189733+01:00",
   "UpdatedAt": "2023-06-15T23:55:36.954197+01:00",
   "DeletedAt": null,
   "amount": 500,
   "amount_bided": 500,
   "issuer_id": 2,
   "reference": "somerandomstring",
   "status": "approved",
   "bids": [
       {
           "ID": 8,
           "CreatedAt": "2023-06-15T23:55:13.099163+01:00",
           "UpdatedAt": "2023-06-15T23:55:13.099163+01:00",
           "DeletedAt": null,
           "amount": 500,
           "invoice_id": 5,
           "investor_id": 1,
           "investor": {
               "ID": 1,
               "CreatedAt": "2023-06-15T22:38:19.606949+01:00",
               "UpdatedAt": "2023-06-15T23:55:13.101905+01:00",
               "DeletedAt": null,
               "name": "kelechi",
               "balance": 500,
               "user_type": "investor"
           }
       }
   ]
}
Update invoice trade GET

http://127.0.0.1:3000/invoices/6/update?action=approve ** You can set the action to either "approve" or "reject" **

invoice-trading's People

Contributors

khelechy avatar

Stargazers

Jesse Emana 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.