Exemple #1
0
 /// <summary>
 /// https://developers.podio.com/doc/tasks/update-task-10583674
 /// </summary>
 public void UpdateTask(int taskId, CreateUpdateRequest requestData)
 {
     PodioRestHelper.JSONRequest <Task>(Constants.PODIOAPI_BASEURL + "/task/" + taskId,
                                        _client.AuthInfo.AccessToken,
                                        requestData,
                                        PodioRestHelper.RequestMethod.PUT);
 }
Exemple #2
0
        /// <summary>
        /// https://developers.podio.com/doc/tasks/update-task-description-76982
        /// </summary>
        public void UpdateTaskDescription(int taskId, string description)
        {
            var rq = new CreateUpdateRequest();

            rq.Description = description;
            PodioRestHelper.JSONRequest <Task>(Constants.PODIOAPI_BASEURL + "/task/" + taskId + "/description",
                                               _client.AuthInfo.AccessToken,
                                               rq,
                                               PodioRestHelper.RequestMethod.PUT);
        }
Exemple #3
0
        /// <summary>
        /// https://developers.podio.com/doc/tasks/update-task-text-22428
        /// </summary>
        public void UpdateTaskText(int taskId, string text)
        {
            var rq = new CreateUpdateRequest();

            rq.Text = text;
            PodioRestHelper.JSONRequest <Task>(Constants.PODIOAPI_BASEURL + "/task/" + taskId + "/text",
                                               _client.AuthInfo.AccessToken,
                                               rq,
                                               PodioRestHelper.RequestMethod.PUT);
        }
        public IActionResult AddUpdate([FromRoute] int id, [FromBody] CreateUpdateRequest requestBody)
        {
            var incident = _incidentsManager.GetIncident(id);

            if (incident == null)
            {
                return(NotFound(new
                {
                    message = "An incident with this ID does not exist."
                }));
            }

            var update = requestBody.ToIncidentUpdate();

            if (incident.State == IncidentState.Resolved)
            {
                return(BadRequest(new
                {
                    message = "This incident has already been marked as resolved."
                }));
            }

            update.IncidentId = incident.Id;
            update            = _incidentUpdatesManager.CreateIncidentUpdate(update);

            incident.State = update.State;
            incident.MostRecentUpdateId = update.Id;
            if (incident.State == IncidentState.Resolved)
            {
                incident.ResolvedAt = DateTime.UtcNow;

                var service             = _servicesManager.GetService(incident.ServiceId);
                var incidents           = _incidentsManager.GetIncidents(incident.ServiceId);
                var unresolvedIncidents = incidents.Where(x => x.ResolvedAt == null && x.Id != incident.Id);

                if (!unresolvedIncidents.Any())
                {
                    service.Status = ServiceStatus.Normal;
                    _servicesManager.Update(service);
                }
                else
                {
                    var nextStatus = unresolvedIncidents
                                     .OrderByDescending(x => x.CausedStatus)
                                     .First()
                                     .CausedStatus;
                    service.Status = nextStatus;
                    _servicesManager.Update(service);
                }
            }

            _incidentsManager.UpdateIncident(incident);

            return(Ok(_incidentsManager.GetIncident(id)));
        }
        /// <summary>
        /// https://developers.podio.com/doc/items/update-item-22363
        /// </summary>
        public void UpdateItem(Item item)
        {
            var fieldValues = item.Fields.Select(f => f.Values == null ? null : new { external_id = f.ExternalId, values = f.Values }.AsDictionary()).Where(f => f != null);
            var requestData = new CreateUpdateRequest()
            {
                Fields  = fieldValues,
                FileIds = item.FileIds,
                Tags    = item.Tags.Select(tag => tag.Text),
            };

            UpdateItem((int)item.ItemId, requestData);
        }
