v1.8.0
This commit is contained in:
33
pkg/cloudapi/user/search.go
Normal file
33
pkg/cloudapi/user/search.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// SearchRequest struct for searching user's elements.
|
||||
type SearchRequest struct {
|
||||
// Text to search
|
||||
// Required: true
|
||||
Text string `url:"text" json:"text" validate:"required"`
|
||||
}
|
||||
|
||||
// Search searches for user's elements.
|
||||
func (u User) Search(ctx context.Context, req SearchRequest) (*FoundElements, error) {
|
||||
url := "/cloudapi/user/search"
|
||||
|
||||
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := FoundElements{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
Reference in New Issue
Block a user