Skip to content

philiplambok/ayano-payment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ayano Payment

Ayano Payment is rails api-only project for learning tdd (Test driven development).

Overview

Ayano payment or Ayano-Pay is payment or bank gateway service.

Core Features :

  • Authentication
  • Roles
  • Users
  • Deposits
  • Transactions
  • Loggings

Enpoints

Authentication

Sign In
  • URL

    /api/auth

  • Method

    POST

  • URL Params

    None

  • Data Params

    "auth": {
      "username": "your_username", 
      "password": "your_password"
    }
  • Success Response

    {
      "jwt": "your_token"
    }
  • Error Response

    Status Message
    422 Sorry, username or password is wrong
  • Notes

    For next request, add token in header: Authorization: Bearer <your_token>

Roles

Show List Roles
  • URL

    /api/roles

  • Method

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response

    {
      "roles": [
        {
          "role": {
            "id": 1, 
            "name": "admin"
          }
        }, 
        {
          "role": {
            "id": 2, 
            "name": "member"
          }
        }
      ]
    } 
  • Error Response

    Status Message
    401 Sorry, you're not authenticated
    403 Sorry, you don't have permission
  • Notes

    Show list of roles just for admin

Create New Role
  • URL

    /api/roles/

  • Method

    POST

  • URL Params

    None

  • Data Params

    {
      "role": {
        "id": 1, 
        "name": "admin"
      }
    }
  • Success Response

    {
      "role": {
        "id": 1, 
        "name": "admin"
      }
    }
  • Error Response

    Status Message
    422 Name can't be blank
    401 Sorry, you're not authenticated
    403 Sorry, you don't have permission
  • Notes

    Create new role just for admin.

Show Role
  • URL

    /api/roles/:id

  • Method

    GET

  • URL Params

    Required

    id=[integer]

  • Data Params

    None

  • Success Response

    {
      "role": {
        "id": 1, 
        "name": "admin"
      }
    }
  • Error Response

    Status | Message 401 | Sorry, you're not authenticated 403 | Sorry, you don't have permission 404 | Sorry, role not found

  • Notes

    Show role just for admin

Update Role
  • URL

    /api/roles/:id

  • Method

    PUT | PATCH

  • URL Params

    Required

    id=[integer]

  • Data Params

    {
      "role": {
        "id": 1, 
        "name": "Admin Edit"
      }
    }
  • Success Response

    {
      "role": {
        "id": 1, 
        "name": "Admin Edit"
      }
    } 
  • Error Response

    Status Message
    401 Sorry, you're not authenticated
    403 Sorry, you don't have permission
    422 Name can't be blank, Role can't be blank
  • Notes

    Update role just for admin.

Delete Role
  • URL

    /api/role/:id

  • Method

    DELETE

  • URL Params

    None

  • Data Params

    None

  • Success Response

    {
      "role": {
        "id": 1, 
        "name": "Admin Edit"
      }
    }
  • Error Response

    Status | Message 401 | Sorry, you're not authenticated 403 | Sorry, you don't have permission 404 | Role not found

  • Notes

    Delete role just for admin.

Users

Show Current User
  • URL

    /api/me

  • Method

    GET

  • URL Params

    None

  • Data Params

    None

  • Success Response

    {
      "user": {
        "id": 2, 
        "username": "pquest"
      }
    } 
  • Error Response

    Status Message
    404 User not found
  • Notes Don't check authenticated status when visit this.

Create New User
  • URL

    /api/users

  • Method

    POST

  • URL Params

    None

  • Data Params

    {
      "user": {
        "username": "chthonic", 
        "password": "secretcode", 
        "password_confirmation": "secretcode" 
      }
    } 
  • Success Response

    {
      "user": {
        "id": 1,
        "username": "chthonic"
      }
    } 
    • Error Response

      Status Message
      422 Username can't be blank, Password can't be blank, Password doesn't match
Show User
  • URL

    /api/users/:id

  • Method

    GET

  • URL Params

    Required

    id=[integer]

  • Data Params

    None

  • Success Response

    {
      "user": {
        "id": 1, 
        "username": "pquest"
      }
    } 
  • Error Response

    Status | Message 404 | User not found

