public async Task <TodoistResources> GetAllResourcesAsync(bool mapData = true) { string content = await httpClient.ExecuteRequest(new Uri("https://todoist.com/API/v6/sync"), "SYNC", new Dictionary <string, string> { ["token"] = token, ["seq_no"] = lastSeqNumber.ToString(), ["resource_types"] = @"[""all""]" }); try { var result = jsonSerializer.Deserialize <TodoistResources>(content); if (result.ContainsErrors) { throw TodoistWebException.GenerateFromHttpErrorCode(result.ErrorCode.Value, null); } if (result != null && mapData) { MapData.Map(result); } return(result); } catch (Exception ex) { } return(null); }
public static TodoistWebException GenerateFromHttpErrorCode(int errorCode, Exception originalException) { string message; if (IsKnownHttpErrorCode(errorCode)) { message = ErrorCodeMessages[errorCode]; } else { message = "Unknown error"; } var exception = new TodoistWebException(message, originalException); exception.HttpErrorCode = errorCode; return exception; }
public static TodoistWebException GenerateFromHttpErrorCode(int errorCode, Exception originalException) { string message; if (IsKnownHttpErrorCode(errorCode)) { message = ErrorCodeMessages[errorCode]; } else { message = "Unknown error"; } var exception = new TodoistWebException(message, originalException); exception.HttpErrorCode = errorCode; return(exception); }