This commit is contained in:
2023-10-23 12:40:54 +03:00
parent b069c31745
commit b666789c7d
73 changed files with 1134 additions and 641 deletions

View File

@@ -8,25 +8,16 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get infromation about task
// GetRequest struct to get information about task
type GetRequest struct {
// ID of audit
// Required: true
AuditID string `url:"auditId" json:"auditId" validate:"required"`
}
// Get gets background API task status and result
// Get gets background API task status and result as a RecordAsyncTask struct
func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudapi/tasks/get"
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := t.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -41,3 +32,18 @@ func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error
return &info, nil
}
// GetRaw gets background API task status and result as an array of bytes
func (t Tasks) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudapi/tasks/get"
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of tasks
// ListRequest struct to get list of tasks
type ListRequest struct {
// Page number
// Required: false
@@ -17,11 +17,9 @@ type ListRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
// List gets list user API tasks with status PROCESSING
// List gets list of user API tasks with status PROCESSING as a ListTasks struct
func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
url := "/cloudapi/tasks/list"
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := t.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -35,3 +33,11 @@ func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
return &list, nil
}
// ListRaw gets list of user API tasks with status PROCESSING as an array of bytes
func (t Tasks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudapi/tasks/list"
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}