From 67a8642245250c05ac08f556bd4e8b69965e03c4 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Mon, 14 Jun 2021 10:59:03 -0700 Subject: [PATCH] added ? to query param of setbal & sendfunds --- help.md | 4 ++-- include/bank_f.h | 4 ++-- src/bank_f.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/help.md b/help.md index c4a15ef..79ada56 100644 --- a/help.md +++ b/help.md @@ -18,14 +18,14 @@ | :------------: | :------------------------------------- | :----: | :---: | -------------------------------------------------------------------------------------------------- | | GetBal | BankF/{name}/bal | GET | false | returns the balance of a given user `{name}` | | GetLog | BankF/{name}/log | GET | true | returns a list of last `n` number of transactions (a configurable amount) of a given user `{name}` | -| SendFunds | BankF/{name}/send/{to}/amount={amount} | POST | true | sends `{amount}` from user `{name}` to user `{to}` | +| SendFunds | BankF/{name}/send/{to}?amount={amount} | POST | true | sends `{amount}` from user `{name}` to user `{to}` | | VerifyPassword | BankF/{name}/pass/verify | GET | true | returns `1` if the supplied user `{name}`'s password matches the password supplied in the header | # Meta Usage | Name | Path | Method | A | Description | | :------------: | :------------------------------------- | :----: | :---: | ---------------------------------------------------------------------------------------------------------------------------------------- | | ChangePassword | BankF/{name}/pass/change | PATCH | true | if the password supplied in the header matches the user `{name}`'s password, the user's password is changed to the one given in the body | -| SetBal | BankF/admin/{name}/bal/amount={amount} | PATCH | true | sets the balance of a give user `{name}` if the supplied password matches the admin password | +| SetBal | BankF/admin/{name}/bal?amount={amount} | PATCH | true | sets the balance of a give user `{name}` if the supplied password matches the admin password | # System Usage | Name | Path | Method | A | Description | diff --git a/include/bank_f.h b/include/bank_f.h index 5b17c17..fc3703f 100644 --- a/include/bank_f.h +++ b/include/bank_f.h @@ -33,12 +33,12 @@ public: //Usage METHOD_ADD(BankF::GetBal, "/{name}/bal", Get, Options); METHOD_ADD(BankF::GetLog, "/{name}/log", Get, Options); - METHOD_ADD(BankF::SendFunds, "/{name}/send/{to}/amount={amount}", Post, Options); + METHOD_ADD(BankF::SendFunds, "/{name}/send/{to}?amount={amount}", Post, Options); METHOD_ADD(BankF::VerifyPassword, "/{name}/pass/verify", Get, Options); //Meta Usage METHOD_ADD(BankF::ChangePassword, "/{name}/pass/change", Patch, Options); - METHOD_ADD(BankF::SetBal, "/admin/{name}/bal/amount={amount}", Patch, Options); + METHOD_ADD(BankF::SetBal, "/admin/{name}/bal?amount={amount}", Patch, Options); //System Usage METHOD_ADD(BankF::Help, "/help", Get, Options); diff --git a/src/bank_f.cpp b/src/bank_f.cpp index 9cfe056..b47ffe2 100644 --- a/src/bank_f.cpp +++ b/src/bank_f.cpp @@ -31,7 +31,7 @@ BankF::BankF(Bank *b) : bank(*b) {} void BankF::Help(req_args) const { auto resp = HttpResponse::newHttpResponse(); - resp->setBody("# Meta Usage

Error Responses

# meaning
-1 UserNotFound
-2 WrongPassword
-3 InvalidRequest
-4 NameTooLong
-5 UserAlreadyExists
-6 InsufficientFunds

Things of Note

Usage

Name Path Method A Description
GetBal BankF/{name}/bal GET false returns the balance of a given user {name}
GetLog BankF/{name}/log GET true returns a list of last n number of transactions (a configurable amount) of a given user {name}
SendFunds BankF/{name}/send/{to}/amount={amount} POST true sends {amount} from user {name} to user {to}
VerifyPassword BankF/{name}/pass/verify GET true returns 1 if the supplied user {name}'s password matches the password supplied in the header

Meta Usage

Name Path Method A Description
ChangePassword BankF/{name}/pass/change PATCH true if the password supplied in the header matches the user {name}'s password, the user’s password is changed to the one given in the body
SetBal BankF/admin/{name}/bal/amount={amount} PATCH true sets the balance of a give user {name} if the supplied password matches the admin password

System Usage

Name Path Method A Description
Help BankF/help GET false the page you’re looking at right now!
Ping BankF/ping GET false for pinging the server to see if its online
Close BankF/admin/close POST true saves and then closes the program if the supplied password matches the admin password
Contains BankF/contains/{name} GET false returns 1 if the supplied user {name} exists
AdminVerifyPass BankF/admin/verify GET true returns 1 if the password supplied in the header matches the admin password

User Management

Name Path Method A Description
AddUser BankF/user/{name} POST true registers a user with the name {name}, balance of 0 and a password of the password supplied in the header
AdminAddUser BankF/admin/user/{name}?init_bal={init_bal} POST true if the password supplied in the header matches the admin password, then it registers a user with the name {name}, balance of init_bal and a password supplied by the body of the request
DelUser BankF/user/{name} DELETE true if the password supplied in the header matches the user {name}'s password, then the user is deleted
AdminDelUser BankF/admin/user/{name} DELETE true if the password supplied in the header matches the admin password, then the user is deleted
"); + resp->setBody("# Meta Usage

Error Responses

# meaning
-1 UserNotFound
-2 WrongPassword
-3 InvalidRequest
-4 NameTooLong
-5 UserAlreadyExists
-6 InsufficientFunds

Things of Note

Usage

Name Path Method A Description
GetBal BankF/{name}/bal GET false returns the balance of a given user {name}
GetLog BankF/{name}/log GET true returns a list of last n number of transactions (a configurable amount) of a given user {name}
SendFunds BankF/{name}/send/{to}?amount={amount} POST true sends {amount} from user {name} to user {to}
VerifyPassword BankF/{name}/pass/verify GET true returns 1 if the supplied user {name}'s password matches the password supplied in the header

Meta Usage

Name Path Method A Description
ChangePassword BankF/{name}/pass/change PATCH true if the password supplied in the header matches the user {name}'s password, the user’s password is changed to the one given in the body
SetBal BankF/admin/{name}/bal?amount={amount} PATCH true sets the balance of a give user {name} if the supplied password matches the admin password

System Usage

Name Path Method A Description
Help BankF/help GET false the page you’re looking at right now!
Ping BankF/ping GET false for pinging the server to see if its online
Close BankF/admin/close POST true saves and then closes the program if the supplied password matches the admin password
Contains BankF/contains/{name} GET false returns 1 if the supplied user {name} exists
AdminVerifyPass BankF/admin/verify GET true returns 1 if the password supplied in the header matches the admin password

User Management

Name Path Method A Description
AddUser BankF/user/{name} POST true registers a user with the name {name}, balance of 0 and a password of the password supplied in the header
AdminAddUser BankF/admin/user/{name}?init_bal={init_bal} POST true if the password supplied in the header matches the admin password, then it registers a user with the name {name}, balance of init_bal and a password supplied by the body of the request
DelUser BankF/user/{name} DELETE true if the password supplied in the header matches the user {name}'s password, then the user is deleted
AdminDelUser BankF/admin/user/{name} DELETE true if the password supplied in the header matches the admin password, then the user is deleted
"); resp->setExpiredTime(0); callback(resp); }