@@ -382,20 +382,44 @@ public void deleteComment(long id) {
382
382
383
383
public List <Activity > getActivityForTask (long id ) {
384
384
try {
385
- HttpResponse <String > response = Unirest .post (URL_BASE + "/activity/get" )
386
- .header ("Content-Type" , "application/json" )
387
- .body (new ActivityRequest (30 , 0 , Arrays .asList ("item:" , "note:added" ), id ))
388
- .asString ();
389
- if (response .getStatus () != HTTP_OK ) {
390
- throw new Exception ("HTTP STATUS " + response .getStatus ());
391
- }
385
+ int limit = 30 ;
386
+ int offset = 0 ;
387
+ int count ;
388
+
389
+ do {
390
+ System .out .println (JsonAdapters .writeActivityRequest (new ActivityRequest (limit , offset , Arrays .asList ("item:" , "note:added" ), id , true , true )));
391
+ HttpResponse <String > response = Unirest .post ("https://todoist.com/API/v8/activity/get" )
392
+ .header ("Content-Type" , "application/json" )
393
+ .body (JsonAdapters .writeActivityRequest (new ActivityRequest (limit , offset , Arrays .asList ("item:" , "note:added" ), id , true , true )))
394
+ /*.header("content-type", "application/x-www-form-urlencoded")
395
+ .queryString("limit", limit)
396
+ .queryString("offset", offset)
397
+ .queryString("object_event_types", "[\"item:\", \"note:added\"]")
398
+ .queryString("parent_item_id", id)
399
+ .queryString("include_parent_object", true)
400
+ .queryString("annotate_notes", true)*/
401
+ .asString ();
402
+ if (response .getStatus () != HTTP_OK ) {
403
+ System .out .println (response .getBody ());
404
+ throw new Exception ("HTTP STATUS " + response .getStatus ());
405
+ }
406
+ System .out .println (response .getBody ());
407
+ ActivityResponse activityResponse = JsonAdapters .extractActivityResponse (response .getBody ());
408
+ count = activityResponse .count ;
409
+
410
+ activityResponse .events .forEach (System .out ::println );
411
+
412
+ offset += limit ;
413
+ } while (offset < count );
414
+
415
+ return null ;
392
416
} catch (Exception e ) {
393
417
e .printStackTrace ();
394
418
return null ;
395
419
}
396
420
}
397
421
398
422
public List <Activity > getActivityForTask (long id , ActivityType ... types ) {
399
-
423
+ return null ;
400
424
}
401
425
}
0 commit comments