mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-08 23:18:15 -07:00
api docs, minor changes
This commit is contained in:
parent
4aa8a2f822
commit
c249a077cc
3 changed files with 203 additions and 9 deletions
|
|
@ -17,9 +17,8 @@ import (
|
|||
// TODO: Put user info fetching code into middleware
|
||||
|
||||
type GetBalanceResponse struct {
|
||||
Status int `json:"status"`
|
||||
RequestID string `json:"request_id"`
|
||||
Data money.Money `json:"data"`
|
||||
Status int `json:"status"`
|
||||
Balance money.Money `json:"balance"`
|
||||
}
|
||||
|
||||
func GetBalance(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -39,9 +38,8 @@ func GetBalance(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
response := GetBalanceResponse{
|
||||
Status: 200,
|
||||
RequestID: "0",
|
||||
Data: money.Money{
|
||||
Status: 200,
|
||||
Balance: money.Money{
|
||||
Currency: user.Balance.Currency,
|
||||
Whole: user.Balance.Whole,
|
||||
Decimal: user.Balance.Decimal,
|
||||
|
|
@ -96,9 +94,8 @@ func SetBalance(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
response := GetBalanceResponse{
|
||||
Status: 200,
|
||||
RequestID: "0",
|
||||
Data: money.Money{
|
||||
Status: 200,
|
||||
Balance: money.Money{
|
||||
Currency: newBalance.Currency,
|
||||
Whole: newBalance.Whole,
|
||||
Decimal: newBalance.Decimal,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import (
|
|||
)
|
||||
|
||||
type BudgetResponse struct {
|
||||
Status int `json:"status"`
|
||||
// total amount allowed to spend in a month
|
||||
Budget money.Money `json:"budget"`
|
||||
// total amount allowed to spend by category
|
||||
|
|
@ -59,6 +60,8 @@ func GetBudget(w http.ResponseWriter, r *http.Request) {
|
|||
response.Expenses[e.Category] = append(response.Expenses[e.Category], e)
|
||||
}
|
||||
|
||||
response.Status = 200
|
||||
|
||||
ret, err := json.Marshal(response)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue