package plane_v1 import ( "fmt" "go.uber.org/zap" ) // ==================== Sticky (便签) API ==================== // ListStickies 列出便签 func ListStickies() ([]byte, error) { path := fmt.Sprintf("/api/v1/workspaces/%s/stickies/", planeWorkspaceSlug) resp, err := planeHttpGet(path) if err != nil { zap.L().Error("[Plane] ListStickies 请求失败", zap.Error(err)) return nil, err } if !isSuccess(resp.StatusCode) { zap.L().Error("[Plane] ListStickies 返回错误", zap.String("status", resp.Status)) return nil, fmt.Errorf("ListStickies 失败: %s", resp.Status) } return resp.Body, nil } // CreateSticky 创建便签 func CreateSticky(data map[string]interface{}) ([]byte, error) { path := fmt.Sprintf("/api/v1/workspaces/%s/stickies/", planeWorkspaceSlug) resp, err := planeHttpPost(path, data) if err != nil { zap.L().Error("[Plane] CreateSticky 请求失败", zap.Error(err)) return nil, err } if resp.StatusCode != 201 { zap.L().Error("[Plane] CreateSticky 返回错误", zap.String("status", resp.Status), zap.String("body", string(resp.Body))) return nil, fmt.Errorf("CreateSticky 失败: %s", resp.Status) } return resp.Body, nil } // GetSticky 获取便签详情 func GetSticky(stickyID string) ([]byte, error) { path := fmt.Sprintf("/api/v1/workspaces/%s/stickies/%s/", planeWorkspaceSlug, stickyID) resp, err := planeHttpGet(path) if err != nil { zap.L().Error("[Plane] GetSticky 请求失败", zap.Error(err)) return nil, err } if !isSuccess(resp.StatusCode) { zap.L().Error("[Plane] GetSticky 返回错误", zap.String("status", resp.Status)) return nil, fmt.Errorf("GetSticky 失败: %s", resp.Status) } return resp.Body, nil } // UpdateSticky 更新便签 func UpdateSticky(stickyID string, data map[string]interface{}) ([]byte, error) { path := fmt.Sprintf("/api/v1/workspaces/%s/stickies/%s/", planeWorkspaceSlug, stickyID) resp, err := planeHttpPatch(path, data) if err != nil { zap.L().Error("[Plane] UpdateSticky 请求失败", zap.Error(err)) return nil, err } if !isSuccess(resp.StatusCode) { zap.L().Error("[Plane] UpdateSticky 返回错误", zap.String("status", resp.Status), zap.String("body", string(resp.Body))) return nil, fmt.Errorf("UpdateSticky 失败: %s", resp.Status) } return resp.Body, nil } // DeleteSticky 删除便签 func DeleteSticky(stickyID string) error { path := fmt.Sprintf("/api/v1/workspaces/%s/stickies/%s/", planeWorkspaceSlug, stickyID) resp, err := planeHttpDelete(path) if err != nil { zap.L().Error("[Plane] DeleteSticky 请求失败", zap.Error(err)) return err } if resp.StatusCode != 204 { zap.L().Error("[Plane] DeleteSticky 返回错误", zap.String("status", resp.Status)) return fmt.Errorf("DeleteSticky 失败: %s", resp.Status) } return nil }