mirror of
https://github.com/ProtonMail/go-proton-api.git
synced 2025-12-23 23:57:50 -05:00
fix: Trash/Delete response structure
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user