public async Task CreateSheets(ICollection <string> names) { var urlBuilder = URLBuilder.BatchUpdate(ID); var value = AddSheetRequestBodyAdapter.GetAddSheetRequestBody(names); var responseHandler = new Action <string>(str => { var jObject = JObject.Parse(str); var replies = jObject["replies"]; var repliesArray = replies.Select(t => t); foreach (var addSheet in repliesArray) { var properties = addSheet["addSheet"]["properties"]; var id = properties["sheetId"]; var title = properties["title"]; var googleSheet = new Sheet(id.Value <int>(), title.Value <string>()); Sheets.Add(googleSheet); } Debug.Log(nameof(CreateSheets) + string.Join("\n", names.ToArray())); }); await RequestExecutor.SendRequestAsync(urlBuilder, value, responseHandler); }
public async Task DeleteGoogleSheets(ICollection <int> ids) { var urlBuilder = URLBuilder.BatchUpdate(ID); var value = AddSheetRequestBodyAdapter.GetDeleteSheetRequestBody(ids); var responseHandler = new Action <string>(str => { Debug.Log(nameof(DeleteGoogleSheets)); foreach (var id in ids) { var googleSheet = Sheets.First(item => item.ID == id); Sheets.Remove(googleSheet); } }); await RequestExecutor.SendRequestAsync(urlBuilder, value, responseHandler); }