Merge 'dev' into 'main'

This commit is contained in:
stSolo
2022-10-03 16:56:47 +03:00
parent 6271fa6d45
commit 5fd450382c
400 changed files with 14394 additions and 13407 deletions

View File

@@ -1,55 +1,44 @@
package vins
import (
"context"
"encoding/json"
"errors"
"github.com/rudecs/decort-sdk/opts"
"github.com/rudecs/decort-sdk/typed"
)
type GetRequest struct {
VinsId uint64 `url:"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
}
func (v Vins) Get(ctx context.Context, req GetRequest, options ...opts.DecortOpts) (*VinsDetailed, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/vins/get"
prefix := "/cloudapi"
option := opts.New(options)
if option != nil {
if option.IsAdmin {
prefix = "/" + option.AdminValue
}
}
url = prefix + url
res, err := v.client.DecortApiCall(ctx, typed.POST, url, req)
if err != nil {
return nil, err
}
vins := &VinsDetailed{}
err = json.Unmarshal(res, vins)
if err != nil {
return nil, err
}
return vins, nil
}
package vins
import (
"context"
"encoding/json"
"errors"
"net/http"
)
type GetRequest struct {
VINSID uint64 `url:"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
}
func (v VINS) Get(ctx context.Context, req GetRequest) (*VINSDetailed, error) {
err := req.Validate()
if err != nil {
return nil, err
}
url := "/cloudapi/vins/get"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
VINS := &VINSDetailed{}
err = json.Unmarshal(res, VINS)
if err != nil {
return nil, err
}
return VINS, nil
}