static void Main(string[] args) { _api = Common.ZendeskApiManager.ZendeskApi; _xml = new PrtgXmlOutput(); if (args == null || args.Length == 0) { Common.Tools.PringAgentHelp(_api); return; } agentIdList = new List<long>(); foreach (var s in args) { long agentId; if (long.TryParse(args[0], out agentId)) { agentIdList.Add(agentId); } else { Tools.PrintError(); break; } } }
public ActionResult Create(CreateTicketViewModel model) { var zendesk = ConfigurationManager.AppSettings["ZendeskUrl"]; var zendeskUser = ConfigurationManager.AppSettings["ZendeskUser"]; var zendeskPassword = ConfigurationManager.AppSettings["ZendeskPassword"]; //set up the api var api = new ZendeskApi(zendesk, zendeskUser, zendeskPassword); //create the user if they don't already exist var user = api.Users.SearchByEmail(model.RequesterEmail); if (user == null || user.Users.Count < 1) api.Users.CreateUser(new User() { Name = model.RequesterEmail, Email = model.RequesterEmail }); //setup the ticket var ticket = new Ticket() { Subject = model.Subject, Description = model.Description, Priority = model.TicketPriority, Requester = new Requester() { Email = model.RequesterEmail } }; //create the new ticket var res = api.Tickets.CreateTicket(ticket).Ticket; return View("Index", new CreateTicketViewModel() {TicketId = res.Id.ToString(), ZendeskUrl = zendesk}); }
public ActionResult Create(CreateTicketViewModel model) { var zendesk = "https://eswebtech.zendesk.com/"; //set up the api var api = new ZendeskApi(string.Format("{0}api/v2", zendesk), "*****@*****.**", "pa55word"); //create the user if they don't already exist var user = api.Users.SearchByEmail(model.RequesterEmail); if (user == null || user.Users.Count < 1) api.Users.CreateUser(new User() { Name = model.RequesterEmail, Email = model.RequesterEmail }); //setup the ticket var ticket = new Ticket() { Subject = model.Subject, Description = model.Description, Priority = model.TicketPriority, Requester = new Requester() { Email = model.RequesterEmail } }; //create the new ticket var res = api.Tickets.CreateTicket(ticket).Ticket; return View("Index", new CreateTicketViewModel() {TicketId = res.Id.ToString(), ZendeskUrl = zendesk}); }
public ZendeskController(IHelpdeskSettings zendeskSettings) { _zendeskSettings = zendeskSettings; if (!string.IsNullOrEmpty(_zendeskSettings.AccessToken)) { _api = GetZendeskApi(_zendeskSettings.Subdomain, _zendeskSettings.AccessToken); } }
/// <summary> /// Print list of groups /// </summary> public static void PrintGroups(ZendeskApi api) { Console.WriteLine("List of groups:"); foreach (var group in api.Groups.GetGroups().Groups) { Console.WriteLine(group.Id + ": " + group.Name); } }
private static void initialize() { var subdomain = ConfigurationManager.AppSettings["Zendesk_subdomain"]; var username = ConfigurationManager.AppSettings["Username"]; var password = ConfigurationManager.AppSettings["Password"]; apiUrl = "https://" + subdomain + ".zendesk.com/api/v2"; api = new ZendeskApi(apiUrl, username, password); }
private void Button_Click(object sender, RoutedEventArgs e) { //ZendeskApi api = new ZendeskApi(https://surfer123.zendesk.com/api/v2, "*****@*****.**", ""); var apiToken = new ZendeskApi(APIURL.Text, "*****@*****.**", ""); var ticket = apiToken.Tickets.CreateTicket(new Ticket() { Subject = "my printer is on fire", Comment = new Comment() { Body = "HELP" }, Priority = TicketPriorities.Urgent }); }
/// <summary> /// Prints agent ids /// </summary> /// <param name="api"></param> private static void PrintAgentIds(ZendeskApi api) { Console.WriteLine("List of agents"); var users = api.Users.GetAllUsers(); var agents = users.Users.Where(u => u.Role.ToLower().Equals("agent")); foreach (var agent in agents) { Console.WriteLine(agent.Id + ": " + agent.Name); } }
private static void DisplayViews(ZendeskApi api) { Console.WriteLine("Views:"); var views = api.Views.GetAllViews().Views; foreach (var view in views) { Console.Write(view.Id); Console.Write("\t"); Console.Write(view.Title); Console.WriteLine(); } }
static void Main(string[] args) { _api = Common.ZendeskApiManager.ZendeskApi; _xml = new PrtgXmlOutput(); if (args == null || args.Length == 0) { Common.Tools.PrintGroupHelp(_api); return; } long groupId; if (long.TryParse(args[0], out groupId)) { GetResult(groupId); } else { Tools.PrintError(); } }
public ZendeskApiManager(string url, string username, string password) { api = new ZendeskApi(url, username, password); }
private static void UpdateTickets(ZendeskApi api) { Console.WriteLine("Search created tickets"); var responseTickets = api.Tickets.GetAllTickets(); var pageUrl = responseTickets.NextPage; var pageUrlParts = pageUrl.Split('='); pageUrl = pageUrlParts[0] + "=" + (Int32.Parse(pageUrlParts[1]) - 1); while (!String.IsNullOrEmpty(pageUrl)) { Console.WriteLine("Scaning page: {0}", pageUrl); responseTickets = api.Tickets.GetByPageUrl<GroupTicketResponse>(pageUrl); var tickets = responseTickets.Tickets.Where(row => row.Subject.StartsWith(SubjectStart)); foreach (var ticket in tickets) { var comment = new Comment { AuthorId = CurrentUser.Id, Body = String.Format("Updated from: {0:yyyy.MM.dd HH:mm:ss.fffff}",DateTime.Now), }; ticket.Priority = ticket.Priority == TicketPriorities.Urgent ? TicketPriorities.Low : TicketPriorities.Urgent; var response = api.Tickets.UpdateTicket(ticket, comment); var updatedTicket = response.Ticket; Console.WriteLine("Updated: {0}\t{1}\t{2}\t{3}", updatedTicket.Id, updatedTicket.Status, updatedTicket.Recipient, updatedTicket.Subject); } pageUrl = responseTickets.NextPage; } }
/// <summary> /// Print help message /// </summary> public static void PrintGroupHelp(ZendeskApi api) { Console.WriteLine("You have to specify a group name or id as parameter"); PrintGroups(api); }
/// <summary> /// Print help for assemblies requiring agent ids as parameter /// </summary> /// <param name="api"></param> public static void PringAgentHelp(ZendeskApi api) { Console.WriteLine("You have to specify at least one agent id as parameter separated by spaces"); PrintAgentIds(api); }
private static ZendeskApi GetApi() { var useSettings = false; var settings = Settings.Default; // Load setings? { Console.WriteLine("Use settings? Y/N"); if (Console.ReadLine().ToLower() == "y") { useSettings = true; settings.Upgrade(); } } String path, email, password; Func<String, Boolean> isNeedInput = field => !useSettings || String.IsNullOrEmpty(field); // Path { path = settings.Path; if (isNeedInput(path)) { Console.WriteLine("Enter Path"); path = Console.ReadLine(); settings.Path = path; } else { Console.WriteLine("Path: " + path); } } // EMail { email = settings.EMail; if (isNeedInput(email)) { Console.WriteLine("Enter EMail"); email = Console.ReadLine(); settings.EMail = email; } else { Console.WriteLine("Email: " + email); } } // Password { password = settings.Password; if (isNeedInput(password)) { Console.WriteLine("Enter Password"); password = Console.ReadLine(); settings.Password = password; } else { Console.WriteLine("Password: "******"/api/v2", email, password); try { Console.WriteLine("Connecting..."); CurrentUser = api.Users.GetCurrentUser().User; Console.WriteLine("Hello {0}", CurrentUser.Name); //if (useSettings) { // save to C:\Users\<UserName>\AppData\Local\ZendeskPrototype\ settings.Save(); } } catch (Exception exception) { Console.WriteLine(exception.Message); } return api; }
static void Main(string[] args) { _api = Common.ZendeskApiManager.ZendeskApi; _xml = new PrtgXmlOutput(); var today = DateTime.Today; _dayStartDateTimeOffset = (DateTimeOffset)today; if (args == null || args.Length == 0) { Common.Tools.PrintGroupHelp(_api); return; } long groupId; if (long.TryParse(args[0], out groupId)) { GetResult(groupId); } else { GetResult(args[0].ToString()); } }
private static void SendTestTicket(ZendeskApi api) { Console.WriteLine("Create ticket"); var ticket = new Ticket() { Subject = SubjectStart + DateTime.Now.Ticks, //Subject = "Request of order #"+DateTime.Now.Second, //Tags = new List<String>(new[] { "Request_of_order" }), Comment = new Comment() { Body = "HELP ME!!!", }, Priority = TicketPriorities.Urgent, }; api.Tickets.CreateTicket(ticket); Console.WriteLine("Done"); }
public async Task TestCaseForIssue220() { var resp = await api.HelpCenter.Sections.GetSectionsAsync(); foreach (var _section in resp.Sections.Where(x => x.Name == "testing section access" || x.Name == "testing section")) { await api.HelpCenter.Sections.DeleteSectionAsync(_section.Id.Value); } var responsSection = await api.HelpCenter.Sections.CreateSectionAsync(new Section { Name = "testing section access", CategoryId = Settings.Category_ID }); var res = await api.HelpCenter.Articles.CreateArticleAsync(responsSection.Section.Id.Value, new Article { Title = "My Test article", Body = "The body of my article", Locale = "en-us" }); var tagList = new List<string> { "testing" }; responsSection.Section.AccessPolicy = new AccessPolicy { ViewableBy = ViewableBy.signed_in_users, RequiredTags = tagList }; await api.HelpCenter.AccessPolicies.UpdateSectionAccessPolicyAsync(responsSection.Section); var apiForUser2 = new ZendeskApi(Settings.Site, Settings.AgentEmail, Settings.AgentPassword); Section section = (await apiForUser2.HelpCenter.Sections.GetSectionByIdAsync(responsSection.Section.Id.Value)).Section; // user 2 is a member of the testing tag so we should get the section Assert.That(section, Is.Not.Null); responsSection.Section.AccessPolicy = new AccessPolicy { ViewableBy = ViewableBy.signed_in_users, RequiredTags = new List<string> { "monkey" } }; await api.HelpCenter.AccessPolicies.UpdateSectionAccessPolicyAsync(responsSection.Section); Thread.Sleep(10000); Assert.ThrowsAsync<WebException>(async () => { var sec = await apiForUser2.HelpCenter.Sections.GetSectionByIdAsync(responsSection.Section.Id.Value); }); }