Example #1
0
        /// <summary>
        ///   Returns details of a specific person in a project
        ///   http://developer.teamwork.com/people
        /// </summary>
        /// <param name="pRojectId">Project ID (int)</param>
        /// <param name="pErsonId"></param>
        /// <returns>Person List</returns>
        public async Task <PeopleResponse> GetPeople(int pRojectId, int pErsonId)
        {
            try
            {
                using (var client = new  AuthorizedHttpClient(this.client.ApiKey, this.client.Domain))
                {
                    var data =
                        await
                        client.GetAsync <PeopleResponse>("/projects/" + pRojectId + "/people/" + pErsonId + ".json",
                                                         null);

                    if (data.StatusCode == HttpStatusCode.OK)
                    {
                        return((PeopleResponse)data.ContentObj);
                    }
                }
                return(new PeopleResponse {
                    STATUS = "ERROR", People = null
                });
            }
            catch (Exception ex)
            {
                return(new PeopleResponse {
                    STATUS = "ERROR:" + ex.Message, People = null
                });
            }
        }
Example #2
0
        /// <summary>
        ///   Return time totals for a project or tasklist
        ///   http://developer.teamwork.com/timetracking#time_totals
        /// </summary>
        /// <param name="projectID">Project ID (int)</param>
        /// <param name="userId"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <param name="fromTime"></param>
        /// <param name="toTime"></param>
        /// <returns>Person List</returns>
        public async Task <TimeTotalsResponse> GetTotals_Project(int projectID, int userId = 0,
                                                                 DateTime?fromDate         = null,
                                                                 DateTime?toDate           = null,
                                                                 string fromTime           = "",
                                                                 string toTime             = "")
        {
            try
            {
                using (var client = new AuthorizedHttpClient(_client))
                {
                    var data = await client.GetAsync <TimeTotalsResponse>("/projects/" + projectID + "/time/total.json", null);

                    if (data.StatusCode == HttpStatusCode.OK)
                    {
                        return((TimeTotalsResponse)data.ContentObj);
                    }
                }
                return(new TimeTotalsResponse {
                    STATUS = "ERROR", Projects = null
                });
            }
            catch (Exception ex)
            {
                return(new TimeTotalsResponse {
                    STATUS = "ERROR:" + ex.Message, Projects = null
                });
            }
        }
Example #3
0
        /// <summary>
        ///   Returns a single milestone, returns null if the user can not access the project
        /// </summary>
        /// <param name="milestoneID">the project id</param>
        /// <param name="includeTasks">include people on project</param>
        /// <returns></returns>
        public async Task <MileStoneResponse> GetMilestone(int milestoneID, bool includeTasks)
        {
            using (var client = new AuthorizedHttpClient(_client))
            {
                var data =
                    await
                    client.GetAsync <MileStoneResponse>("/milestones/" + milestoneID + ".json?showTaskLists=" + includeTasks,
                                                        null);

                return((MileStoneResponse)data.ContentObj);
            }
        }
Example #4
0
        /// <summary>
        ///   Returns all Companies within the given Project
        ///   Details: http://developer.teamwork.com/companies
        /// </summary>
        /// <param name="projectid"></param>
        /// <returns></returns>
        public async Task <CompaniesResponse> GetProjectCompanies(int projectid)
        {
            using (var client = new  AuthorizedHttpClient(this.client.ApiKey, this.client.Domain))
            {
                var data = await client.GetAsync <CompaniesResponse>("/projects/" + projectid + "/companies.json", null);

                if (data.StatusCode == HttpStatusCode.OK)
                {
                    return((CompaniesResponse)data.ContentObj);
                }
            }
            return(null);
        }
Example #5
0
        /// <summary>
        /// Delete a Task
        /// </summary>
        /// <param name="taskid"></param>
        /// <returns></returns>
        //public async Task<bool> DeleteTask(int taskid)
        //{
        //  using (var client = new AuthorizedHttpClient(_client))
        //  {
        //    var response = await client.DeleteAsync("/tasks/" + taskid + ".json");
        //  }
        //  return false;
        //}

        /// <summary>
        /// Delete a Task
        /// </summary>
        /// <param name="taskid"></param>
        /// <returns></returns>
        //public async Task<bool>CompleteTask(int taskid)
        //{
        //  using (var client = new AuthorizedHttpClient(_client))
        //  {
        //    var response = await client.PutAsync("/tasks/" + taskid + "/complete.json",null);
        //  }
        //  return false;
        //}

        /// <summary>
        /// Delete a Task
        /// </summary>
        /// <param name="taskid"></param>
        /// <returns></returns>
        //public async Task<bool> UnCompleteTask(int taskid)
        //{
        //  using (var client = new AuthorizedHttpClient(_client))
        //  {
        //    var response = await client.PutAsync("/tasks/" + taskid + "/uncomplete.json", null);
        //  }
        //  return false;
        //}



        /// <summary>
        ///   Returns all tags the user has access to
        /// </summary>
        /// <returns></returns>

        public async Task <List <string> > GetTaskLists(string projectId)
        {
            using (var client = new AuthorizedHttpClient(_client))
            {
                var data = await client.GetAsync <TaskListResponse2>("/projects/" + projectId + "/tasklists.json", null);

                if (data.StatusCode == HttpStatusCode.OK)
                {
                    var response = (TaskListResponse2)data.ContentObj;
                    return(response.TaskLists.Select(t => t.Id).ToList());
                }
            }
            return(null);
        }
Example #6
0
        /// <summary>
        /// Returns the list of latest activities for a given project
        /// </summary>
        /// <param name="maxItems">default 60 max 200</param>
        /// <param name="onlyStarred"></param>
        /// <param name="projectID"></param>
        /// <returns>List of Activities</returns>
        public async Task <ActivityResponse> GetLatestActivities(int maxItems, bool onlyStarred, int projectID)
        {
            using (var client = new AuthorizedHttpClient(_client))
            {
                var data = await client.GetAsync <ActivityResponse>("/projects/" + projectID + "/latestActivity.json", null);

                if (data.StatusCode == HttpStatusCode.OK)
                {
                    return((ActivityResponse)data.ContentObj);
                }
                return(new ActivityResponse()
                {
                    STATUS = data.Content
                });
            }
        }
Example #7
0
        /// <summary>
        /// Returns the list of latest activities across all projects
        /// </summary>
        /// <param name="maxItems">default 60 max 200</param>
        /// <param name="onlyStarred"></param>
        /// <returns>List of Activities</returns>
        public async Task <ActivityResponse> GetLatestActivities(int maxItems, bool onlyStarred)
        {
            using (var client = new AuthorizedHttpClient(_client))
            {
                var starred = onlyStarred == false ? "no" : "yes";
                var data    = await client.GetAsync <ActivityResponse>("latestActivity.json?maxItems=" + maxItems + "&onlyStarred=" + starred, null);

                if (data.StatusCode == HttpStatusCode.OK)
                {
                    return((ActivityResponse)data.ContentObj);
                }
                return(new ActivityResponse()
                {
                    STATUS = data.Content
                });
            }
        }
Example #8
0
        public async Task <PersonResponse> GetPerson(int personID)
        {
            using (var client = new AuthorizedHttpClient(_client))
            {
                var data = await client.GetAsync <PersonResponse>("/people/" + personID + ".json", null);

                if (data.StatusCode == HttpStatusCode.OK)
                {
                    var response = (PersonResponse)data.ContentObj;
                    return(response);
                }

                return(new PersonResponse()
                {
                    Person = null, STATUS = "ERROR"
                });
            }
        }