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 void GetAuthorizationlUrl_ApplicationNameIsEmpty_Throw() { var trello = new Trello("key"); Assert.That(() => trello.GetAuthorizationUrl("", Scope.ReadOnly), Throws.InstanceOf<ArgumentException>().With.Matches<ArgumentException>(e => e.ParamName == "applicationName")); }
public void GetAuthorizationlUrl_ExpirationOneHour_Contains1hour() { var trello = new Trello("dummy"); var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWrite, Expiration.OneHour); Assert.That(url.ToString(), Is.StringContaining("expiration=1hour")); }
public void GetAuthorizationlUrl_DefaultExpiration_Contains30days() { var trello = new Trello("dummy"); var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWrite); Assert.That(url.ToString(), Is.StringContaining("expiration=30days")); }
public void GetAuthorizationlUrl_Always_ContainsResponseTypeToken() { var trello = new Trello("dummy"); var url = trello.GetAuthorizationUrl("dummy", Scope.ReadOnly); Assert.That(url.ToString(), Is.StringContaining("response_type=token")); }
public void GetAuthorizationlUrl_Always_ContainsKeyPassedInConstructor() { var trello = new Trello("123"); var url = trello.GetAuthorizationUrl("dummy", Scope.ReadOnly); Assert.That(url.ToString(), Is.StringContaining("key=123")); }
public void GetAuthorizationlUrl_Always_ContainsApplicationName() { var trello = new Trello("dummy"); var url = trello.GetAuthorizationUrl("appname", Scope.ReadOnly); Assert.That(url.ToString(), Is.StringContaining("name=appname")); }
public void GetAuthorizationlUrl_ScopeReadWriteAccount_ContainsReadWriteAccount() { var trello = new Trello("dummy"); var url = trello.GetAuthorizationUrl("dummy", Scope.ReadWriteAccount); Assert.That(url.ToString(), Is.StringContaining("scope=read,write,account")); }
public void GetAuthorizationlUrl_ScopeReadonly_ContainsRead() { var trello = new Trello("dummy"); var url = trello.GetAuthorizationUrl("dummy", Scope.ReadOnly); Assert.That(url.ToString(), Is.StringContaining("scope=read")); Assert.That(url.ToString(), Is.Not.StringContaining("write")); }
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 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); }
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);*/ }