项目作者: PaulKish

项目描述 :
Bank Account API
高级语言: PHP
项目地址: git://github.com/PaulKish/bankapp.git
创建时间: 2017-03-08T17:55:44Z
项目社区:https://github.com/PaulKish/bankapp

开源协议:

下载


Folder structure

  1. bankapp/
  2. ├── application/
  3. ├── composer.json
  4. ├── composer.lock
  5. ├── public/
  6. ├── .htaccess
  7. └── index.php
  8. └── vendor/
  9. └── codeigniter/
  10. └── framework/
  11. └── system/
  12. ...
  13. └── schema/

Instructions

  • Clone Repo into folder e.g git clone https://github.com/PaulKish/bankapp.git bankapp
  • Run composer install to install dependencies
  • Setup schema into a MySQL instance. Schema can be found in schema folder
  • Edit application/config/database.php to correspond to your db user/password
  • If on a bash enabled system run:
  1. $ cd /path/to/bankapp
  2. $ bin/server.sh
  • On Windows you can run

    1. cd /path/to/bankapp/public
    2. php -S localhost:8000
  • Or if you have gitbash on Windows

    1. $ cd /path/to/bankapp
    2. sh bin\server.sh
  • Or copy the folder your WAMP/XAMPP webroot dir then access it from:
    `http://localhost/bankapp/public

Tests

  • Ensure you have PHPUnit setup in your system and is callable via phpunit on the terminal or cmd
  • To runs tests:
  1. $ cd /path/to/bankapp/application/tests
  2. $ phpunit

Bank Account API

End points

  • / - default
    • GET/POST methods allowed
    • No parameters required
  • /balance - returns account balance
    • GET/POST methods allowed
    • No parameters required
  • /deposit - allows depositing to account
    • POST method only
    • amount needed - send as form-data / e.g <?php $_POST['amount'] ?> should contain a numeric value
  • /withdraw - allows withdrawal
    • POST method only
    • amount needed - send as form-data / e.g <?php $_POST['amount'] ?> should contain a numeric value

Response structure

  1. {
  2. "version": "0.1",
  3. "links": [
  4. {
  5. "href": "/balance",
  6. "method": "GET"
  7. },
  8. {
  9. "href": "/withdraw",
  10. "method": "POST"
  11. },
  12. {
  13. "href": "/deposit",
  14. "method": "POST"
  15. }
  16. ],
  17. "status": "Success",
  18. "message": "Ok"
  19. }
  • Status can be False or Success depending on whether the process was successful
  • Message contains either Ok or the specifics of the error message
  • Account contains the balance
  • Transacation contains the transaction info
  1. "account": {
  2. "balance": 30000
  3. },
  4. "transaction": {
  5. "type": "Deposit",
  6. "amount": "30000",
  7. "date": "2017-03-08"
  8. }
  • Status codes include
    • 200 - Ok
    • 201 - Created
    • 400 - Bad request
    • 404 - Not found
    • 405 - Method not allowed

Misc