v9.0.0
This commit is contained in:
38
pkg/cloudapi/user/set_data.go
Normal file
38
pkg/cloudapi/user/set_data.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// SetDataRequest struct for setting extra user information.
|
||||
type SetDataRequest struct {
|
||||
// Data to set to user in json format
|
||||
// Required: true
|
||||
Data string `url:"data" json:"data" validation:"required"`
|
||||
}
|
||||
|
||||
// SetData sets extra user information.
|
||||
func (u User) SetData(ctx context.Context, req SetDataRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/user/setData"
|
||||
|
||||
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user