public static T Execute <T>(TrelloAuthorization auth, Endpoint endpoint, T body) where T : class { var obj = new object(); var request = BuildRequest(auth, endpoint); request.AddBody(body); AddDefaultParameters <T>(request); RestRequestProcessor.AddRequest <T>(request, obj); lock (obj) Monitor.Wait(obj); ValidateResponse(request); var response = request.Response as IRestResponse <T>; return(response?.Data); }
public MemberContext(string id, bool isMe, TrelloAuthorization auth) : base(auth) { _isMe = isMe; Data.Id = id; Actions = new ReadOnlyActionCollection(typeof(Member), () => Data.Id, auth); if (isMe) { Boards = new BoardCollection(typeof(Member), () => Data.Id, auth); BoardBackgrounds = new BoardBackgroundCollection(() => Data.Id, auth); Organizations = new OrganizationCollection(() => Data.Id, auth); StarredBoards = new StarredBoardCollection(() => Data.Id, auth); } else { Boards = new ReadOnlyBoardCollection(typeof(Member), () => Data.Id, auth); BoardBackgrounds = new ReadOnlyBoardBackgroundCollection(() => Data.Id, auth); Organizations = new ReadOnlyOrganizationCollection(() => Data.Id, auth); StarredBoards = new ReadOnlyStarredBoardCollection(() => Data.Id, auth); } Boards.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Boards) }); BoardBackgrounds.Refreshed += (s, e) => OnMerged(new List <string> { nameof(BoardBackgrounds) }); Organizations.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Organizations) }); StarredBoards.Refreshed += (s, e) => OnMerged(new List <string> { nameof(StarredBoards) }); Cards = new ReadOnlyCardCollection(EntityRequestType.Member_Read_Cards, () => Data.Id, auth); Cards.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Cards) }); Notifications = new ReadOnlyNotificationCollection(() => Data.Id, auth); Notifications.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Notifications) }); MemberPreferencesContext = new MemberPreferencesContext(Auth); MemberPreferencesContext.SubmitRequested += ct => HandleSubmitRequested("Preferences", ct); Data.Prefs = MemberPreferencesContext.Data; }
protected SynchronizationContext(TrelloAuthorization auth, bool useTimer) { ManagesSubmissions = useTimer; if (useTimer && TrelloConfiguration.ChangeSubmissionTime.Milliseconds != 0) { _timer = new Timer(async state => await _TimerElapsed(), null, TrelloConfiguration.ChangeSubmissionTime, TrelloConfiguration.ChangeSubmissionTime); } _updateLock = new object(); _expireLock = new object(); _semaphore = new SemaphoreSlim(1, 1); _expires = DateTime.MinValue; RestRequestProcessor.LastCall += _TimerElapsed; Auth = auth ?? TrelloAuthorization.Default; }
public static T GetFromCache <T>(this IJsonCacheable json, TrelloAuthorization auth) where T : class, ICacheable { if (json == null) { return(null); } var cache = TryGetFromCache <T>(json); if (cache == null) { TrelloConfiguration.Log.Debug($"{typeof(T).Name} with ID {json.Id} not found. Building..."); return((T)JsonFactory[typeof(T)](json, auth, null)); } return(cache); }
public void AttachmentTest() { TrelloServiceConfiguration.ThrowOnTrelloError = false; var serializer = new ManateeSerializer(); TrelloServiceConfiguration.Serializer = serializer; TrelloServiceConfiguration.Deserializer = serializer; TrelloServiceConfiguration.RestClientProvider = new RestSharpClientProvider(); var auth = new TrelloAuthorization(TrelloIds.AppKey, TrelloIds.UserToken); var service = new TrelloService(auth); var list = service.Retrieve <List>(TrelloIds.ListId); var card = list.AddCard("Attachment Test"); card.AddAttachment("new attachment", TrelloIds.AttachmentUrl); }
public void WebhookForBoardGeneratingWebException() { TrelloServiceConfiguration.ThrowOnTrelloError = false; var serializer = new ManateeSerializer(); TrelloServiceConfiguration.Serializer = serializer; TrelloServiceConfiguration.Deserializer = serializer; TrelloServiceConfiguration.RestClientProvider = new RestSharpClientProvider(); var auth = new TrelloAuthorization(TrelloIds.AppKey, TrelloIds.UserToken); var service = new TrelloService(auth); var board = service.Retrieve <Board>(TrelloIds.BoardId); var hook = board.CreateWebhook("http://requestb.in/1k36jm21"); Console.WriteLine(hook == null ? "null" : hook.IsActive.ToString()); }
public BoardContext(string id, TrelloAuthorization auth) : base(auth) { Data.Id = id; Actions = new ReadOnlyActionCollection(typeof(Board), () => Data.Id, auth); Actions.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Actions) }); Cards = new ReadOnlyCardCollection(typeof(Board), () => Data.Id, auth); Cards.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Cards) }); CustomFields = new CustomFieldDefinitionCollection(() => Data.Id, auth); CustomFields.Refreshed += (s, e) => OnMerged(new List <string> { nameof(CustomFields) }); Labels = new BoardLabelCollection(() => Data.Id, auth); Labels.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Labels) }); Lists = new ListCollection(() => Data.Id, auth); Lists.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Lists) }); Members = new ReadOnlyMemberCollection(EntityRequestType.Board_Read_Members, () => Data.Id, auth); Members.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Members) }); Memberships = new BoardMembershipCollection(() => Data.Id, auth); Memberships.Refreshed += (s, e) => OnMerged(new List <string> { nameof(Memberships) }); PowerUps = new PowerUpCollection(() => Data.Id, auth); PowerUps.Refreshed += (s, e) => OnMerged(new List <string> { nameof(PowerUps) }); PowerUpData = new ReadOnlyPowerUpDataCollection(EntityRequestType.Board_Read_PowerUpData, () => Data.Id, auth); PowerUpData.Refreshed += (s, e) => OnMerged(new List <string> { nameof(PowerUpData) }); BoardPreferencesContext = new BoardPreferencesContext(Auth); BoardPreferencesContext.SubmitRequested += ct => HandleSubmitRequested("Preferences", ct); Data.Prefs = BoardPreferencesContext.Data; }
public static T GetFromCache <T, TJson>(this TJson json, TrelloAuthorization auth, bool overwrite = true, params object[] parameters) where T : class, ICacheable, IMergeJson <TJson> where TJson : IJsonCacheable { if (json == null) { return(null); } var cache = TryGetFromCache <T, TJson>(json, overwrite); if (cache == null) { TrelloConfiguration.Log.Debug($"{typeof(T).Name} with ID {json.Id} not found. Building..."); return((T)JsonFactory[typeof(T)](json, auth, parameters)); } return(cache); }
public MemberContext(string id, bool isMe, TrelloAuthorization auth) : base(auth) { Data.Id = id; Actions = new ReadOnlyActionCollection(typeof(Member), () => Data.Id, auth); Boards = isMe ? new BoardCollection(typeof(Member), () => Data.Id, auth) : new ReadOnlyBoardCollection(typeof(Member), () => Data.Id, auth); Cards = new ReadOnlyCardCollection(EntityRequestType.Member_Read_Cards, () => Data.Id, auth); Organizations = isMe ? new OrganizationCollection(() => Data.Id, auth) : new ReadOnlyOrganizationCollection(() => Data.Id, auth); Notifications = new ReadOnlyNotificationCollection(() => Data.Id, auth); MemberPreferencesContext = new MemberPreferencesContext(Auth); MemberPreferencesContext.SubmitRequested += ct => HandleSubmitRequested("Preferences", ct); Data.Prefs = MemberPreferencesContext.Data; }
public void TestBoardCardsExtensionMethod() { TrelloServiceConfiguration.ThrowOnTrelloError = false; var serializer = new ManateeSerializer(); TrelloServiceConfiguration.Serializer = serializer; TrelloServiceConfiguration.Deserializer = serializer; TrelloServiceConfiguration.RestClientProvider = new RestSharpClientProvider(); var auth = new TrelloAuthorization(TrelloIds.AppKey, TrelloIds.UserToken); var service = new TrelloService(auth); var me = service.Me; foreach (var card in me.AllCards()) { Console.WriteLine(card); } }
public void GetAllActions() { TrelloServiceConfiguration.ThrowOnTrelloError = false; var serializer = new ManateeSerializer(); TrelloServiceConfiguration.Serializer = serializer; TrelloServiceConfiguration.Deserializer = serializer; TrelloServiceConfiguration.RestClientProvider = new RestSharpClientProvider(); var auth = new TrelloAuthorization(TrelloIds.AppKey, TrelloIds.UserToken); var service = new TrelloService(auth); var member = service.Retrieve <Member>("gregsdennis"); foreach (var action in member.Actions) { Console.WriteLine(action); } }
public CardContext(string id, TrelloAuthorization auth) : base(auth) { Data.Id = id; Actions = new ReadOnlyActionCollection(typeof(Card), () => Data.Id, auth); Attachments = new AttachmentCollection(() => Data.Id, auth); CheckLists = new CheckListCollection(() => Data.Id, auth); Comments = new CommentCollection(() => Data.Id, auth); CustomFields = new ReadOnlyCustomFieldCollection(() => Data.Id, auth); Labels = new CardLabelCollection(this, auth); Members = new MemberCollection(EntityRequestType.Card_Read_Members, () => Data.Id, auth); PowerUpData = new ReadOnlyPowerUpDataCollection(EntityRequestType.Card_Read_PowerUpData, () => Data.Id, auth); Stickers = new CardStickerCollection(() => Data.Id, auth); VotingMembers = new ReadOnlyMemberCollection(EntityRequestType.Card_Read_MembersVoted, () => Data.Id, auth); BadgesContext = new BadgesContext(Auth); Data.Badges = BadgesContext.Data; }
public OrganizationContext(string id, TrelloAuthorization auth) : base(auth) { Data.Id = id; Actions = new ReadOnlyActionCollection(typeof(Organization), () => Data.Id, auth); Actions.Refreshed += (s, e) => OnMerged(new[] { nameof(Actions) }); Boards = new BoardCollection(typeof(Organization), () => Data.Id, auth); Boards.Refreshed += (s, e) => OnMerged(new[] { nameof(Boards) }); Members = new ReadOnlyMemberCollection(EntityRequestType.Organization_Read_Members, () => Data.Id, auth); Members.Refreshed += (s, e) => OnMerged(new[] { nameof(Members) }); Memberships = new OrganizationMembershipCollection(() => Data.Id, auth); Memberships.Refreshed += (s, e) => OnMerged(new[] { nameof(Memberships) }); PowerUpData = new ReadOnlyPowerUpDataCollection(EntityRequestType.Organization_Read_PowerUpData, () => Data.Id, auth); PowerUpData.Refreshed += (s, e) => OnMerged(new[] { nameof(PowerUpData) }); OrganizationPreferencesContext = new OrganizationPreferencesContext(Auth); OrganizationPreferencesContext.SubmitRequested += ct => HandleSubmitRequested("Preferences", ct); Data.Prefs = OrganizationPreferencesContext.Data; }
public static ICacheable GetFromCache(this IJsonCacheable json, TrelloAuthorization auth) { if (json == null) { return(null); } Type jsonType = json.GetType(); if (!jsonType.IsInterface) { jsonType = JsonTypeMap.Keys.Intersect(jsonType.GetInterfaces()).FirstOrDefault(); if (jsonType == null) { throw new InvalidOperationException($"Type `{json.GetType().Name}` implements more than one Manatee.Trello.Json interface. " + $"Please provide separate classes for each interface."); } } return(TrelloConfiguration.Cache.Find <ICacheable>(json.Id) ?? JsonFactory[JsonTypeMap[jsonType]](json, auth, null)); }
public async Task Issue34_CardsNotDownloading() { //app key and token, user required to enter token var auth = new TrelloAuthorization { AppKey = "440a184b181002cf00f63713a7f51191", UserToken = "dfd8dd877fa1775db502f891370fb26882a4d8bad41a1cc8cf1a58874b21322b" }; TrelloConfiguration.ThrowOnTrelloError = true; Console.WriteLine(await _factory.Me(auth)); var boardID = "574e95edd8a4fc16207f7079"; var board = _factory.Board(boardID); Console.WriteLine(board); //here is where it calls the exception with 'invalid id' foreach (var card in board.Cards) { Console.WriteLine(card); } }
public static ICacheable GetFromCache(this IJsonCacheable json, TrelloAuthorization auth) { return(json == null ? null : TrelloConfiguration.Cache.Find <ICacheable>(o => o.Id == json.Id) ?? _jsonFactory[_jsonTypeMap[json.GetType()]](json, auth)); }
public MemberPreferencesContext(TrelloAuthorization auth) : base(auth) { }
public OrganizationMembershipContext(string id, string ownerId, TrelloAuthorization auth) : base(auth) { _ownerId = ownerId; Data.Id = id; }
private static CommentReaction _BuildCommentReaction(IJsonCommentReaction json, TrelloAuthorization auth, object[] parameters) { var ownerId = parameters[0] as string; return(new CommentReaction(json, ownerId, auth)); }
private CustomFieldsPowerUp(IJsonPowerUp json, TrelloAuthorization auth) : base(json, auth) { }
public BoardPreferencesContext(TrelloAuthorization auth) : base(auth) { }
public SearchContext(TrelloAuthorization auth) : base(auth) { }
public WebhookContext(string id, TrelloAuthorization auth) : this(auth) { Data.Id = id; }
public ActionDataContext(TrelloAuthorization auth) : base(auth) { }
public static T GetFromCache <T>(this IJsonCacheable json, TrelloAuthorization auth) where T : class, ICacheable { return(json == null ? null : TrelloConfiguration.Cache.Find <T>(o => o.Id == json.Id) ?? (T)_jsonFactory[typeof(T)](json, auth)); }
public BadgesContext(TrelloAuthorization auth) : base(auth) { }
public PowerUpDataContext(string id, TrelloAuthorization auth) : base(auth) { Data.Id = id; }
protected LinkedSynchronizationContext(TrelloAuthorization auth) : base(auth, false) { }
public NotificationDataContext(TrelloAuthorization auth) : base(auth) { }
public WebhookContext(TrelloAuthorization auth) : base(auth) { }