This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -7,11 +7,14 @@ import (
"net/http"
)
// Request struct for get information about account
type GetRequest struct {
// ID an account
// Required: true
AccountID uint64 `url:"accountId"`
}
func (arq GetRequest) Validate() error {
func (arq GetRequest) validate() error {
if arq.AccountID == 0 {
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
}
@@ -19,8 +22,9 @@ func (arq GetRequest) Validate() error {
return nil
}
func (a Account) Get(ctx context.Context, req GetRequest) (*AccountWithResources, error) {
err := req.Validate()
// Get gets account details
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
err := req.validate()
if err != nil {
return nil, err
}
@@ -32,13 +36,13 @@ func (a Account) Get(ctx context.Context, req GetRequest) (*AccountWithResources
return nil, err
}
account := &AccountWithResources{}
info := RecordAccount{}
err = json.Unmarshal(res, &account)
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return account, nil
return &info, nil
}