You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
847 B
39 lines
847 B
package user
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/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
|
|
}
|