private ProcoreFolder _GetFolderInfo(ProcoreProject project, int?folder_id = null) { RestRequest req; if (folder_id == null) { req = new RestRequest("https://app.procore.com/vapid/folders"); req.AddParameter("show_latest_file_version_only", true); req.AddParameter("view", "web_normal"); req.AddParameter("project_id", project.id); } else { req = new RestRequest($"https://app.procore.com/vapid/folders/{folder_id}"); req.AddParameter("show_latest_file_version_only", true); req.AddParameter("view", "web_normal"); req.AddParameter("project_id", project.id); } var res = client.Execute(req); if (!res.IsSuccessful) { throw new Exception(res.StatusCode.ToString()); } var body = res.Content; var folder = JsonConvert.DeserializeObject <ProcoreFolder>(body); folder.Project = project; folder.Contents.ForEach(x => x.Project = project); return(folder); }
private ProcoreFolder GetFolderTree(ProcoreProject project, int?root_folder_id = null) { Console.WriteLine(root_folder_id); var tree = this._GetFolderInfo(project, root_folder_id); for (int i = 0; i < tree.folders.Length; i++) { if (tree.folders[i].has_children) { tree.folders[i] = GetFolderTree(project, tree.folders[i].id); } } tree.populated = true; return(tree); }