This commit is contained in:
2023-10-23 12:40:54 +03:00
parent b069c31745
commit b666789c7d
73 changed files with 1134 additions and 641 deletions

View File

@@ -8,25 +8,16 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get information about VINS
// GetRequest struct to get information about VINS
type GetRequest struct {
// VINS ID
// Required: true
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
}
// Get gets information about VINS by ID
// Get gets information about VINS by ID as a RecordVINS struct
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudapi/vins/get"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := v.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -39,5 +30,19 @@ func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
}
return &info, nil
}
// GetRaw gets information about VINS by ID as an array of bytes
func (v VINS) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudapi/vins/get"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of VINSes
// ListRequest struct to get list of VINSes
type ListRequest struct {
// Find by ID
// Required: false
@@ -41,11 +41,9 @@ type ListRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
// List gets list of VINSes available for current user
// List gets list of VINSes available for current user as a ListVINS struct
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
url := "/cloudapi/vins/list"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := v.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -59,3 +57,11 @@ func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
return &list, nil
}
// ListRaw gets list of VINSes available for current user as an array of bytes
func (v VINS) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudapi/vins/list"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}