Exemplo n.º 1
0
        /// <summary>
        /// Returns tickets with that tag in groups of 15. Use the page index to get the next set.
        /// </summary>
        /// <param name="tagName"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public List <Ticket> GetTicktesForTagByPage(string tagName, int page = 1)
        {
            var request = new ZenRestRequest
            {
                Method   = Method.GET,
                Resource = string.Format("{0}/{1}.xml", Tags, tagName)
            };

            request.AddParameter("page", page.ToString());

            return(Execute <List <Ticket> >(request));
        }
Exemplo n.º 2
0
        public List <Ticket> GetTicketsInViewByPage(int viewId, int page = 1)
        {
            var request = new ZenRestRequest
            {
                Method   = Method.GET,
                Resource = string.Format("rules/{0}.xml", viewId)
            };

            request.AddParameter("page", page.ToString());

            return(Execute <List <Ticket> >(request));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns tickets with that tag in groups of 15. Use the page index to get the next set.
        /// </summary>
        /// <param name="tagName"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public List<Ticket> GetTicktesForTagByPage(string tagName, int page = 1)
        {
            var request = new ZenRestRequest
            {
                Method = Method.GET,
                Resource = string.Format("{0}/{1}.xml", Tags, tagName)
            };

            request.AddParameter("page", page.ToString());

            return Execute<List<Ticket>>(request);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Matches the api method at http://www.zendesk.com/api/users
        /// Ex: QueryUsers("*****@*****.**") returns a list of users with that email, which should only be one.
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List <User> QueryUsers(string query)
        {
            var request = new ZenRestRequest
            {
                Method   = Method.GET,
                Resource = Users,
            };

            request.AddParameter("query", query);

            return(Execute <List <User> >(request));
        }
Exemplo n.º 5
0
        public List <Ticket> GetTicketsForUserByPage(string email, int page = 1)
        {
            var request = new ZenRestRequest
            {
                Method   = Method.GET,
                Resource = Requests + ".xml",
            };

            //Assume the user
            request.AddHeader(XOnBehalfOfEmail, email);
            request.AddParameter("page", page.ToString());

            //Get the open ones
            var ticktes = Execute <List <Ticket> >(request);

            //Now get the closed ones
            request.AddParameter("filter", "solved");
            var closedOrSolved = Execute <List <Ticket> >(request);

            ticktes.AddRange(closedOrSolved);
            return(ticktes);
        }
Exemplo n.º 6
0
        public bool ApplyMacro(int macroId, int ticketId)
        {
            var request = new ZenRestRequest
            {
                Method   = Method.POST,
                Resource = string.Format("{0}/{1}/apply.json", Macros, macroId)
            };

            request.AddParameter("ticket_id", ticketId.ToString());

            var resp = Execute(request);

            return(resp.StatusCode == System.Net.HttpStatusCode.OK);
        }
Exemplo n.º 7
0
        public bool ApplyMacro(int macroId, int ticketId)
        {
            var request = new ZenRestRequest
            {
                Method = Method.POST,
                Resource = string.Format("{0}/{1}/apply.xml", Macros, macroId)
            };

            request.AddParameter("ticket_id", ticketId.ToString());

            var resp = Execute(request);

            return resp.StatusCode == System.Net.HttpStatusCode.OK;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Throws a ZenDeskNotAcceptableInputException if the twitter account doesn't exist or is already assigned to someone else.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="twitterHandle"></param>
        /// <returns></returns>
        public bool AddTwitterHandleToUser(int userId, string twitterHandle)
        {
            //first check to see if the user already has that twitter identity
            var records = GetUserIdentities(userId);
            if (records.Where(x => x.ScreenName == twitterHandle).Count() > 0)
                return true;

            var request = new ZenRestRequest
            {
                Method = Method.POST,
                Resource = string.Format("{0}/{1}/user_identities.xml", Users, userId)
            };

            request.AddParameter("text/xml", string.Format("<twitter>{0}</twitter>", twitterHandle), ParameterType.RequestBody);

            var res = Execute(request);

            return res.StatusCode == System.Net.HttpStatusCode.Created;
        }
Exemplo n.º 9
0
        public bool AddEmailAddressToAUser(int userId, string email)
        {
            //first check to see if the user allready has that email identity
            var emails = GetUserIdentities(userId);
            if (emails.Where(x => x.Value == email).Count() > 0)
                return true;

            var request = new ZenRestRequest
            {
                Method = Method.POST,
                Resource = string.Format("{0}/{1}/user_identities.xml", Users, userId)
            };

            request.AddParameter("text/xml", string.Format("<email>{0}</email>", email), ParameterType.RequestBody);

            var res = Execute(request);

            return res.StatusCode == System.Net.HttpStatusCode.Created;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Throws a ZenDeskNotAcceptableInputException if the twitter account doesn't exist or is already assigned to someone else.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="twitterHandle"></param>
        /// <returns></returns>
        public bool AddTwitterHandleToUser(int userId, string twitterHandle)
        {
            //first check to see if the user already has that twitter identity
            var records = GetUserIdentities(userId);

            if (records.Where(x => x.ScreenName == twitterHandle).Count() > 0)
            {
                return(true);
            }

            var request = new ZenRestRequest
            {
                Method   = Method.POST,
                Resource = string.Format("{0}/{1}/user_identities.xml", Users, userId)
            };

            request.AddParameter("text/xml", string.Format("<twitter>{0}</twitter>", twitterHandle), ParameterType.RequestBody);

            var res = Execute(request);

            return(res.StatusCode == System.Net.HttpStatusCode.Created);
        }
Exemplo n.º 11
0
        public bool AddEmailAddressToAUser(int userId, string email)
        {
            //first check to see if the user allready has that email identity
            var emails = GetUserIdentities(userId);

            if (emails.Where(x => x.Value == email).Count() > 0)
            {
                return(true);
            }

            var request = new ZenRestRequest
            {
                Method   = Method.POST,
                Resource = string.Format("{0}/{1}/user_identities.xml", Users, userId)
            };

            request.AddParameter("text/xml", string.Format("<email>{0}</email>", email), ParameterType.RequestBody);

            var res = Execute(request);

            return(res.StatusCode == System.Net.HttpStatusCode.Created);
        }
Exemplo n.º 12
0
        public List<Ticket> GetTicketsInViewByPage(int viewId, int page = 1)
        {
            var request = new ZenRestRequest
            {
                Method = Method.GET,
                Resource = string.Format("rules/{0}.xml", viewId)
            };

            request.AddParameter("page", page.ToString());

            return Execute<List<Ticket>>(request);
        }
Exemplo n.º 13
0
        public List<Ticket> GetTicketsForUserByPage(string email, int page = 1)
        {
            var request = new ZenRestRequest
            {
                Method = Method.GET,
                Resource = Requests + ".xml",
            };

            //Assume the user
            request.AddHeader(XOnBehalfOfEmail, email);
            request.AddParameter("page", page.ToString());

            //Get the open ones
            var ticktes = Execute<List<Ticket>>(request);

            //Now get the closed ones
            request.AddParameter("filter", "solved");
            var closedOrSolved = Execute<List<Ticket>>(request);

            ticktes.AddRange(closedOrSolved);
            return ticktes;
        }
Exemplo n.º 14
0
        private List<Organization> GetOrganizationssByPage(int page)
        {
            var request = new ZenRestRequest
            {
                Method = Method.GET,
                Resource = string.Format("{0}.xml", _organizations)
            };

            request.AddParameter("page", page.ToString());

            return Execute<List<Organization>>(request);
        }
Exemplo n.º 15
0
        private List<User> GetUsersByPage(int page)
        {
            var request = new ZenRestRequest
            {
                Method = Method.GET,
                Resource = string.Format("{0}.xml", Users)
            };

            request.AddParameter("page", page.ToString());

            return Execute<List<User>>(request);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Matches the api method at http://www.zendesk.com/api/users
        /// Ex: QueryUsers("*****@*****.**") returns a list of users with that email, which should only be one.
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<User> QueryUsers(string query)
        {
            var request = new ZenRestRequest
            {
                Method = Method.GET,
                Resource = Users,
            };

            request.AddParameter("query", query);

            return Execute<List<User>>(request);
        }