static async Task MainAsync(string email) { // https://blogs.perficient.com/2016/04/28/tsl-1-2-and-net-support/ // ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var userEmailToSearchFor = "*****@*****.**"; var userName = "******"; // the user that will be logging in the API aka the call center staff var userPassword = "******"; var companySubDomain = "csharpapi"; // sub-domain for the account with Zendesk var pageSize = 5; var api = new ZendeskApi(companySubDomain, userName, userPassword); var userResponse = api.Search.SearchFor <User>(userEmailToSearchFor); var userId = userResponse.Results[0].Id.Value; var tickets = new List <Ticket>(); var ticketResponse = await api.Tickets.GetTicketsByUserIDAsync(userId, pageSize, sideLoadOptions : Requests.TicketSideLoadOptionsEnum.Users); // default per page is 100 do { tickets.AddRange(ticketResponse.Tickets); if (!string.IsNullOrWhiteSpace(ticketResponse.NextPage)) { ticketResponse = await api.Tickets.GetByPageUrlAsync <GroupTicketResponse>(ticketResponse.NextPage, pageSize); } } while (tickets.Count != ticketResponse.Count); foreach (var ticket in tickets) { System.Console.WriteLine(string.Format("ticket id: {0 }, Assignee Id: {1}, Requester Id: {2}", ticket.Id, ticket.AssigneeId, ticket.RequesterId)); } }
public ICustomActivityResult Execute() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; var api = new ZendeskApi(Domain, Username, ApiToken, ""); var user = new User(); user.Email = Email; user.Name = Name; if (!string.IsNullOrEmpty(Phone)) { user.Phone = Phone; } if (!string.IsNullOrEmpty(Role)) { user.Role = Role; } if (!string.IsNullOrEmpty(Verified)) { user.Verified = Verified == "Yes"; } var res = api.Users.CreateUser(user); var userId = res.User.Id.Value; return(this.GenerateActivityResult(SuccessResult(userId))); }
private static ZendeskApi Connect(string serverUrl, string userName, string password) { Console.WriteLine(String.Format("Attempting to connect to Zendesk with user: '******' at url: {1}", userName, serverUrl)); var api = new ZendeskApi(serverUrl, userName, password); return(api); }
async static Task Main(string[] args) { var userEmailToSearchFor = "*****@*****.**"; var userName = "******"; // the user that will be logging in the API aka the call center staff var userPassword = "******"; var companySubDomain = "csharpapi"; // sub-domain for the account with Zendesk var api = new ZendeskApi(companySubDomain, userName, userPassword); var helper = new ZendeskHelper(api); var tickets = await helper.GetTickets(userEmailToSearchFor); var count = 0; foreach (var ticket in tickets) { Console.WriteLine($"{count}: ticket id: {ticket?.Id}, Assignee Id: {ticket?.AssigneeId}, Requester Id: {ticket?.RequesterId}"); var comments = await helper.GetComments(ticket); foreach (var comment in comments) { Console.WriteLine($"commnet ID: {comment.Id}"); foreach (var attachment in comment.Attachments) { Console.WriteLine($"attechemnt File Name: {attachment.FileName}"); } } count++; } System.Console.ReadKey(); }
private static void UpdateUsers(ZendeskApi api) { var rateTimer = new Timer(new TimerCallback(RateTimerCallback), null, OneMinute, OneMinute); var allUsers = api.Users.GetAllUsers().Users; foreach (var user in allUsers) { var sanitizedNumber = SanitizeNumber(user.Phone); if (user.Phone != sanitizedNumber) { Console.WriteLine(String.Format("Updating {0} {1} to {2}", user.Name, user.Phone, sanitizedNumber)); user.Phone = sanitizedNumber; api.Users.UpdateUser(user); s_apiCount++; if (s_apiCount >= RequestsPerMinute) { Console.Write("Api limit reached, waiting for timer to expire..."); s_apiLimitResetEvent.WaitOne(); Console.WriteLine("Done"); } } } }
static async Task MainAsync(string email) { string userEmailToSreachFor = "*****@*****.**"; string userName = "******"; // the user that will be logging in the API aka the call center staff string userPassword = "******"; string companySubDomain = "csharpapi"; // sub-domain for the account with Zendesk int pageSize = 5; var api = new ZendeskApi(companySubDomain, userName, userPassword); var userResponse = api.Search.SearchFor <User>(userEmailToSreachFor); long userId = userResponse.Results[0].Id.Value; List <Ticket> tickets = new List <Ticket>(); var ticketResponse = await api.Tickets.GetTicketsByUserIDAsync(userId, pageSize, sideLoadOptions : Requests.TicketSideLoadOptionsEnum.Users); // default per page is 100 do { tickets.AddRange(ticketResponse.Tickets); if (!string.IsNullOrWhiteSpace(ticketResponse.NextPage)) { ticketResponse = await api.Tickets.GetByPageUrlAsync <GroupTicketResponse>(ticketResponse.NextPage, pageSize); } } while (tickets.Count != ticketResponse.Count); foreach (var ticket in tickets) { System.Console.WriteLine(string.Format("ticket id: {0 }, Assignee Id: {1}, Requester Id: {2}", ticket.Id, ticket.AssigneeId, ticket.RequesterId)); } }
public List <ZendeskUpdateModel> GetUpdatesForOrder(Guid id) { var updates = new List <ZendeskUpdateModel>(); var api = new ZendeskApi(ZendeskServiceConfiguration.EndpointUrl, ZendeskServiceConfiguration.Username, ZendeskServiceConfiguration.Password); var orders = api.Search.SearchFor(id.ToString()); var firstCase = orders.Results.FirstOrDefault(); if (firstCase != null) { var comments = api.Tickets.GetTicketComments(firstCase.Id); var temporaryUserCache = new Dictionary <long, string>(); updates.AddRange(comments.Comments.Where(x => x.Public).Select(x => new ZendeskUpdateModel() { Date = DateTime.Parse(x.CreatedAt), Text = x.Body, UpdatedBy = GetAuthorName(api, x.AuthorId, temporaryUserCache) })); } return(updates); }
public ZendeskController(IHelpdeskSettings zendeskSettings) { _zendeskSettings = zendeskSettings; if (!string.IsNullOrEmpty(_zendeskSettings.AccessToken)) { _api = GetZendeskApi(_zendeskSettings.Subdomain, _zendeskSettings.AccessToken); } }
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); }
public ICustomActivityResult Execute() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; var api = new ZendeskApi(Domain, Username, ApiToken, ""); var res = api.Tickets.Delete(long.Parse(TicketId)); return(this.GenerateActivityResult(SuccessResult())); }
public static IFeature Create(ICommandParser commandParser, IKeyValueStore persistence, Configuration configuration) { var zendeskApi = new ErrorCatchingZendeskTicketApi( new ZendeskTicketApi(new CachedZendeskApi(new Time(), ReconnectingZendeskApi.CreateAsync( async() => await ZendeskApi.CreateAsync(configuration.Get("redgate-id")), new Time()).Result))); var zendeskTicketTracker = new ZendeskTicketTracker(commandParser, persistence, zendeskApi); var zendeskTicketProcessor = new ZendeskTicketProcessor(zendeskApi); return(new BasicFeature("zdtracker", "track comments added to zendesk tickets", "use `track ZD#12345` to start tracking a zendesk ticket in the current channel", new CompositeMessageProcessor(zendeskTicketProcessor, zendeskTicketTracker))); }
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); }); }
public void CanCreateZendeskApiAndFetchIssue() { var api = new ZendeskTicketApi(ZendeskApi.Create(m_Configuration.Get("redgate-id"))); var ticket = api.FromId("34182").Result; Assert.AreEqual("SQL Packager 8 crash", ticket.Description); var comment = ticket.Comments.ElementAt(1); Assert.NotNull(comment.Author); Assert.NotNull(comment.Avatar); Trace.WriteLine(comment.Author); Trace.WriteLine(comment.Avatar); }
public ICustomActivityResult Execute() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; var api = new ZendeskApi(Domain, Username, ApiToken, ""); var success = api.Users.SetUsersPassword(long.Parse(UserId), NewPassword); var result = success?"Success":"Fail"; return(this.GenerateActivityResult(SuccessResult(result))); }
public void CanCacheZendeskApi() { var cached = new CachedZendeskApi(new Time(), ZendeskApi.Create(m_Configuration.Get("redgate-id"))); TimeSpan uncachedTime, cachedTime; var stopwatch = new Stopwatch(); stopwatch.Start(); var bug = cached.Ticket("34182").Result; uncachedTime = stopwatch.Elapsed; stopwatch.Reset(); bug = cached.Ticket("34182").Result; cachedTime = stopwatch.Elapsed; Assert.Greater(uncachedTime.TotalMilliseconds, 10); Assert.Less(cachedTime.TotalMilliseconds, 10); }
public ICustomActivityResult Execute() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; var api = new ZendeskApi(Domain, Username, ApiToken, ""); var ticket = new Ticket(); ticket.Comment = new Comment(); ticket.Comment.Body = Comment; ticket.Subject = Subject; ticket.Type = Type; ticket.Priority = Priority; var res = api.Tickets.CreateTicket(ticket); var id = res.Ticket.Id; return(this.GenerateActivityResult(SuccessResult(id.Value))); }
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 ICustomActivityResult Execute() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; var api = new ZendeskApi(Domain, Username, ApiToken, ""); var ticket = new Ticket(); ticket.Id = long.Parse(TicketId); Comment comment = null; if (!string.IsNullOrEmpty(Comment)) { comment = new Comment(); comment.Body = Comment; } if (!string.IsNullOrEmpty(Subject)) { ticket.Subject = Subject; } if (!string.IsNullOrEmpty(Type)) { ticket.Type = Type; } if (!string.IsNullOrEmpty(Priority)) { ticket.Priority = Priority; } if (!string.IsNullOrEmpty(GroupId)) { ticket.GroupId = long.Parse(GroupId); } if (!string.IsNullOrEmpty(Status)) { ticket.Status = Status; } var res = api.Tickets.UpdateTicket(ticket, comment); return(this.GenerateActivityResult(SuccessResult())); }
public ICustomActivityResult Execute() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; var api = new ZendeskApi(Domain, Username, ApiToken, ""); var res = api.Tickets.GetTicket(long.Parse(TicketId)); var json = JsonConvert.SerializeObject(res.Ticket); var jObject = JObject.Parse(json); var dt = new DataTable("resultSet"); var row = dt.NewRow(); dt.Rows.Add(row); foreach (var pair in jObject) { dt.Columns.Add(pair.Key); dt.Rows[0][pair.Key] = pair.Value.ToString(); } return(this.GenerateActivityResult(dt)); }
public ICustomActivityResult Execute() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; api = new ZendeskApi(Domain, Username, ApiToken, ""); if (Type == "all") { Type = null; } if (Priority == "all") { Priority = null; } if (Status == "all") { Status = null; } var termType = string.IsNullOrEmpty(Type) ? "" : "ticket_type:" + Type + " "; var termPriority = string.IsNullOrEmpty(Priority) ? "" : "priority:" + Priority + " "; var termStatus = string.IsNullOrEmpty(Status) ? "" : "status:" + Status + " "; var termSortBy = string.IsNullOrEmpty(SortBy) ? "" : "&sort_by=" + SortBy + " "; var termOrderBy = string.IsNullOrEmpty(OrderBy) ? "" : "&order_by=" + OrderBy + " "; Term = (Query + " " + termStatus + termPriority + termType + termSortBy + termOrderBy).Trim(); var pageRes = api.Search.SearchFor <Ticket>(Term); TotalPage = pageRes.TotalPages; var res = api.Search.SearchFor <Ticket>(Term, page: 10); var tickets = GetTickets(); return(this.GenerateActivityResult(ItemsToDatatable(tickets))); }
public ICustomActivityResult Execute() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; var api = new ZendeskApi(Domain, Username, ApiToken, ""); var users = new List <User>(); long totalPage = 1; GroupUserResponse res = null; for (int currentPage = 1; currentPage <= 1000; currentPage++) { if (UserType == "admin") { res = api.Users.GetAllAdmins(100, currentPage); } else if (UserType == "agent") { res = api.Users.GetAllAgents(100, currentPage); } else if (UserType == "enduser") { res = api.Users.GetAllEndUsers(100, currentPage); } else { res = api.Users.GetAllUsers(100, currentPage); } totalPage = res.TotalPages; users.AddRange(res.Users); if (currentPage == totalPage) { break; } } var dt = ItemsToDatatable(users); return(this.GenerateActivityResult(dt)); }
private string GetAuthorName(ZendeskApi api, long?authorId, Dictionary <long, string> temporaryUserCache) { var name = "Unknown"; if (authorId.HasValue) { var isCached = temporaryUserCache.ContainsKey(authorId.Value); if (isCached) { name = temporaryUserCache[authorId.Value]; } else { //get the name of the user from the api, name = api.Users.GetUser(authorId.Value).User.Name; //and cache the results temporaryUserCache.Add(authorId.Value, name); } } return(name); }
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 })); }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var subdomain = Subdomain.Get(context); var email = Email.Get(context); var apitoken = APIToken.Get(context); var endpoint_url = string.Format("https://{0}.zendesk.com/api/v2", subdomain); var user = string.Format("{0}/token", email); this._client = new ZendeskApi(endpoint_url, user, apitoken); this._objectContainer.Add(this._client); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } // Outputs }); }
static async Task MainAsync(string email) { string userEmailToSreachFor = "*****@*****.**"; string userName = "******"; // the user that will be logging in the API aka the call center staff string userPassword = "******"; string companySubDomain = "csharpapi"; // sub-domain for the account with Zendesk int pageSize = 5; var api = new ZendeskApi(companySubDomain, userName, userPassword); var userResponse = api.Search.SearchFor<User>(userEmailToSreachFor); long userId = userResponse.Results[0].Id.Value; List<Ticket> tickets = new List<Ticket>(); var ticketResponse = await api.Tickets.GetTicketsByUserIDAsync(userId, pageSize, sideLoadOptions: Requests.TicketSideLoadOptionsEnum.Users); // default per page is 100 do { tickets.AddRange(ticketResponse.Tickets); if (!string.IsNullOrWhiteSpace(ticketResponse.NextPage)) { ticketResponse = await api.Tickets.GetByPageUrlAsync<GroupTicketResponse>(ticketResponse.NextPage, pageSize); } } while (tickets.Count != ticketResponse.Count); foreach (var ticket in tickets) { System.Console.WriteLine(string.Format("ticket id: {0 }, Assignee Id: {1}, Requester Id: {2}", ticket.Id, ticket.AssigneeId, ticket.RequesterId )); } }
public ZendeskApiManager(string url, string username, string password) { api = new ZendeskApi(url, username, password); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.UnitInfoLayout); TextView textDetails = this.FindViewById <TextView>(Resource.Id.textDetails); TextView textWarranty = this.FindViewById <TextView>(Resource.Id.textWarranty); Spinner ddTypeOfWarranty = this.FindViewById <Spinner>(Resource.Id.ddTypeOfWarranty); TextView textProduct = this.FindViewById <TextView>(Resource.Id.textProduct); Spinner ddTypeOfProduct = this.FindViewById <Spinner>(Resource.Id.ddTypeofProduct); TextView textFault = this.FindViewById <TextView>(Resource.Id.textFault); Spinner ddAreaOfFault = this.FindViewById <Spinner>(Resource.Id.ddAreaOfFault); Button buttonUpload = this.FindViewById <Button>(Resource.Id.buttonUpload); TextView textUploadStatus = this.FindViewById <TextView>(Resource.Id.textUploadStatus); //ids for custom fields warrantyselected.Id = 360019766751; productselected.Id = 360019468991; faultselected.Id = 360019766771; var uploadapi = new ZendeskApi("https://greenworkstools1552039260.zendesk.com/api/v2", LoginActivity.username, LoginActivity.userpass, ""); ddTypeOfWarranty.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(warranty_ItemSelected); var warrantyadapter = ArrayAdapter.CreateFromResource( this, Resource.Array.warranty_array, Android.Resource.Layout.SimpleSpinnerItem); warrantyadapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); ddTypeOfWarranty.Adapter = warrantyadapter; ddTypeOfProduct.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(product_ItemSelected); var productadapter = ArrayAdapter.CreateFromResource( this, Resource.Array.product_array, Android.Resource.Layout.SimpleSpinnerItem); productadapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); ddTypeOfProduct.Adapter = productadapter; ddAreaOfFault.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(fault_ItemSelected); var faultadapter = ArrayAdapter.CreateFromResource( this, Resource.Array.fault_array, Android.Resource.Layout.SimpleSpinnerItem); faultadapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); ddAreaOfFault.Adapter = faultadapter; buttonUpload.Click += async(sender, e) => { customfields.Add(warrantyselected); customfields.Add(productselected); customfields.Add(faultselected); var ticket = new Ticket() { Subject = "this is a test ticket", Priority = TicketPriorities.Normal, TicketFormId = 360000437791, Comment = new Comment() { Body = "This is a test ticket", //set Public to true to receive an email notification to the requester's email Public = true, /*Uploads = new List<string>() { attachment.Token } //Add the attachment token here */ }, Requester = new Requester() { Email = "*****@*****.**" }, CustomFields = customfields }; var res = await uploadapi.Tickets.CreateTicketAsync(ticket); if (res.Ticket.Id != null) { long?zenticketId = res.Ticket.Id; textUploadStatus.Text = "Successfully uploaded ticket #" + zenticketId.ToString(); } else { textUploadStatus.Text = "Something went wrong"; } }; }
public ZendeskRetriever(string zendeskUrl, string zendeskUser, string zendeskToken) { _client = new ZendeskApi(zendeskUrl, zendeskUser, zendeskToken, String.Empty); }
public void ReturnsNullOnError() { var api = new ErrorCatchingZendeskTicketApi(new ZendeskTicketApi(ZendeskApi.Create(m_Configuration.Get("redgate-id")))); Assert.AreEqual(default(ZendeskTicket), api.FromId("not a zd id").Result); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.SetContentView(Resource.Layout.LoginActivityLayout); textUsername = this.FindViewById <EditText>(Resource.Id.textUsername); textPassword = this.FindViewById <EditText>(Resource.Id.textPassword); buttonLogin = this.FindViewById <Android.Widget.Button>(Resource.Id.buttonLogin); textLoginInfo = this.FindViewById <TextView>(Resource.Id.textLoginInfo); textLoginInfosubtext = this.FindViewById <TextView>(Resource.Id.textLoginInfosubtext); this.Title = "User Login"; buttonLogin.Click += async(sender, e) => { var user = string.Empty; var password = string.Empty; this.RunOnUiThread(() => { user = this.textUsername.Text; }); this.RunOnUiThread(() => { password = this.textPassword.Text; }); username = user; userpass = password; //AzureService service = new AzureService(); var api = new ZendeskApi("https://greenworkstools1552039260.zendesk.com/api/v2", user, password, ""); this.textLoginInfo.Text = "Connecting to Zendesk..."; IList <TicketField> allfields = new List <TicketField>(); try { //retrieve ticket fields from Zendesk GroupTicketFieldResponse fields = await api.Tickets.GetTicketFieldsAsync(); foreach (TicketField fielddata in fields.TicketFields) { allfields.Add(fielddata); } if (!String.IsNullOrEmpty(allfields[2].Title)) { this.textLoginInfo.Text = "Succesfully connected and validated user!"; await Task.Delay(1000); StartActivity(typeof(DecoderActivity)); } else { this.textLoginInfo.Text = "Unable to retrieve ticket fields!"; } } catch (WebException ex) { this.textLoginInfo.Text = "Invalid Username or Password"; this.textLoginInfosubtext.Text = ex.Message; await Task.Delay(2000); this.textLoginInfo.Text = "Enter a valid Username and Password"; this.textLoginInfosubtext.Text = ""; //throw new WebException(ex.Message + " " + ex.Response.Headers.ToString(), ex); } /*if (this.textUsername.Text == service.textUsername) * { * if (this.textPassword.Text == service.textPassword) * { * this.textLoginInfo.Text = "User Found!"; * * currentUser.Name = service.textName; * currentUser.Date = DateTime.Now; * * this.textLoginInfo.Text = "Succesfully Logged in!"; * StartActivity(typeof(DecoderActivity)); * } * else * { * this.textLoginInfo.Text = "Invalid Password"; * } * } * else * { * this.textLoginInfo.Text = "Unrecognized Username"; * }*/ }; }