fix: Trash/Delete response structure

This commit is contained in:
James Houlahan
2023-02-27 18:22:44 +01:00
committed by James
parent f7e1f971c4
commit 6100d39d97

View File

@@ -42,15 +42,11 @@ func (c *Client) ListChildren(ctx context.Context, shareID, linkID string, showA
func (c *Client) TrashChildren(ctx context.Context, shareID, linkID string, childIDs ...string) error {
var res struct {
Responses struct {
Responses []struct {
LinkResponse struct {
LinkID string
Response APIError
}
}
}
}
for _, childIDs := range xslices.Chunk(childIDs, maxPageSize) {
req := struct {
@@ -65,9 +61,9 @@ func (c *Client) TrashChildren(ctx context.Context, shareID, linkID string, chil
return err
}
for _, res := range res.Responses.Responses {
if res.LinkResponse.Response.Code != SuccessCode {
return fmt.Errorf("failed to trash child: %w", res.LinkResponse.Response)
for _, res := range res.Responses {
if res.Response.Code != SuccessCode {
return fmt.Errorf("failed to trash child: %w", res.Response)
}
}
}
@@ -77,15 +73,11 @@ func (c *Client) TrashChildren(ctx context.Context, shareID, linkID string, chil
func (c *Client) DeleteChildren(ctx context.Context, shareID, linkID string, childIDs ...string) error {
var res struct {
Responses struct {
Responses []struct {
LinkResponse struct {
LinkID string
Response APIError
}
}
}
}
for _, childIDs := range xslices.Chunk(childIDs, maxPageSize) {
req := struct {
@@ -100,9 +92,9 @@ func (c *Client) DeleteChildren(ctx context.Context, shareID, linkID string, chi
return err
}
for _, res := range res.Responses.Responses {
if res.LinkResponse.Response.Code != SuccessCode {
return fmt.Errorf("failed to delete child: %w", res.LinkResponse.Response)
for _, res := range res.Responses {
if res.Response.Code != SuccessCode {
return fmt.Errorf("failed to delete child: %w", res.Response)
}
}
}