v1.3.0
This commit is contained in:
@@ -3,30 +3,25 @@ package vins
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get information about VINS
|
||||
type GetRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq GetRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets information about VINS by ID
|
||||
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/get"
|
||||
|
||||
Reference in New Issue
Block a user