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