@@ -49,11 +49,6 @@ public string GetCalendars()
4949 //This uses calendar list instead of calendar. Read for the difference https://developers.google.com/calendar/api/concepts/events-calendars#calendar_and_calendar_list
5050 var result = client . GetAsync ( "https://www.googleapis.com/calendar/v3/users/me/calendarList?access_token=" + _accessToken ) . Result ;
5151
52- if ( ! result . IsSuccessStatusCode )
53- {
54- return "error" ;
55- }
56-
5752 return result . Content . ReadAsStringAsync ( ) . Result ;
5853 }
5954
@@ -65,14 +60,8 @@ public string GetCalendars()
6560 public string GetCalendarById ( string calendarId )
6661 {
6762 var client = HttpClientFactory . CreateClient ( ) ;
68-
6963 var result = client . GetAsync ( $ "https://www.googleapis.com/calendar/v3/users/me/calendarList/{ calendarId } ?access_token=" + _accessToken ) . Result ;
7064
71- if ( ! result . IsSuccessStatusCode )
72- {
73- return "error" ;
74- }
75-
7665 return result . Content . ReadAsStringAsync ( ) . Result ;
7766 }
7867
@@ -84,10 +73,6 @@ public string GetCalendarById(string calendarId)
8473 public string GetCalendarBySummary ( string summary )
8574 {
8675 string calendars = GetCalendars ( ) ;
87- if ( calendars == "error" )
88- {
89- return "error: Can't fetch calendars." ;
90- }
9176 GoogleCalendarListRoot jsonCalendar = JsonSerializer . Deserialize < GoogleCalendarListRoot > ( calendars ) ;
9277
9378 if ( jsonCalendar . items == null )
@@ -129,11 +114,6 @@ public string AddCalendar(GoogleCalendarListModel googleCalendarListModel)
129114
130115 var result = client . PostAsync ( $ "https://www.googleapis.com/calendar/v3/calendars", content ) . Result ;
131116
132- if ( ! result . IsSuccessStatusCode )
133- {
134- return "error" ;
135- }
136-
137117 return result . Content . ReadAsStringAsync ( ) . Result ;
138118 }
139119
@@ -154,11 +134,6 @@ public string UpdateCalendar(string calendarId, GoogleCalendarListModel googleCa
154134
155135 var result = client . PutAsync ( $ "https://www.googleapis.com/calendar/v3/calendars/{ calendarId } ", content ) . Result ;
156136
157- if ( ! result . IsSuccessStatusCode )
158- {
159- return "error" ;
160- }
161-
162137 return result . Content . ReadAsStringAsync ( ) . Result ;
163138 }
164139
@@ -175,11 +150,6 @@ public string DeleteCalendar(string calendarId)
175150
176151 var result = client . DeleteAsync ( $ "https://www.googleapis.com/calendar/v3/calendars/{ calendarId } ") . Result ;
177152
178- if ( ! result . IsSuccessStatusCode )
179- {
180- return "error" ;
181- }
182-
183153 return result . Content . ReadAsStringAsync ( ) . Result ;
184154 }
185155
@@ -197,11 +167,6 @@ public string ClearCalendar(string calendarId)
197167
198168 var result = client . PostAsync ( $ "https://www.googleapis.com/calendar/v3/calendars/{ calendarId } /clear", content ) . Result ;
199169
200- if ( ! result . IsSuccessStatusCode )
201- {
202- return "error" ;
203- }
204-
205170 return result . Content . ReadAsStringAsync ( ) . Result ;
206171 }
207172
@@ -222,11 +187,6 @@ public string GetEvents(DateTime timeMin, DateTime timeMax, string calendarId)
222187 var client = HttpClientFactory . CreateClient ( ) ;
223188 var result = client . GetAsync ( $ "https://www.googleapis.com/calendar/v3/calendars/{ calendarId } /events?access_token={ _accessToken } &maxResults=2500") . Result ;
224189
225- if ( ! result . IsSuccessStatusCode )
226- {
227- return "error" ;
228- }
229-
230190 return result . Content . ReadAsStringAsync ( ) . Result ;
231191 }
232192
@@ -241,11 +201,6 @@ public string GetEventById(string eventId, string calendarId)
241201 var client = HttpClientFactory . CreateClient ( ) ;
242202 var result = client . GetAsync ( $ "https://www.googleapis.com/calendar/v3/calendars/{ calendarId } /events/{ eventId } ?access_token=" + _accessToken ) . Result ;
243203
244- if ( ! result . IsSuccessStatusCode )
245- {
246- return "error" ;
247- }
248-
249204 return result . Content . ReadAsStringAsync ( ) . Result ;
250205 }
251206
@@ -264,10 +219,6 @@ public string AddEvent(GoogleCalendarEventModel calendarEvent, string calendarId
264219 client . DefaultRequestHeaders . Authorization = new AuthenticationHeaderValue ( "Bearer" , _accessToken ) ;
265220 var content = new StringContent ( requestBody , Encoding . UTF8 , "application/json" ) ;
266221 var result = client . PostAsync ( $ "https://www.googleapis.com/calendar/v3/calendars/{ calendarId } /events", content ) . Result ;
267- if ( ! result . IsSuccessStatusCode )
268- {
269- return "error" ;
270- }
271222
272223 return result . Content . ReadAsStringAsync ( ) . Result ;
273224 }
@@ -300,10 +251,6 @@ public string UpdateEvent(GoogleCalendarEventModel newCalendarEvent, string even
300251 // result = client.PutAsync($"https://www.googleapis.com/calendar/v3/calendars/{calendarId}/events/{eventId}", content).Result;
301252 //}
302253 result = client . PutAsync ( $ "https://www.googleapis.com/calendar/v3/calendars/{ calendarId } /events/{ eventId } ", content ) . Result ;
303- if ( ! result . IsSuccessStatusCode )
304- {
305- return "error" ;
306- }
307254
308255 return result . Content . ReadAsStringAsync ( ) . Result ;
309256 }
@@ -319,10 +266,6 @@ public string UpdateEvent(GoogleCalendarEventModel newCalendarEvent, string even
319266 public string GetEventBySummary ( string summary , DateTime dateMin , DateTime dateMax , string calendarId )
320267 {
321268 string events = GetEvents ( dateMin , dateMax , calendarId ) ;
322- if ( events == "error" )
323- {
324- return "error: Can't fetch calendars." ;
325- }
326269 GoogleCalendarEventRoot jsonEvent = JsonSerializer . Deserialize < GoogleCalendarEventRoot > ( events ) ;
327270
328271 if ( jsonEvent . items == null )
@@ -551,10 +494,6 @@ public string FindCalendarId(CalendarValueType valueType, object val)
551494 public string FindEventId ( EventValueType valueType , object val , DateTime timeMin , DateTime timeMax , string calendarId )
552495 {
553496 string googleEvents = GetEvents ( timeMin , timeMax , calendarId ) ;
554- if ( googleEvents == "error" )
555- {
556- return "error: Can't fetch calendars." ;
557- }
558497 GoogleCalendarEventRoot googleCalendarEventRoot = JsonSerializer . Deserialize < GoogleCalendarEventRoot > ( googleEvents ) ;
559498
560499 if ( googleCalendarEventRoot . items == null )
0 commit comments