Exemple #6
0
        /// <summary>
        /// https://developers.podio.com/doc/tasks/update-task-due-on-3442633
        /// </summary>
        public void UpdateTaskDue(int taskId, DateTime date, bool dateOnly = false)
        {
            var rq = new CreateUpdateRequest();

            rq.DueDate = date.ToString("yyyy-MM-dd");
            if (!dateOnly)
            {
                rq.DueTime = date.ToString("HH:mm");
            }
            PodioRestHelper.JSONRequest <Task>(Constants.PODIOAPI_BASEURL + "/task/" + taskId + "/due",
                                               _client.AuthInfo.AccessToken,
                                               rq,
                                               PodioRestHelper.RequestMethod.PUT);
        }
 /// <summary>
 /// https://developers.podio.com/doc/items/add-new-item-22362
 /// </summary>
 public int AddNewItem(int appId, Item item)
 {
     var fieldValues = item.Fields.Select(f => f.Values == null ? null : new { external_id = f.ExternalId, values = f.Values }.AsDictionary()).Where(f => f != null);
     var requestData = new CreateUpdateRequest()
     {
         ExternalId = item.ExternalId,
         Fields = fieldValues,
         FileIds = item.FileIds,
         Tags = item.Tags
     };
     var newItem = AddNewItem(appId, requestData);
     item.ItemId = newItem.ItemId;
     item.Title = newItem.Title;
     return (int)item.ItemId;
 }
        /// <summary>
        /// https://developers.podio.com/doc/items/add-new-item-22362
        /// </summary>
        public int AddNewItem(int appId, Item item)
        {
            var fieldValues = item.Fields.Select(f => f.Values == null ? null : new { external_id = f.ExternalId, values = f.Values }.AsDictionary()).Where(f => f != null);
            var requestData = new CreateUpdateRequest()
            {
                Fields  = fieldValues,
                FileIds = item.FileIds,
                Tags    = item.Tags.Select(tag => tag.Text)
            };
            var newItem = AddNewItem(appId, requestData);

            item.ItemId = newItem.ItemId;
            item.Title  = newItem.Title;
            return((int)item.ItemId);
        }
Exemple #9
0
 /// <summary>
 /// https://developers.podio.com/doc/tasks/create-task-22419
 /// or
 /// https://developers.podio.com/doc/tasks/create-task-with-reference-22420
 /// </summary>
 public Task AddNewTask(CreateUpdateRequest requestData, string ref_type = null, int?ref_id = null, bool silent = false)
 {
     if (!String.IsNullOrEmpty(ref_type) && ref_id.HasValue)
     {
         return(PodioRestHelper.JSONRequest <Task>(Constants.PODIOAPI_BASEURL + "/task/" + ref_type + "/" + ref_id.ToString() + "/",
                                                   _client.AuthInfo.AccessToken,
                                                   requestData,
                                                   PodioRestHelper.RequestMethod.POST).Data);
     }
     else
     {
         return(PodioRestHelper.JSONRequest <Task>(Constants.PODIOAPI_BASEURL + "/task/",
                                                   _client.AuthInfo.AccessToken,
                                                   requestData,
                                                   PodioRestHelper.RequestMethod.POST).Data);
     }
 }
        public async Task <NotificationInfo> Create(CreateUpdateRequest request)
        {
            var content = JObject.FromObject(request).ToString(Formatting.None);

            Console.WriteLine(content);
            var response = await Client.PostAsync(Client.BaseAddress, new StringContent(content, Encoding.UTF8, "application/json"));

            using (var reader = new JsonTextReader(new StreamReader(await response.Content.ReadAsStreamAsync())))
            {
                if (response.StatusCode == HttpStatusCode.Created)
                {
                    return(Serializer.Deserialize <NotificationInfo>(reader));
                }

                var info = Serializer.Deserialize <NotificationExceptionInfo>(reader);
                throw new SkillNotificationException(info);
            }
        }
Exemple #11
0
        /// <summary>
        /// https://developers.podio.com/doc/tasks/update-task-10583674
        /// </summary>
        public void UpdateTask(Task task)
        {
            var requestData = new CreateUpdateRequest()
            {
                Text        = task.Text,
                Description = task.Description,
                DueDate     = ((DateTime)task.DueDate).ToString("yyyy-MM-dd"),
                DueTime     = ((DateTime)task.DueTime).ToString("HH:mm"),
                Responsible = task.Responsible,
                Private     = task.Private,
                RefType     = task.RefType,
                RefId       = task.RefId,
                Labels      = task.Labels,
                FileIds     = task.FileIds
            };

            UpdateTask((int)task.TaskId, requestData);
        }
 /// <summary>
 /// https://developers.podio.com/doc/items/add-new-item-22362
 /// </summary>
 public int CreateSpaceContact(int spaceId, Contact contact)
 {
     var requestData = new CreateUpdateRequest
     {
         Name = contact.Name,
         Address = contact.Address,
         City = contact.City,
         State = contact.State,
         Zip = contact.Zip,
         Country = contact.Country,
         Mail = contact.Mail,
         Phone = contact.Phone,
         Url = contact.Url
     };
     var newContact = CreateSpaceContact(spaceId, requestData);
     contact.ProfileId = newContact.ProfileId;
     return (int)contact.ProfileId;
 }
