public void Demonstrate_Functionality() { // Visit https://trello.com/1/appKey/generate to get your application key ITrello trello = new Trello("[your application key]"); // Optional: Have the user browse to this url to authenticate your application var urlForAuthentication = trello.GetAuthorizationUrl("[a name for your application]", Scope.ReadOnly); // The user will receive a token, call Authenticate with it trello.Authorize("[the token the user got]"); // Get a member Member memberTrello = trello.Members.WithId("trello"); // Get the authenticated member Member me = trello.Members.Me(); // Get a board Board theTrelloDevBoard = trello.Boards.WithId("4d5ea62fd76aa1136000000c"); // Get an organization Organization trelloApps = trello.Organizations.WithId("trelloapps"); // Get all members of a board IEnumerable<Member> membersOfTrelloDevBoard = trello.Members.ForBoard(theTrelloDevBoard); // Get all owners of a board IEnumerable<Member> ownersOfTrelloDevBoard = trello.Members.ForBoard(theTrelloDevBoard, MemberFilter.Owners); // Get all members of an organization IEnumerable<Member> membersInTrelloAppsOrg = trello.Members.ForOrganization(trelloApps); // Get all boards of a member IEnumerable<Board> allMyBoards = trello.Boards.ForMember(me); //Get all boards of an organization IEnumerable<Board> allBoardsOfTrelloAppsOrg = trello.Boards.ForOrganization(trelloApps); // Get all closed boards of an organization IEnumerable<Board> closedBoardsOfTrelloAppsOrg = trello.Boards.ForOrganization(trelloApps, BoardFilter.Closed); // Get all lists on a board IEnumerable<List> allListsInTheTrelloDevBoard = trello.Lists.ForBoard(theTrelloDevBoard); // Get all cards on a board IEnumerable<Card> allCardsOnTheTrelloDevBoard = trello.Cards.ForBoard(theTrelloDevBoard); // Get all cards assigned to a member IEnumerable<Card> allCardsAssignedToMe = trello.Cards.ForMember(me); // Get all organizations that a member belongs to IEnumerable<Organization> allMyOrganizations = trello.Organizations.ForMember(me); // Get unread notifications IEnumerable<Notification> notifications = trello.Notifications.ForMe(readFilter: ReadFilter.Unread); // Get a token Token token = trello.Tokens.WithToken("[a token]"); // Create a new board Board aNewBoard = trello.Boards.Add(new NewBoard("A new board")); // Close a board trello.Boards.Close(aNewBoard); // Create a new list List aNewList = trello.Lists.Add(new NewList("A new list", aNewBoard)); // Archive a list trello.Lists.Archive(aNewList); // Create a card Card aNewCard = trello.Cards.Add(new NewCard("A new card", aNewList)); // Label card trello.Cards.AddLabel(aNewCard, Color.Green); // Assign member to card trello.Cards.AddMember(aNewCard, me); // Delete a card trello.Cards.Delete(aNewCard); // Comment on a card trello.Cards.AddComment(aNewCard, "My comment"); // Update entire card (also works for list, board and checklist) aNewCard.Name = "an updated name"; aNewCard.Desc = "an updated description"; trello.Cards.Update(aNewCard); // Create a checklist var aNewChecklist = trello.Checklists.Add("My checklist", aNewBoard); // Add the checklist to a card trello.Cards.AddChecklist(aNewCard, aNewChecklist); // Add check items trello.Checklists.AddCheckItem(aNewChecklist, "My check item"); // Do things asynchronously! Same API as the sync one, except it returns Task. Task<IEnumerable<Card>> cardsTask = trello.Async.Cards.ForMe(); cardsTask.Wait(); }
public IList <ITask> GetAllTasks() { _trello.Authorize(UserToken); var tasks = new List <ITask>(); var board = _trello.Boards.WithId(BoardID); var cards = _trello.Cards.ForBoard(board); foreach (var card in cards) { tasks.Add(GetTasksFromCard(card)); } return(tasks); }
/// <summary> Initializes static members of the TrelloMicroService.TrelloMS class. </summary> static TrelloMS() { trello = new Trello(TrelloIds.AppKey); var url = trello.GetAuthorizationUrl("https://trello.com/b/j4CnV8Vq/work", Scope.ReadWrite); trello.Authorize(TrelloIds.UserToken); }
/// <summary> /// 認証ボタンが押された時に呼び出されます /// </summary> private void authButton_Click(object sender, EventArgs e) { m_trello = new Trello(m_keyTextBox.Text); m_trello.Authorize(m_tokenTextBox.Text); OnAuthorize(); }
public void InvalidToken_ShouldThrowUnauthorizedException() { var trello = new Trello(ConfigurationManager.AppSettings["ApplicationKey"]); trello.Authorize("invalid token"); Assert.That(() => trello.Members.Me(), Throws.TypeOf <TrelloUnauthorizedException>()); }
private string authoriseTrello(TrelloAuthorisationRequest getAuthFromUser) { var url = trello.GetAuthorizationUrl("Work Horse", Scope.ReadWrite); var authFromUser = getAuthFromUser(url); trello.Authorize(authFromUser); return(authFromUser); }
public void Setup() { _trelloReadOnly = new Trello(ConfigurationManager.AppSettings["ApplicationKey"]); _trelloReadOnly.Authorize(ConfigurationManager.AppSettings["MemberReadToken"]); _trelloReadWrite = new Trello(ConfigurationManager.AppSettings["ApplicationKey"]); _trelloReadWrite.Authorize(ConfigurationManager.AppSettings["MemberWriteToken"]); }
public IEnumerable <TrelloNet.Board> GetAll() { ITrello trello = new Trello("84ffe047543614a43b06bb341dc3e25f"); trello.Authorize("81fd4d07eb1a4317a05e4cdfaa6a5e1642ed8ac726bf22a8c21194e805952064"); var me = trello.Members.Me(); Console.WriteLine(me.FullName); var allMyBoards = trello.Boards.ForMember(me); return(allMyBoards); //return _repository.AllItems; }
private void button2_Click(object sender, EventArgs e) { var trello = new Trello(AppKey); trello.Authorize(UserToken); var trelloBoard = trello.Boards.ForMe().FirstOrDefault(b => b.Name == "Gladiators RoadMap"); var trelloCards = trello.Cards.ForBoard(trelloBoard); foreach (var trelloCard in trelloCards) { trello.Cards.Delete(trelloCard); } MessageBox.Show(@"RoadMap cleaned."); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Executes the start action. </summary> /// /// <param name="host"> The host. This may be null. </param> /// /// <returns> True if it succeeds, false if it fails. </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// public new bool OnStart([CanBeNull] HostControl host) { base.Start(host); Subscribe(); trello = new Trello("16548e3857c79f75e31bb40002a0595b"); var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWrite); trello.Authorize("6a5a70e52074548a989ce1ac8eb48bb1dd60f7ac80645caf5fa0b1814727c955"); var expectedBoard = CreateBoard("Microservice Ecosystem", "Hands on Microservices with C#"); var expectedList = CreateList("Drafts"); for (int x = 0; x < 10; x++) { CreateCard("Chapter " + (x + 1).ToString(), RandomString(25), false, x % 2 == 0 ? SystemClock.Instance.GetCurrentInstant().ToDateTimeUtc().ToLocalTime().AddDays(12) : DateTime.MinValue); } CreateList("Proofs"); for (int x = 0; x < 10; x++) { CreateCard("Chapter " + (x + 1).ToString(), RandomString(25), false, x % 2 == 0 ? SystemClock.Instance.GetCurrentInstant().ToDateTimeUtc().ToLocalTime().AddDays(24) : DateTime.MinValue); } CreateList("Final Copies"); for (int x = 0; x < 10; x++) { CreateCard("Chapter " + (x + 1).ToString(), RandomString(25), false, x % 2 == 0 ? SystemClock.Instance.GetCurrentInstant().ToDateTimeUtc().ToLocalTime().AddDays(36) : DateTime.MinValue); } return(true); }
/// <summary> /// フォームが読み込まれた時に呼び出されます /// </summary> private void MainForm_Load(object sender, EventArgs e) { var key = m_keyTextBox.Text; if (string.IsNullOrWhiteSpace(key)) { return; } var token = m_tokenTextBox.Text; if (string.IsNullOrWhiteSpace(token)) { return; } m_trello = new Trello(key); m_trello.Authorize(token); OnAuthorize(); }
static void Main(string[] args) { string key = null; string token = null; var options = new NDesk.Options.OptionSet { { "key=", k => key = k }, { "token=", t => token = t } }; options.Parse(args); if (string.IsNullOrWhiteSpace(key)) { Usage(); Environment.Exit(1); } var trello = new Trello(key); if (string.IsNullOrWhiteSpace(token)) { var url = trello.GetAuthorizationUrl("TrelloExample", Scope.ReadOnly); Console.WriteLine("No token provided for this app. Get one via this url:"); Console.WriteLine(url); Usage(); Environment.Exit(2); } trello.Authorize(token); foreach (var board in trello.Boards.ForMe()) { Console.WriteLine("Board name: {0}", board.Name); foreach (var card in trello.Cards.ForBoard(board)) { Console.WriteLine("\tCard: {0}", card.Name); } } }
private void TryToAuthorizeTrello() { if (string.IsNullOrWhiteSpace(Settings.Default.Token)) { return; } Trello.Authorize(Settings.Default.Token); Trello.Async.Members.Me().ContinueWith(t => { if (t.Exception == null) { MessageBus.Publish(new TrelloWasAuthorizedEvent(t.Result)); } else { Trello.Deauthorize(); Settings.Default.Token = ""; Settings.Default.Save(); } }); }
public Trello Authenticate() { if (string.IsNullOrEmpty(Key)) { AddNotification(nameof(Key), "Chave para acesso não informada"); return(new Trello("")); } if (string.IsNullOrEmpty(Token)) { AddNotification(nameof(Token), "Token para acesso não informada"); return(new Trello("")); } Trello trello = new Trello(Key); // The user will receive a token, call Authenticate with it (https://trello.com/app-key and click in Token) trello.Authorize(Token); ValidAuthorization(trello); return(trello); }
static void Main(string[] args) { ITrello trello = new Trello(Configuration.DeveloperKey, true); var url = trello.GetAuthorizationUrl("MyApp", Scope.ReadWrite); //trello. //httpWebRequest.Proxy.Credentials = CredentialCache.DefaultCredentials; //var cc = CredentialCache.DefaultCredentials; trello.Authorize(Configuration.UserToken); // Get the authenticated member Member me = trello.Members.Me(); //Console.WriteLine(me.FullName); var myBoards = trello.Boards.ForMember(me); var myBoard = myBoards.Where(b => b.Name == "WorkBoard").FirstOrDefault(); var list = trello.Lists.ForBoard(myBoard).FirstOrDefault(); trello.Cards.Add("Новый картен", list); /*var board = trello.Boards.WithId("5a5c32dcac1b363264c4e25a"); * var lists = trello.Lists.ForBoard(board); //Where(l=>l.Name == "Неделя 29.01 - 02.02").FirstOrDefault() * * foreach (var list in lists) * { * var membersTotalPlan = new Dictionary<string, double>(); // MemberId * * Console.WriteLine(list.Name + ":"); * * var cards = trello.Cards.ForList(list); * * if (cards.Count() == 0) * { * Console.WriteLine("Нихт картен"); * } * * foreach (var card in cards) * { * //Console.WriteLine(card.Name); * int memCount = card.IdMembers.Count; * * var pd = trello.Cards.CardPluginData(card.Id); * int cardPoints = 0; * if (pd.Count > 0) * { * cardPoints = pd.Where(p => p.IdPlugin == "59d4ef8cfea15a55b0086614").FirstOrDefault().ParsedValue.Points; * } * * foreach (string memId in card.IdMembers) * { * if (membersTotalPlan.Keys.Contains(memId)) * { * membersTotalPlan[memId] += (Convert.ToDouble(cardPoints) / memCount); * } * else * { * membersTotalPlan.Add(memId, Convert.ToDouble(cardPoints) / memCount); * } * * //var cardMember = trello.Members.WithId(memId); * //Console.Write(cardMember.FullName + " "); * //var tc = trello.Cards.WithId(card.Id); // 5a6aeba0a2cd0bebfce3d617 * } * * * //Console.WriteLine(card.); * } * * foreach (string memId in membersTotalPlan.Keys) * { * var cardMember = trello.Members.WithId(memId); * Console.WriteLine(string.Format("{0}: {1}", cardMember.FullName, membersTotalPlan[memId])); * } * Console.WriteLine(); * }*/ /* * var lists = trello.Lists.ForBoard(myBoard).Where(l=>l.Name != "TO DO"); * * foreach (var list in lists) * { * Console.WriteLine(list.Name); * var cards = trello.Cards.ForList(list); * foreach (var card in cards) * { * Console.WriteLine(card.Name); * //Console.Write(string.Join(", ", card.IdMembers)); * //Console.WriteLine(": "); * foreach (var memId in card.IdMembers) * { * var cardMember = trello.Members.WithId(memId); * Console.Write(cardMember.FullName + " "); * } * * //Console.WriteLine(card.); * } * * * Console.WriteLine(); * } */ //Console.WriteLine(me.FullName); // Get a board //Board theTrelloDevBoard = trello.Boards.WithId("4d5ea62fd76aa1136000000c"); //Console.WriteLine(theTrelloDevBoard.Name); Console.ReadKey(); /*var myBoard = trello.Boards.Add("My Board"); * * var todoList = trello.Lists.Add("To Do", myBoard); * trello.Lists.Add("Doing", myBoard); * trello.Lists.Add("Done", myBoard); * * trello.Cards.Add("My card", todoList); * * foreach (var list in trello.Lists.ForBoard(myBoard)) * Console.WriteLine(list.Name);*/ }
public void Explore() { ITrello trello = new Trello("[your application key]"); var url = trello.GetAuthorizationUrl("Name of your app", Scope.ReadWrite); trello.Authorize("[the token the user got]"); var myBoard = trello.Boards.Add("My Board"); var todoList = trello.Lists.Add("To Do", myBoard); trello.Lists.Add("Doing", myBoard); trello.Lists.Add("Done", myBoard); trello.Cards.Add("My card", todoList); foreach(var list in trello.Lists.ForBoard(myBoard)) Console.WriteLine(list.Name); }
public TrelloManager(string userToken) { _trello.Authorize(userToken); }
private void button1_Click(object sender, EventArgs e) { string YOUR_GIT_INSTALLED_DIRECTORY = @"C:\Program Files\Git"; string GIT_COMMIT = "git commit -m \"C# prgram\""; string GIT_ADD = "git add ."; string GIT_PUSH = "git push https://github.com/krzysiutek/WalutyJS.git master"; string YOUR_GIT_REPOSITORY_PATH = @"C:\Users\Krzysiek\Documents\Visual Studio 2015\Projects\WalutyJS"; Trello trello = new Trello("8a28c73842ea470f6b5864870580ac08"); trello.Authorize("3d383cd9870dfbc7199e774999eea3b03bc396530dccc50fb0bfb988bc403cf4"); // Get the authenticated member Member me = trello.Members.Me(); Console.WriteLine(me.FullName); var url = trello.GetAuthorizationUrl("WindowsFormApplication1", Scope.ReadWrite); Console.WriteLine(url); theTrelloDevBoard = trello.Boards.WithId("573b2e5609201b4364783c69"); tmr = new Timer(); tmr.Interval = 3000; tmr.Tick += timerHandler; // We'll write it in a bit tmr.Start(); //Console.WriteLine(theTrelloDevBoard.Name); //var myBoard = trello.Boards.Add("My Board"); //var todoList = trello.Lists.Add("To Do", myBoard); //trello.Lists.Add("Doing", myBoard); //trello.Lists.Add("Done", myBoard); //trello.Cards.Add("My card", todoList); //foreach (var list in trello.Lists.ForBoard(myBoard)) // Console.WriteLine(list.Name); ////////ProcessStartInfo gitInfo = new ProcessStartInfo(); ////////gitInfo.CreateNoWindow = false; ////////gitInfo.RedirectStandardError = true; ////////gitInfo.RedirectStandardOutput = true; ////////gitInfo.FileName = @"C:\Program Files\Git\git-bash.exe"; ////////Process gitProcess = new Process(); ////////gitInfo.UseShellExecute = false; ////////gitInfo.WorkingDirectory = YOUR_GIT_REPOSITORY_PATH; ////////gitProcess.StartInfo = gitInfo; ////////gitProcess.StartInfo.Arguments = "git status"; // such as "fetch orign" ////////gitProcess.Start(); ////////string stderr_str = gitProcess.StandardError.ReadToEnd(); // pick up STDERR ////////string stdout_str = gitProcess.StandardOutput.ReadToEnd(); // pick up STDOUT ////////Debug.WriteLine("err "+stderr_str + " \n out " + stdout_str); //gitProcess.WaitForExit(); //gitProcess.Close(); ////Process process = new Process(); ////ProcessStartInfo processStartInfo = new ProcessStartInfo(); ////processStartInfo.WindowStyle = ProcessWindowStyle.Hidden; ////processStartInfo.FileName = @"C:\Program Files\Git\bin\bash.exe"; ////processStartInfo.WorkingDirectory = @"C:\Users\Krzysiek\Documents\Visual Studio 2015\Projects\WalutyJS"; ////processStartInfo.Arguments = "git status"; ////processStartInfo.RedirectStandardOutput = true; ////processStartInfo.RedirectStandardError = true; ////processStartInfo.UseShellExecute = false; ////process.StartInfo = processStartInfo; ////process.Start(); ////String error = process.StandardError.ReadToEnd(); ////String output = process.StandardOutput.ReadToEnd(); ////Debug.WriteLine(error + " " + output); //ViewBag.Error = error; //ViewBag.Ouput = output; //ProcessStartInfo gitInfo = new ProcessStartInfo(); //gitInfo.CreateNoWindow = true; //gitInfo.RedirectStandardError = true; //gitInfo.RedirectStandardOutput = true; //gitInfo.FileName = @"C:\Program Files\Git\bin\git.exe"; //Process gitProcess = new Process(); //gitInfo.Arguments = GIT_ADD; // such as "fetch orign" //gitInfo.WorkingDirectory = YOUR_GIT_REPOSITORY_PATH; ////gitInfo.Arguments = GIT_PUSH; //gitInfo.UseShellExecute = false; //gitProcess.StartInfo = gitInfo; //gitProcess.Start(); //string stderr_str = gitProcess.StandardError.ReadToEnd(); // pick up STDERR //string stdout_str = gitProcess.StandardOutput.ReadToEnd(); // pick up STDOUT //gitProcess.WaitForExit(); //gitProcess.Close(); }
public void Explore() { ITrello trello = new Trello("[your application key]"); var url = trello.GetAuthorizationUrl("Name of your app", Scope.ReadWrite); trello.Authorize("[the token the user got]"); var board = trello.Boards.Add("My Board"); var todoList = trello.Lists.Add("To Do", board); trello.Lists.Add("Doing", board); trello.Lists.Add("Done", board); trello.Cards.Add("My card", todoList); }
// ReSharper disable PossibleMultipleEnumeration private void button1_Click(object sender, EventArgs e) { try { var jira = new JiraClient(JiraUrl, User, Password); var jiraIssues = jira.GetIssuesByQuery("USPL", "", Jql); var trello = new Trello(AppKey); trello.Authorize(UserToken); var trelloBoard = trello.Boards.ForMe().FirstOrDefault(b => b.Name == BoardName); var trelloLists = trello.Lists.ForBoard(trelloBoard); var trelloCards = trello.Cards.ForBoard(trelloBoard); var backlogList = trelloLists.FirstOrDefault(b => b.Name == BacklogName); foreach (var jiraIssue in jiraIssues) { var key = jiraIssue.key.ToLowerInvariant(); var cardTrello = trelloCards.FirstOrDefault(c => c.Name.ToLowerInvariant().Contains(key)); if (cardTrello == null) { Console.WriteLine(@"Creating {0}.", jiraIssue.key); var name = string.Format("({0}) {1} - {2}", jiraIssue.fields.issuetype.name, key.ToUpperInvariant(), jiraIssue.fields.summary); var defaultSprint = backlogList; if (!String.IsNullOrEmpty(jiraIssue.fields.status.name)) { name = string.Format("({0}) {1} - {2} [{3}]", jiraIssue.fields.issuetype.name, key.ToUpperInvariant(), jiraIssue.fields.summary, jiraIssue.fields.status.name); } foreach (var sprint in jiraIssue.fields.customfield_10007) { if (GetSprintState(sprint) == "CLOSED") { continue; } var sprintList = trelloLists.FirstOrDefault( l => l.Name.ToLowerInvariant().Equals(GetSprintName(sprint).ToLowerInvariant())); if (sprintList == null) { continue; } defaultSprint = sprintList; } var newCard = trello.Cards.Add(name, defaultSprint); if (checkBox1.Checked) { trello.Cards.AddLabel(newCard, Color.Red); } switch (jiraIssue.fields.issuetype.name.ToLowerInvariant()) { case "technical task": case "task": trello.Cards.AddLabel(newCard, Color.Blue); break; default: trello.Cards.AddLabel(newCard, Color.Sky); break; } switch (jiraIssue.fields.status.name.ToLowerInvariant()) { case "awaiting po acceptance": case "po signed off for production": case "in po acceptance": trello.Cards.AddLabel(newCard, Color.Yellow); trello.Cards.AddLabel(newCard, Color.Green); break; case "ready for development": case "in development": case "in qa": case "awaiting qa": trello.Cards.AddLabel(newCard, Color.Yellow); break; } trello.Cards.AddComment(newCard, "Imported from Jira"); } else { Console.WriteLine(@"Updating {0}.", jiraIssue.key); var updated = false; if (!String.IsNullOrEmpty(jiraIssue.fields.status.name)) { var name = string.Format("({0}) {1} - {2} [{3}]", jiraIssue.fields.issuetype.name, key.ToUpperInvariant(), jiraIssue.fields.summary, jiraIssue.fields.status.name); if (cardTrello.Name != name) { cardTrello.Name = name; updated = true; } } if (jiraIssue.fields.updated != null) { var lastActivity = jiraIssue.fields.updated.Value; if (cardTrello.DateLastActivity != lastActivity) { cardTrello.DateLastActivity = lastActivity; updated = true; } } var originalSprint = cardTrello.IdList; foreach ( var sprintList in jiraIssue.fields.customfield_10007 .Where(sprint => GetSprintState(sprint) != "CLOSED") // ReSharper disable once PossibleMultipleEnumeration .Select(sprint => trelloLists.FirstOrDefault(l => l.Name.ToLowerInvariant().Equals(GetSprintName(sprint).ToLowerInvariant()))) .Where(sprintList => sprintList != null && cardTrello.IdList != sprintList.Id)) { cardTrello.IdList = sprintList.Id; updated = true; } if (updated) { trello.Cards.Update(cardTrello); foreach (var label in cardTrello.Labels) { try { trello.Cards.AddLabel(cardTrello, label.Color); } catch (TrelloException ex) { if (ex.Message.Contains("that label is already on the card")) { continue; } throw; } } if (cardTrello.IdList != originalSprint) { try { if (!cardTrello.LabelColors.Contains(Color.Red)) { trello.Cards.AddLabel(cardTrello, Color.Red); } } catch (TrelloException ex) { if (!ex.Message.Contains("that label is already on the card")) { throw; } } } trello.Cards.AddComment(cardTrello, "Updated from Jira"); } switch (jiraIssue.fields.status.name.ToLowerInvariant()) { case "awaiting po acceptance": case "po signed off for production": case "in po acceptance": if (!cardTrello.LabelColors.Contains(Color.Yellow)) { trello.Cards.AddLabel(cardTrello, Color.Yellow); } if (!cardTrello.LabelColors.Contains(Color.Green)) { trello.Cards.AddLabel(cardTrello, Color.Green); } break; case "ready for development": case "in development": case "in qa": case "awaiting qa": if (!cardTrello.LabelColors.Contains(Color.Yellow)) { trello.Cards.AddLabel(cardTrello, Color.Yellow); } break; } } } var removedTrelloCards = trelloCards.Where(tc => tc.LabelColors.Contains(Color.Sky) && jiraIssues.Count(j => tc.Name.ToLowerInvariant().Contains(j.key.ToLowerInvariant())) == 0); foreach (var removedTrelloCard in removedTrelloCards) { if (removedTrelloCard.Labels.FirstOrDefault(t => t.Color == Color.Red) == null) { trello.Cards.AddLabel(removedTrelloCard, Color.Red); } trello.Cards.AddComment(removedTrelloCard, "Removed from Backlog in Jira"); } MessageBox.Show(@"RoadMap updated."); } catch (Exception ex) { MessageBox.Show(string.Format("Error. Message: {0}.", ex.Message)); } }
public void InvalidToken_ShouldThrowUnauthorizedException() { var trello = new Trello(ConfigurationManager.AppSettings["ApplicationKey"]); trello.Authorize("invalid token"); Assert.That(() => trello.Members.Me(), Throws.TypeOf<TrelloUnauthorizedException>()); }
public void Demonstrate_Functionality() { // Visit https://trello.com/1/appKey/generate to get your application key ITrello trello = new Trello("[your application key]"); // Optional: Have the user browse to this url to authenticate your application var urlForAuthentication = trello.GetAuthorizationUrl("[a name for your application]", Scope.ReadOnly); // The user will receive a token, call Authenticate with it trello.Authorize("[the token the user got]"); // Get a member Member memberTrello = trello.Members.WithId("trello"); // Get the authenticated member Member me = trello.Members.Me(); Console.WriteLine(me.FullName); // Get a board Board theTrelloDevBoard = trello.Boards.WithId("4d5ea62fd76aa1136000000c"); Console.WriteLine(theTrelloDevBoard.Name); // Get an organization Organization trelloApps = trello.Organizations.WithId("trelloapps"); Console.WriteLine(trelloApps.DisplayName); // Get all members of a board IEnumerable <Member> membersOfTrelloDevBoard = trello.Members.ForBoard(theTrelloDevBoard); // Get all owners of a board IEnumerable <Member> ownersOfTrelloDevBoard = trello.Members.ForBoard(theTrelloDevBoard, MemberFilter.Owners); // Get all members of an organization IEnumerable <Member> membersInTrelloAppsOrg = trello.Members.ForOrganization(trelloApps); // Get all boards of a member IEnumerable <Board> allMyBoards = trello.Boards.ForMember(me); //Get all boards of an organization IEnumerable <Board> allBoardsOfTrelloAppsOrg = trello.Boards.ForOrganization(trelloApps); // Get all closed boards of an organization IEnumerable <Board> closedBoardsOfTrelloAppsOrg = trello.Boards.ForOrganization(trelloApps, BoardFilter.Closed); // Get all lists on a board IEnumerable <List> allListsInTheTrelloDevBoard = trello.Lists.ForBoard(theTrelloDevBoard); // Get all cards on a board IEnumerable <Card> allCardsOnTheTrelloDevBoard = trello.Cards.ForBoard(theTrelloDevBoard); // Get all cards assigned to a member IEnumerable <Card> allCardsAssignedToMe = trello.Cards.ForMember(me); // Get all organizations that a member belongs to IEnumerable <Organization> allMyOrganizations = trello.Organizations.ForMember(me); // Get unread notifications IEnumerable <Notification> notifications = trello.Notifications.ForMe(readFilter: ReadFilter.Unread); // Get a token Token token = trello.Tokens.WithToken("[a token]"); // Get all actions since last view foreach (Action action in trello.Actions.ForMe(since: Since.LastView)) { Console.WriteLine(action.Date); } // Create a new board Board aNewBoard = trello.Boards.Add(new NewBoard("A new board")); // Close a board trello.Boards.Close(aNewBoard); // Create a new list List aNewList = trello.Lists.Add(new NewList("A new list", aNewBoard)); // Archive a list trello.Lists.Archive(aNewList); // Create a card Card aNewCard = trello.Cards.Add(new NewCard("A new card", aNewList)); // Label card trello.Cards.AddLabel(aNewCard, Color.Green); // Assign member to card trello.Cards.AddMember(aNewCard, me); // Delete a card trello.Cards.Delete(aNewCard); // Comment on a card trello.Cards.AddComment(aNewCard, "My comment"); // Update entire card (also works for list, board and checklist) aNewCard.Name = "an updated name"; aNewCard.Desc = "an updated description"; trello.Cards.Update(aNewCard); // Create a checklist var aNewChecklist = trello.Checklists.Add("My checklist", aNewBoard); // Add the checklist to a card trello.Cards.AddChecklist(aNewCard, aNewChecklist); // Add check items trello.Checklists.AddCheckItem(aNewChecklist, "My check item"); // Search in Boards, Cards, Members, Organizations and Actions var results = trello.Search("some search query"); Console.WriteLine("Found {0} boards", results.Boards.Count); Console.WriteLine("Found {0} cards", results.Cards.Count); Console.WriteLine("Found {0} cards", results.Members.Count); // etc... // Or search per model individually IEnumerable <Card> cards = trello.Cards.Search("some search query", limit: 10); foreach (var card in cards) { Console.WriteLine(card.Name); } // Do things asynchronously! Same API as the sync one, except it returns Task. Task <IEnumerable <Card> > cardsTask = trello.Async.Cards.ForMe(); cardsTask.Wait(); }
public void Authorise(string token) { _trello.Authorize(token); }
public void WithId_CopyCardAction_ReturnsRightTypeWithValues() { const string actionId = "5284efa689cce63268004224"; var trello = new Trello("4db5f5e3efbc86a81cf5f3633432fc64"); trello.Authorize("bb03a75e3c7aa28fd3eceed4012f818ba094428458588532cf69e795609e6a4d"); var expected = new CopyCardAction { Id = actionId, IdMemberCreator = "5284ee0726a67481680045bf", Date = new DateTime(2013, 11, 14, 15, 43, 34, 477), Data = new CopyCardAction.ActionData { CardSource = new CardName { Id = "5284ee0726a67481680045c9", Name = "Welcome to Trello!", IdShort = 1, ShortLink = "51YEJguq" }, List = new ListName { Id = "5284ee0726a67481680045c5", Name = "Basics" }, Card = new CardName { IdShort = 20, Id = "5284efa689cce63268004223", Name = "Welcome to Trello 2!", ShortLink = "I5YS0snW" }, Board = new BoardName { Id = "5284ee0726a67481680045c0", Name = "Welcome Board", ShortLink = "YZZ1mDR5" }, }, MemberCreator = new Action.ActionMember { FullName = "Trello ApiGuy", Username = "******", Id = "5284ee0726a67481680045bf", AvatarHash = null, Initials = "TA" } }.ToExpectedObject(); var result = trello.Actions.WithId(actionId); var actual = result as CopyCardAction; expected.ShouldEqual(actual); }