public string AuthorizeURL() { requestToken = RequestToken(); return requestToken.getToken().BaseUrl + "/oauth/authorize?oauth_token=" + requestToken.Token; }
public void Send() { Task.Run( () => { try { var apikey = "hVAAtCM7wCEaJe9DqlR52w"; var apiSecret = "haN4L38nqnyZTTfVyudb7WpR2vSAcOWB3PUEm6XQQ"; var subdomain = "hearthstonetracker"; var client = new Client(subdomain, apikey, apiSecret); object attachments = new object[] { }; if (AttachLog) { var logPath = Path.Combine((string)AppDomain.CurrentDomain.GetData("DataDirectory"), "logs"); var dirInfo = new DirectoryInfo(logPath); var latestLogfiles = dirInfo.GetFiles().Where(x => x.Extension == ".txt").OrderByDescending(x => x.LastWriteTime).Take(3).ToList(); if (latestLogfiles.Count > 0) { using (var ms = new MemoryStream()) { using (var zipfile = new ZipArchive(ms, ZipArchiveMode.Create, true)) { foreach (var latestLogfile in latestLogfiles) { zipfile.CreateEntryFromFile(latestLogfile.FullName, latestLogfile.Name, CompressionLevel.Optimal); } } ms.Position = 0; var bytes = new Byte[ms.Length]; ms.Read(bytes, 0, bytes.Length); attachments = new object[] { new { name = "logfiles.zip", content_type = "application/zip", data = Convert.ToBase64String(bytes) } }; } } } var ticket = new { email = Email, ticket = new { state = "open", subject = Subject, message = Message, user_agent = "HearthstoneTracker App", attachments } }; client.Post("/api/v1/tickets.json", ticket); } catch (Exception ex) { Log.Error(ex); } }); TryClose(); MessageBox.Show("Your support request has been sent.", "Support request sent.", MessageBoxButton.OK); }