v1.0.0
This commit is contained in:
@@ -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
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user