private async static Task DisplayTabluarData(int employeeId, BambooHrTableType tableType) { var bambooHrClient = new BambooHrClient(); var data = await bambooHrClient.GetTabularData(employeeId.ToString(), tableType); foreach (var row in data) { foreach (var key in row.Keys) { Console.WriteLine(row[key]); } } }
private async static Task DisplayTabluarData(int employeeId, BambooHrTableType tableType) { var bambooHrClient = new BambooHrClient(); var data = await bambooHrClient.GetTabularData(employeeId.ToString(), tableType); foreach (var row in data) { foreach (var key in row.Keys) { Console.WriteLine(row[key]); } } }
public async Task<List<Dictionary<string, string>>> GetTabularData(string employeeId, BambooHrTableType tableType) { var url = string.Format("/employees/{0}/tables/{1}/", employeeId, tableType.ToString().LowerCaseFirstLetter()); var request = GetNewRestRequest(url, Method.GET, true); IRestResponse<List<Dictionary<string, string>>> response; try { response = await _iRestClient.ExecuteTaskAsync<List<Dictionary<string, string>>>(request); } catch (Exception ex) { throw new Exception("Error executing Bamboo request to " + url, ex); } if (response.ErrorException != null) throw new Exception("Error executing Bamboo request to " + url, response.ErrorException); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { return response.Data; } throw new Exception("Bamboo Response does not contain data."); } throw new Exception($"Bamboo Response threw error code {response.StatusCode} ({response.StatusDescription}) {response.GetBambooHrErrorMessage()} in {nameof(GetTabularData)}"); }