@@ -42,60 +42,34 @@ public List<Project> getAllProjects() throws TodoistException {
4242 return extract (JsonAdapters ::extractProjectList , response );
4343 }
4444
45- public Project getProject (long id ) {
46- try {
47- HttpResponse <String > response = Unirest .get (URL_BASE + "/projects/" + id )
48- .asString ();
49- if (response .getStatus () != HTTP_OK ) {
50- throw new Exception ("HTTP STATUS " + response .getStatus ());
51- }
52- return JsonAdapters .extractProject (response .getBody ());
53- } catch (Exception e ) {
54- e .printStackTrace ();
55- return null ;
56- }
45+ public Project getProject (long id ) throws TodoistException {
46+ HttpResponse <String > response = Unirest .get (URL_BASE + "/projects/" + id )
47+ .asString ();
48+ if (response .getStatus () != HTTP_OK ) throw new TodoistException (response .getStatus ());
49+ return extract (JsonAdapters ::extractProject , response );
5750 }
5851
59- public Project createNewProject (String name ) {
60- try {
61- HttpResponse <String > response = Unirest .post (URL_BASE + "/projects" )
62- .header ("Content-Type" , "application/json" )
63- .body (JsonAdapters .writeProjectRequest (new ProjectRequest (name )))
64- .asString ();
65- if (response .getStatus () != HTTP_OK ) {
66- throw new Exception ("HTTP STATUS " + response .getStatus ());
67- }
68- return JsonAdapters .extractProject (response .getBody ());
69- } catch (Exception e ) {
70- e .printStackTrace ();
71- return null ;
72- }
52+ public Project createNewProject (String name ) throws TodoistException {
53+ HttpResponse <String > response = Unirest .post (URL_BASE + "/projects" )
54+ .header ("Content-Type" , "application/json" )
55+ .body (JsonAdapters .writeProjectRequest (new ProjectRequest (name )))
56+ .asString ();
57+ if (response .getStatus () != HTTP_OK ) throw new TodoistException (response .getStatus ());
58+ return extract (JsonAdapters ::extractProject , response );
7359 }
7460
75- public void updateProject (long id , String name ) {
76- try {
77- HttpResponse <String > response = Unirest .post (URL_BASE + "/projects/" + id )
78- .header ("Content-Type" , "application/json" )
79- .body (JsonAdapters .writeProjectRequest (new ProjectRequest (name )))
80- .asString ();
81- if (response .getStatus () != HTTP_OK_NO_CONTENT ) {
82- throw new Exception ("HTTP STATUS " + response .getStatus ());
83- }
84- } catch (Exception e ) {
85- e .printStackTrace ();
86- }
61+ public void updateProject (long id , String name ) throws TodoistException {
62+ HttpResponse <String > response = Unirest .post (URL_BASE + "/projects/" + id )
63+ .header ("Content-Type" , "application/json" )
64+ .body (JsonAdapters .writeProjectRequest (new ProjectRequest (name )))
65+ .asString ();
66+ if (response .getStatus () != HTTP_OK_NO_CONTENT ) throw new TodoistException (response .getStatus ());
8767 }
8868
89- public void deleteProject (long id ) {
90- try {
91- HttpResponse <String > response = Unirest .delete (URL_BASE + "/projects/" + id )
92- .asString ();
93- if (response .getStatus () != HTTP_OK_NO_CONTENT ) {
94- throw new Exception ("HTTP STATUS " + response .getStatus ());
95- }
96- } catch (Exception e ) {
97- e .printStackTrace ();
98- }
69+ public void deleteProject (long id ) throws TodoistException {
70+ HttpResponse <String > response = Unirest .delete (URL_BASE + "/projects/" + id )
71+ .asString ();
72+ if (response .getStatus () != HTTP_OK_NO_CONTENT ) throw new TodoistException (response .getStatus ());
9973 }
10074
10175 public List <Task > getActiveTasks () {
0 commit comments