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.
43 lines
1.1 KiB
43 lines
1.1 KiB
package folder
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/internal/constants"
|
|
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/internal/validators"
|
|
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/pkg/folder/models"
|
|
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/pkg/folder/requests"
|
|
)
|
|
|
|
// List gets a list of all folder
|
|
func (f Folder) List(ctx context.Context, req requests.ListFolderRequest) (*models.ListFolderResponse, error) {
|
|
|
|
res, err := f.ListRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
list := models.ListFolderResponse{}
|
|
|
|
err = json.Unmarshal(res, &list)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &list, nil
|
|
}
|
|
|
|
// ListRaw gets a list of all folders as an array of bytes
|
|
func (f Folder) ListRaw(ctx context.Context, req requests.ListFolderRequest) ([]byte, error) {
|
|
|
|
if err := validators.ValidateRequest(req); err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := constants.APIv0 + "/folder"
|
|
|
|
res, err := f.client.ApiCall(ctx, http.MethodGet, url, req)
|
|
return res, err
|
|
}
|