Giter VIP home page Giter VIP logo

golang-challenge's Introduction

Requirements

  • Implement a Rest API with CRUD functionality.
  • Database: MySQL or PostgreSQL.
  • Unit test as much as you can.
  • Set up service with docker compse.

Installation

  • Install docker
  • git clone https://github.com/moneyforwardvietnam/rory-exercise

Usage

  • docker-compose up

Detail of endpoints

1. Get transactions of an user with paginate

  • URL path: /api/v2/users/<user_id>/transactions
  • HTTP method: GET
  • Request:
    • Parameters:
      Name Required Data type Description
      user_id Yes Integer User's ID
      account_id No Integer Account's ID
      page No Integer Page
      size No Integer Size of a Page
  • Response:
    • Content type: application/json

    • HTTP status: 200 OK

    • Body:

      Name Data type Description
      data Array Array of user's transactions
      total Integer Transaction's Total
      page Integer Page

2. Get transactions of an user

  • URL path: /api/users/<user_id>/transactions

  • HTTP method: GET

  • Request:

    • Parameters:
      Name Required Data type Description
      user_id Yes Integer User's ID
      account_id No Integer Account's ID
    • Note: When account_id is not specified, return all transactions of the user.
    • Please have validations for required fields
  • Response:

    • Content type: application/json

    • HTTP status: 200 OK

    • Body: Array of user's transactions, each of which has the following fields:

      Name Data type Description
      id Integer Transaction's ID
      account_id Integer Account's id
      amount Decimal Amount of money
      bank String Bank's name
      transaction_type String Type of transaction
      created_at String Created date of transaction
  • Example: GET /api/users/1/transactions?account_id=1

    • Response:
      [{
        "id": 1,
        "account_id": 1,
        "amount": 100000.00,
        "bank": "VCB",
        "transaction_type": "deposit",
        "created_at": "2020-02-10 20:00:00 +0700"
      }, { ... }]

3. Create a transaction for an user

  • URL path: /api/users/<user_id>/transactions

  • HTTP method: POST

  • Request:

    • Parameters:

      Name Required Data type Description
      user_id Yes Integer User's ID
    • Body:

      Name Required Data type Description
      account_id Yes Integer Account's ID
      amount Yes Decimal Amount of money
      transaction_type Yes String Type of transaction
    • Please have validations for required fields

  • Response:

    • Content type: application/json

    • HTTP status: 201 Created

    • Body: Details of the created transaction with the following fields:

      Name Data type Description
      id Integer Transaction's ID
      account_id Integer Account's id
      amount Decimal Amount of transaction
      bank String Bank's name
      transaction_type String Type of transaction
      created_at String Created date of transaction
  • Example: POST /api/users/1/transactions

    • Request body:
      {
        "account_id": 2,
        "amount": 100000.00,
        "transaction_type": "deposit"
      }
    • Response
      {
        "id": 10,
        "account_id": 2,
        "amount": 100000.00,
        "bank": "VCB",
        "transaction_type": "deposit",
        "created_at": "2020-02-10 20:10:00 +0700"
      }

golang-challenge's People

Contributors

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