Exemple #13
0
        /// <summary>
        /// https://developers.podio.com/doc/tasks/create-task-22419
        /// or
        /// https://developers.podio.com/doc/tasks/create-task-with-reference-22420
        /// </summary>
        public int AddNewTask(Task task, bool silent = false)
        {
            var requestData = new CreateUpdateRequest()
            {
                Text        = task.Text,
                Description = task.Description,
                Private     = task.Private,
                DueDate     = ((DateTime)task.DueDate).ToString("yyyy-MM-dd"),
                DueTime     = ((DateTime)task.DueTime).ToString("HH:mm"),
                DueOn       = task.DueOn,
                Responsible = task.Responsible,
                FileIds     = task.FileIds,
                Labels      = task.Labels,
                LabelIds    = task.LabelIds,
                Reminder    = task.Reminder,
                Recurrence  = task.Recurrence,
                ExternalId  = task.ExternalId
            };
            var newTask = AddNewTask(requestData, task.RefType, task.RefId, silent);

            task.TaskId = newTask.TaskId;
            return((int)task.TaskId);
        }
 /// <summary>
 /// https://developers.podio.com/doc/items/update-item-22363
 /// </summary>
 public void UpdateItem(int itemId, CreateUpdateRequest requestData)
 {
     PodioRestHelper.JSONRequest<Item>(Constants.PODIOAPI_BASEURL + "/item/" + itemId, _client.AuthInfo.AccessToken, requestData, PodioRestHelper.RequestMethod.PUT);
 }
 /// <summary>
 /// https://developers.podio.com/doc/items/add-new-item-22362
 /// </summary>
 public Item AddNewItem(int appId, CreateUpdateRequest requestData)
 {
     return PodioRestHelper.JSONRequest<Item>(Constants.PODIOAPI_BASEURL + "/item/app/" + appId + "/", _client.AuthInfo.AccessToken, requestData, PodioRestHelper.RequestMethod.POST).Data;
 }
        /// <summary>
        /// https://developers.podio.com/doc/items/update-item-22363
        /// </summary>
        public void UpdateItem(Item item)
        {
            var fieldValues = item.Fields.Select(f => f.Values == null ? null : new { external_id = f.ExternalId, values = f.Values }.AsDictionary()).Where(f => f != null);
            var requestData = new CreateUpdateRequest()
            {
                ExternalId = item.ExternalId,
                Fields = fieldValues,
                FileIds = item.FileIds,
                Tags = item.Tags.Select(tag => tag.Text),

            };
            UpdateItem((int)item.ItemId, requestData);
        }
 /// <summary>
 /// https://developers.podio.com/doc/tasks/update-task-due-on-3442633
 /// </summary>
 public void UpdateTaskDue(int taskId, DateTime date, bool dateOnly = false)
 {
     var rq = new CreateUpdateRequest();
     rq.DueDate = date.ToString("yyyy-MM-dd");
     if (!dateOnly) rq.DueTime = date.ToString("HH:mm");
     PodioRestHelper.JSONRequest<Task>(Constants.PODIOAPI_BASEURL + "/task/" + taskId + "/due",
                                       _client.AuthInfo.AccessToken,
                                       rq,
                                       PodioRestHelper.RequestMethod.PUT);
 }
 /// <summary>
 /// https://developers.podio.com/doc/items/add-new-item-22362
 /// </summary>
 public Item AddNewItem(int appId, CreateUpdateRequest requestData)
 {
     return PodioRestHelper.JSONRequest<Item>(String.Format("{0}/item/app/{1}/", Constants.PODIOAPI_BASEURL, appId), _client.AuthInfo.AccessToken, requestData, PodioRestHelper.RequestMethod.POST).Data;
 }
 /// <summary>
 /// https://developers.podio.com/doc/tasks/update-task-text-22428
 /// </summary>
 public void UpdateTaskText(int taskId, string text)
 {
     var rq = new CreateUpdateRequest();
     rq.Text = text;
     PodioRestHelper.JSONRequest<Task>(Constants.PODIOAPI_BASEURL + "/task/" + taskId + "/text",
                                       _client.AuthInfo.AccessToken,
                                       rq,
                                       PodioRestHelper.RequestMethod.PUT);
 }
 /// <summary>
 /// https://developers.podio.com/doc/tasks/update-task-description-76982
 /// </summary>
 public void UpdateTaskDescription(int taskId, string description)
 {
     var rq = new CreateUpdateRequest();
     rq.Description = description;
     PodioRestHelper.JSONRequest<Task>(Constants.PODIOAPI_BASEURL + "/task/" + taskId + "/description",
                                       _client.AuthInfo.AccessToken,
                                       rq,
                                       PodioRestHelper.RequestMethod.PUT);
 }
 /// <summary>
 /// https://developers.podio.com/doc/tasks/update-task-10583674
 /// </summary>
 public void UpdateTask(int taskId, CreateUpdateRequest requestData)
 {
     PodioRestHelper.JSONRequest<Task>(Constants.PODIOAPI_BASEURL + "/task/" + taskId,
                                       _client.AuthInfo.AccessToken,
                                       requestData,
                                       PodioRestHelper.RequestMethod.PUT);
 }
 /// <summary>
 /// https://developers.podio.com/doc/tasks/update-task-10583674
 /// </summary>
 public void UpdateTask(Task task)
 {
     var requestData = new CreateUpdateRequest()
     {
         Text = task.Text,
         Description = task.Description,
         DueDate = ((DateTime)task.DueDate).ToString("yyyy-MM-dd"),
         DueTime = ((DateTime)task.DueTime).ToString("HH:mm"),
         Responsible = task.Responsible,
         Private = task.Private,
         RefType = task.RefType,
         RefId = task.RefId,
         Labels = task.Labels,
         FileIds = task.FileIds
     };
     UpdateTask((int)task.TaskId, requestData);
 }
 /// <summary>
 /// https://developers.podio.com/doc/tasks/create-task-22419
 /// or
 /// https://developers.podio.com/doc/tasks/create-task-with-reference-22420
 /// </summary>
 public Task AddNewTask(CreateUpdateRequest requestData, string ref_type = null, int? ref_id = null, bool silent = false)
 {
     if (!String.IsNullOrEmpty(ref_type) && ref_id.HasValue)
     {
         return PodioRestHelper.JSONRequest<Task>(Constants.PODIOAPI_BASEURL + "/task/" + ref_type + "/" + ref_id.ToString() + "/",
                                                  _client.AuthInfo.AccessToken,
                                                  requestData,
                                                  PodioRestHelper.RequestMethod.POST).Data;
     }
     else
     {
         return PodioRestHelper.JSONRequest<Task>(Constants.PODIOAPI_BASEURL + "/task/",
                                                  _client.AuthInfo.AccessToken,
                                                  requestData,
                                                  PodioRestHelper.RequestMethod.POST).Data;
     }
 }
 /// <summary>
 /// https://developers.podio.com/doc/items/update-item-22363
 /// </summary>
 public void UpdateItem(int itemId, CreateUpdateRequest requestData)
 {
     PodioRestHelper.JSONRequest<Item>(String.Format("{0}/item/{1}", Constants.PODIOAPI_BASEURL, itemId), _client.AuthInfo.AccessToken, requestData, PodioRestHelper.RequestMethod.PUT);
 }
 public Task Update(string notificationId, CreateUpdateRequest request)
 {
     return(Client.PutAsync(
                NotificationUri(notificationId),
                new StringContent(JObject.FromObject(request).ToString())));
 }
 /// <summary>
 /// https://developers.podio.com/doc/items/add-new-item-22362
 /// </summary>
 public Item AddNewItem(int appId, CreateUpdateRequest requestData)
 {
     return(PodioRestHelper.JSONRequest <Item>(Constants.PODIOAPI_BASEURL + "/item/app/" + appId + "/", _client.AuthInfo.AccessToken, requestData, PodioRestHelper.RequestMethod.POST).Data);
 }
 /// <summary>
 /// https://developers.podio.com/doc/items/add-new-item-22362
 /// </summary>
 public Contact CreateSpaceContact(int spaceId, CreateUpdateRequest requestData)
 {
     return PodioRestHelper.JSONRequest<Contact>(Constants.PODIOAPI_BASEURL + "/contact/space/" + spaceId + "/", _client.AuthInfo.AccessToken, requestData, PodioRestHelper.RequestMethod.POST).Data;
 }
 /// <summary>
 /// https://developers.podio.com/doc/items/update-item-22363
 /// </summary>
 public void UpdateItem(int itemId, CreateUpdateRequest requestData)
 {
     PodioRestHelper.JSONRequest <Item>(Constants.PODIOAPI_BASEURL + "/item/" + itemId, _client.AuthInfo.AccessToken, requestData, PodioRestHelper.RequestMethod.PUT);
 }
 /// <summary>
 /// https://developers.podio.com/doc/tasks/create-task-22419
 /// or
 /// https://developers.podio.com/doc/tasks/create-task-with-reference-22420
 /// </summary>
 public int AddNewTask(Task task, bool silent = false)
 {
     var requestData = new CreateUpdateRequest()
     {
         Text = task.Text,
         Description = task.Description,
         Private = task.Private,
         DueDate = ((DateTime)task.DueDate).ToString("yyyy-MM-dd"),
         DueTime = ((DateTime)task.DueTime).ToString("HH:mm"),
         DueOn = task.DueOn,
         Responsible = task.Responsible,
         FileIds = task.FileIds,
         Labels = task.Labels,
         LabelIds = task.LabelIds,
         Reminder = task.Reminder,
         Recurrence = task.Recurrence,
         ExternalId = task.ExternalId
     };
     var newTask = AddNewTask(requestData, task.RefType, task.RefId, silent);
     task.TaskId = newTask.TaskId;
     return (int)task.TaskId;
 }