/// <summary> /// Creates a new task /// <para>API Reference: https://developers.podio.com/doc/tasks/create-task-22419 </para> /// </summary> /// <param name="task"></param> /// <param name="refType">The valid types of objects are "item", "status", "app", "space" and "conversation".</param> /// <param name="refId">Id of the reference</param> /// <param name="hook">True if hooks should be executed for the change, false otherwise. Default value: true</param> /// <param name="silent"> /// If set to true, the object will not be bumped up in the stream and notifications will not be /// generated. Default value: false /// </param> /// <returns></returns> public async Task <List <Models.Task> > CreateTask(TaskCreateUpdateRequest task, string refType = null, int?refId = null, bool hook = true, bool silent = false) { string url = "/task/"; if (!string.IsNullOrEmpty(refType) && refId != null) { url = string.Format("/task/{0}/{1}/", refType, refId); } url = Utility.PrepareUrlWithOptions(url, new CreateUpdateOptions(silent, hook)); var createdTasks = new List <Models.Task>(); if ((task.Responsible is IEnumerable <int> || task.Responsible is IEnumerable <Ref>) && task.Responsible.Count > 1) { List <Models.Task> response = await _podio.Post <List <Models.Task> >(url, task); createdTasks = response; } else { Models.Task response = await _podio.Post <Models.Task>(url, task); createdTasks.Add(response); } return(createdTasks); }
/// <summary> /// Updates the task with the given requestData. Any requestData not specified will remain unchanged. /// <para>API Reference: https://developers.podio.com/doc/tasks/update-task-10583674 </para> /// </summary> /// <param name="taskId"></param> /// <param name="task"></param> /// <param name="hook">True if hooks should be executed for the change, false otherwise. Default value: true</param> /// <param name="silent"> /// If set to true, the object will not be bumped up in the stream and notifications will not be /// generated. Default value: false /// </param> /// <returns></returns> public async Task <Models.Task> UpdateTask(int taskId, TaskCreateUpdateRequest task, bool hook = true, bool silent = false) { string url = string.Format("/task/{0}", taskId); url = Utility.PrepareUrlWithOptions(url, new CreateUpdateOptions(silent, hook)); return(await _podio.Put <Models.Task>(url, task)); }
/// <summary> /// Creates a new task with no reference to other objects. /// <para>API Reference: https://developers.podio.com/doc/tasks/create-task-22419 </para> /// </summary> /// <param name="text">The text of the task</param> /// <param name="dueDate">The due date and time of the task, if any (in local time)</param> /// <param name="description">The description of the task</param> /// <param name="responsible">user_id of the re</param> /// <param name="isPrivate">True if the task should be private, default true</param> /// <param name="refType">The valid types of objects are "item", "status", "app", "space" and "conversation".</param> /// <param name="refId">Id of the reference</param> /// <param name="hook">True if hooks should be executed for the change, false otherwise. Default value: true</param> /// <param name="silent"> /// If set to true, the object will not be bumped up in the stream and notifications will not be /// generated. Default value: false /// </param> /// <param name="externalId"></param> /// <returns></returns> public async Task <List <Models.Task> > CreateTask(string text, DateTime?dueDate = null, string description = null, int?responsible = null, bool isPrivate = true, string refType = null, int?refId = null, bool hook = true, bool silent = false, string externalId = null) { var task = new TaskCreateUpdateRequest { Text = text, Description = description, DueDate = dueDate, Responsible = responsible, Private = isPrivate, ExternalId = externalId }; return(await CreateTask(task, refType, refId, hook, silent)); }
public async Task FunctionHandler(RoutedPodioEvent e, ILambdaContext context) { //var awsClient = new Amazon.Lambda.AmazonLambdaClient(); //InvokeRequest request = new InvokeRequest { FunctionName = "FunctionHandler" }; //await awsClient.InvokeAsync(request); context.Logger.LogLine("---Recieved Routed Podio Event"); var factory = new AuditedPodioClientFactory(e.solutionId, e.version, e.clientId, e.environmentId); var podio = factory.ForClient(e.clientId, e.environmentId); var saasafrasClient = new SaasafrasClient( Environment.GetEnvironmentVariable("BBC_SERVICE_URL"), Environment.GetEnvironmentVariable("BBC_SERVICE_API_KEY") ); var dictChild = await saasafrasClient.GetDictionary(e.clientId, e.environmentId, e.solutionId, e.version); var dictMaster = await saasafrasClient.GetDictionary("vcadministration", "vcadministration", "vilcap", "0.0"); var ids = new GetIds(dictChild, dictMaster, e.environmentId); //string functionName = "VilcapDateAssignTask"; var taskServ = new TaskService(podio); var itemServ = new ItemService(podio); var fieldIdToSearch = ids.GetFieldId("Task List|Date"); var filterValue = DateTime.Now.AddDays(7).Ticks; var viewServ = new ViewService(podio); context.Logger.LogLine("Got View Service ..."); var views = await viewServ.GetViews(22708289); var view = from v in views where v.Name == "[TaskAutomation]" select v; context.Logger.LogLine($"Got View '[TaskAutomation]' ..."); var op = new FilterOptions { Filters = view.First().Filters }; var filter = await podio.FilterItems(22708289, op); context.Logger.LogLine($"Items in filter:{filter.Items.Count()}"); foreach (var item in filter.Items) { var responsibleMember = item.Field <ContactItemField>(ids.GetFieldId("Task List|Responsible Member")); var title = item.Field <TextItemField>(ids.GetFieldId("Task List|Title")); var date = item.Field <DateItemField>(ids.GetFieldId("Task List|Date")); var description = item.Field <TextItemField>(ids.GetFieldId("Task List|Description")); var t = new TaskCreateUpdateRequest { Description = description.Value, Private = false, RefType = "item", Id = item.ItemId, DueDate = date.Start.GetValueOrDefault(), Text = title.Value }; IEnumerable <int> cIds = new List <int>(); foreach (var contact in responsibleMember.Contacts) { cIds.Append(Convert.ToInt32(contact.UserId)); } t.SetResponsible(cIds); //t.SetResponsible(cIds); var tasks = await taskServ.CreateTask(t); foreach (var task in tasks) { await taskServ.AssignTask(Convert.ToInt32(task.TaskId), task.Responsible.UserId); //neccessary? context.Logger.LogLine($"Assigned Task"); } var updateMe = new Item() { ItemId = item.ItemId }; var dupecheck = updateMe.Field <CategoryItemField>(ids.GetFieldId("Task List|Task Assigned?")); dupecheck.OptionText = "Yes"; await itemServ.UpdateItem(updateMe, hook : false); context.Logger.LogLine($"Updated Item"); } }
public Task <HttpOperationResult> UpdateTaskAsync(string id, TaskCreateUpdateRequest dto) => HttpService.PatchAsync($"{ApiServerConstants.Endpoints.Tasks.Uri}/{id}", dto);
public Task <HttpOperationResult <EntityReference> > CreateTaskAsync(TaskCreateUpdateRequest dto) => HttpService.PostAsync <EntityReference>(ApiServerConstants.Endpoints.Tasks.Uri, dto);
public async System.Threading.Tasks.Task FunctionHandler(RoutedPodioEvent e, ILambdaContext context) { var factory = new AuditedPodioClientFactory(e.solutionId, e.version, e.clientId, e.environmentId); var podio = factory.ForClient(e.clientId, e.environmentId); var check = await podio.GetItem(Convert.ToInt32(e.podioEvent.item_id)); var saasafrasClient = new SaasafrasClient(Environment.GetEnvironmentVariable("BBC_SERVICE_URL"), Environment.GetEnvironmentVariable("BBC_SERVICE_API_KEY")); var dictChild = await saasafrasClient.GetDictionary(e.clientId, e.environmentId, e.solutionId, e.version); var dictMaster = await saasafrasClient.GetDictionary("vcadministration", "vcadministration", "vilcap", "0.0"); string lockValue; var ids = new GetIds(dictChild, dictMaster, e.environmentId); //Make sure to implement by checking to see if Deploy Curriculum has just changed //Deploy Curriculum field var functionName = "VilcapUpdateApplicationStatus"; lockValue = await saasafrasClient.LockFunction(functionName, check.ItemId.ToString()); try { if (string.IsNullOrEmpty(lockValue)) { context.Logger.LogLine($"Failed to acquire lock for {functionName} and id {check.ItemId}"); return; } //when an item is updated im applications: var revision = await podio.GetRevisionDifference ( Convert.ToInt32(check.ItemId), check.CurrentRevision.Revision - 1, check.CurrentRevision.Revision ); var firstRevision = revision.First(); var completionStatus = check.Field <CategoryItemField>(ids.GetFieldId("Applications|Complete This Application")); if (firstRevision.FieldId == completionStatus.FieldId) { if (completionStatus.Options.Any() && completionStatus.Options.First().Text == "Submit") { var fieldIdToSearch = ids.GetFieldId("Admin"); var newOptions = new FilterOptions { Limit = 1 }; context.Logger.LogLine("Checking for duplicates"); var items = await podio.FilterItems(ids.GetFieldId("Admin"), newOptions); var AdminOptionToCheck = await podio.GetItem(items.Items.First().ItemId); //assign tasks: var taskServ = new TaskService(podio); var programAssociates = AdminOptionToCheck.Field <ContactItemField>(ids.GetFieldId("Admin|Programs Associate")); var title = "Review Completed Application for " + $"{check.Field<TextItemField>(ids.GetFieldId("Applications|Company Name")).Value} here: {check.Link}"; var date = DateTime.Now.AddDays(5); var t = new TaskCreateUpdateRequest { Description = title, Text = "Details", Private = false }; var cId = 0; var random = new Random(); var assignedTo = programAssociates.Contacts.ToArray()[random.Next(programAssociates.Contacts.Count())]; context.Logger.LogLine($"Adding Contact: {assignedTo.Mail.First()} with userID: {assignedTo.UserId}"); cId = Convert.ToInt32(assignedTo.UserId); t.Private = true; // foreach (var contact in programAssociates.Contacts) //{ // context.Logger.LogLine($"Adding Contact: {contact.Mail.First()} with userID: {contact.UserId}"); // cId=Convert.ToInt32(contact.UserId); //} t.RefType = "item"; t.Id = check.ItemId; t.SetResponsible(cId); t.DueDate = date; var task = await taskServ.CreateTask(t, silent : false); context.Logger.LogLine($"Created task: {task.First().TaskId}"); await taskServ.AssignTask(int.Parse(task.First().TaskId), cId, true);//neccessary? context.Logger.LogLine($"Assigned task: {task.First().TaskId} to userID: {cId}"); } } } catch (Exception ex) { throw ex; } finally { await saasafrasClient.UnlockFunction(functionName, check.ItemId.ToString(), lockValue); } }