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 detailed information about service
type GetRequest struct {
// ID of the service to query information
// Required: true
ServiceID uint64 `url:"serviceId"`
}
func (bsrq GetRequest) Validate() error {
func (bsrq GetRequest) validate() error {
if bsrq.ServiceID == 0 {
return errors.New("field ServiceID can not be empty or equal to 0")
}
@@ -19,21 +22,26 @@ func (bsrq GetRequest) Validate() error {
return nil
}
func (b BService) Get(ctx context.Context, req GetRequest) (*BasicService, error) {
if err := req.Validate(); err != nil {
// Get gets detailed specifications for the BasicService.
func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService, error) {
err := req.validate()
if err != nil {
return nil, err
}
url := "/cloudapi/bservice/get"
bsRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
bs := &BasicService{}
if err := json.Unmarshal(bsRaw, bs); err != nil {
info := RecordBasicService{}
err = json.Unmarshal(bsRaw, &info)
if err != nil {
return nil, err
}
return bs, nil
return &info, nil
}