2024-06-06 18:56:35 +00:00
|
|
|
package account
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.supernets.org/perp/gopay/internal/context"
|
|
|
|
v1 "git.supernets.org/perp/gopay/internal/models/v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
// @summary Fetch an account
|
|
|
|
// @tags account
|
|
|
|
// @accept json
|
|
|
|
// @produce json
|
|
|
|
// @success 200 {object} v1.Account
|
|
|
|
// @response default {object} v1.Error "There was an error"
|
|
|
|
// @router /v1/account [get]
|
|
|
|
func Fetch(ctx *context.Context) {
|
|
|
|
// Call middleware
|
|
|
|
ctx.GetAccount()
|
|
|
|
|
|
|
|
// Account not found
|
|
|
|
if ctx.Account == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-06-06 19:07:47 +00:00
|
|
|
if ctx.Account.Username == "" {
|
|
|
|
ctx.Error(400, "InvalidToken")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-06-06 18:56:35 +00:00
|
|
|
// Create information
|
|
|
|
information := &v1.Account{
|
|
|
|
ID: ctx.Account.ID,
|
|
|
|
Username: ctx.Account.Username,
|
|
|
|
Admin: ctx.Account.Admin,
|
|
|
|
Created: ctx.Account.Created.Unix(),
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.JSON(200, information)
|
|
|
|
}
|