@@ -214,3 +214,67 @@ func (s *TasksService) EditSettingsTemplate(ctx context.Context, projectID, task
214214func (s * TasksService ) DeleteSettingsTemplate (ctx context.Context , projectID , taskSettingTemplateID int ) (* Response , error ) {
215215 return s .client .Delete (ctx , fmt .Sprintf ("/api/v2/projects/%d/tasks/settings-templates/%d" , projectID , taskSettingTemplateID ), nil )
216216}
217+
218+ // ListComments returns a list of task comments in a project.
219+ //
220+ // https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.getMany
221+ func (s * TasksService ) ListComments (ctx context.Context , projectID , taskID int , opts * model.ListOptions ) (
222+ []* model.TaskComment , * Response , error ,
223+ ) {
224+ res := new (model.TaskCommentsListResponse )
225+ resp , err := s .client .Get (ctx , fmt .Sprintf ("/api/v2/projects/%d/tasks/%d/comments" , projectID , taskID ), opts , res )
226+ if err != nil {
227+ return nil , resp , err
228+ }
229+
230+ list := make ([]* model.TaskComment , 0 , len (res .Data ))
231+ for _ , task := range res .Data {
232+ list = append (list , task .Data )
233+ }
234+
235+ return list , resp , err
236+ }
237+
238+ // GetComment returns a single task comment in a project by its identifier.
239+ //
240+ // https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.get
241+ func (s * TasksService ) GetComment (ctx context.Context , projectID , taskID , commentID int ) (
242+ * model.TaskComment , * Response , error ,
243+ ) {
244+ path := fmt .Sprintf ("/api/v2/projects/%d/tasks/%d/comments/%d" , projectID , taskID , commentID )
245+ res := new (model.TaskCommentResponse )
246+ resp , err := s .client .Get (ctx , path , nil , res )
247+
248+ return res .Data , resp , err
249+ }
250+
251+ // AddComment creates a new comment for a specific task in a project.
252+ //
253+ // https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.post
254+ func (s * TasksService ) AddComment (ctx context.Context , projectID , taskID int , req * model.TaskCommentAddRequest ) (
255+ * model.TaskComment , * Response , error ,
256+ ) {
257+ res := new (model.TaskCommentResponse )
258+ resp , err := s .client .Post (ctx , fmt .Sprintf ("/api/v2/projects/%d/tasks/%d/comments" , projectID , taskID ), req , res )
259+
260+ return res .Data , resp , err
261+ }
262+
263+ // EditComment updates a comment for a specific task in a project by its identifier.
264+ //
265+ // https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.patch
266+ func (s * TasksService ) EditComment (ctx context.Context , projectID , taskID , commentID int , req []* model.UpdateRequest ) (
267+ * model.TaskComment , * Response , error ,
268+ ) {
269+ res := new (model.TaskCommentResponse )
270+ resp , err := s .client .Patch (ctx , fmt .Sprintf ("/api/v2/projects/%d/tasks/%d/comments/%d" , projectID , taskID , commentID ), req , res )
271+
272+ return res .Data , resp , err
273+ }
274+
275+ // DeleteComment removes a comment from a specific task in a project by its identifier.
276+ //
277+ // https://support.crowdin.com/developer/api/v2/#tag/Tasks/operation/api.projects.tasks.comments.delete
278+ func (s * TasksService ) DeleteComment (ctx context.Context , projectID , taskID , commentID int ) (* Response , error ) {
279+ return s .client .Delete (ctx , fmt .Sprintf ("/api/v2/projects/%d/tasks/%d/comments/%d" , projectID , taskID , commentID ), nil )
280+ }
0 commit comments