IEnumerator InsertEvent() { UnityWebRequest InserEventRequest = calendarAPI.InsertCalendarevent(eventToBeInserted); InserEventRequest.timeout = 90000000; yield return(InserEventRequest.SendWebRequest()); if (InserEventRequest.isNetworkError || InserEventRequest.isHttpError) { if (InserEventRequest.responseCode == 401) { Debug.Log("Refreshed token"); calendarAPI.RefreshAccessToken(this); } } else { eventToBeInserted = null; } }
public IEnumerator GetCalendarEvents() { UnityWebRequest AlleCalendarEventsRequest = calendarAPI.GetCalendarEventsHTTPRequest(); AlleCalendarEventsRequest.chunkedTransfer = false; AlleCalendarEventsRequest.timeout = 100000; yield return(AlleCalendarEventsRequest.SendWebRequest()); if (AlleCalendarEventsRequest.isNetworkError || AlleCalendarEventsRequest.isHttpError) { if (AlleCalendarEventsRequest.responseCode == 401) { Debug.Log("Refreshed token"); calendarAPI.RefreshAccessToken(this); } Debug.Log("An error occured receiving events: " + AlleCalendarEventsRequest.responseCode); } else { GoogleCalendarEventsResponse eventsResponse = JsonUtility.FromJson <GoogleCalendarEventsResponse>(AlleCalendarEventsRequest.downloadHandler.text); eventsUpdater?.Invoke(eventsResponse.items); } }