Update User
  • URL

    /api/users/:id

  • Method

    PUT | PATCH

  • URL Params

    Required

    id=[integer]

  • Data Params

    {
      "user": {
        "username": "pquestedit", 
        "password": "secretcodeedit",
        "password_confirmation": "secretcodeedit"
      }
    } 
  • Success Response

    {
      "user": {
        "username": "pquestedit"
      }
    } 
  • Error Response

    Status | Message 401 | Sorry, you're not authenticated 403 | Sorry, you don't have permission 404 | User not found 422 | Username can't be blank, Password can't be blank, Password doesn't match

  • Notes

    This feature just can be used by owner or admin.

Delete User
  • URL

    /api/users/:id

  • Method

    DELETE

  • URL Params

    Required

    id=[integer]

  • Data Params

    None

  • Success Response

    {
      "user": {
        "id": 1, 
        "username": "pquest"
      }
    } 
  • Error Response

    Status | Message 401 | Sorry, you're not authenticated 403 | Sorry, you don't have permission

Show User Role
  • URL

    /api/users/:id/role

  • Method

    GET

  • URL Params

    id=[integer]

  • Data Params

    None.

  • Success Response

    {
      "role": {
        "id": 2,
        "name": "member"
      }
    } 
  • Error Response

    Status | Message 401 | Sorry, you're not authenticated 403 | Sorry, you don't have permission 404 | User not found

  • Notes

    None.

Deposits

Show Deposit
  • URL

    /api/users/:id/deposits

  • Method

    GET

  • URL Params

    id=[integer]

  • Data Params

    None

  • Success Response

    {
      "amount": "100000"
    } 
  • Error Response

    Status Message
    401 Sorry, you're not authenticated
    403 Sorry, you don't have permission
    404 User not found
Save Deposit
  • URL

    /api/users/:id/deposits/

  • Method

    POST

  • URL Params

    Required

    id=[integer]

  • Data Params

    {
      "type": "save", 
      "ammount": "50000"
    } 
  • Success Response

    {
      "amount": "150000"
    }
  • Error Response

    Status Message
    401 Sorry, you're not authenticated
    403 Sorry, you haven't permission
    404 User not found
  • Notes

    None

Take Deposit
  • URL

    /api/users/:id/deposits

  • Method

    POST

  • URL Params

    id=[integer]

  • Data Params

    {
      "type": "take", 
      "amount": "70000"
    } 
  • Success Response

    {
      "amount": "80000"
    } 
  • Error Response

    Status | Message 401 | Sorry, you're not authenticated 403 | Sorry, you don't have permission 404 | User not found 422 | Sorry, your deposit is not enough

  • Notes

    None.

Transaction

Add Transaction
  • URL

    /api/users/:id/transactions

  • Method

    POST

  • URL Params

    Required

    id=[integer]

  • Data Params

    {
      "transaction": {
        "to": 1,
        "amount": "50000" 
      }
    }
  • Success Response

    {
      "deposit": {
        "ammount": "100000"
      }
    } 
  • Error Response

    Status Message
    401 Sorry, you're not authenticated
    403 Sorry, you don't have permission
    404 Sorry, user not found
    422 Sorry, your deposit is not enough
  • Notes

    transaction.to is value of user_id

Logs

Show Logs
  • URL

    /api/users/:id/logs

  • Method

    GET

  • URL Params

    id=[integer]

  • Data Params

    None.

  • Success Response

    {
      "logs": [
        {
          "log": {
            "message": "You send 200000 to pquest",
            "created_at": "27-08-2017 15:30"
          }
        }, 
        {
          "log": {
            "message": "You take deposit 100000",
            "created_at": "27-08-2017 12:30"
          }
        }, 
        {
          "log": {
            "message": "You added deposit 500000",
            "created_at": "27-08-2017 10:30"
          }
        }, 
      ]
    } 
  • Error Response

    Status Message
    401 Sorry, you're not authenticated
    403 Sorry, you don't have permission
    404 User not found
  • Notes

    None.

Usage

  1. Clone the repo
  2. Run bundle
  3. Run bin/rspec to test that everything works.
  4. Run rails s
  5. Test with api-tester like curl / postman / etc..

Version

Last Releases: v1.0

Licenses

MIT License.

About

Cute Payment Made Easy (just for learning purpose)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published