internal static async Task <string> GetId(TrelloAuthorization auth, CancellationToken ct) { var endpoint = EndpointFactory.Build(EntityRequestType.Service_Read_Me); _myJson = await JsonRepository.Execute <IJsonMember>(auth, endpoint, ct); // If this object exists in the cache already as a regular Member, it needs to be replaced. var meAsMember = TrelloConfiguration.Cache.Find <Member>(_myJson.Id); if (meAsMember != null) { TrelloConfiguration.Cache.Remove(meAsMember); } return(_myJson.Id); }
/// <summary> /// Creates a new instance of the <see cref="Webhook{T}"/> object for a webhook which has already been registered with Trello. /// </summary> /// <param name="id">The id.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, <see cref="TrelloAuthorization.Default"/> will be used.</param> public Webhook(string id, TrelloAuthorization auth = null) { Id = id; _context = new WebhookContext <T>(Id, auth); _context.Synchronized += Synchronized; _callBackUrl = new Field <string>(_context, nameof(CallBackUrl)); _callBackUrl.AddRule(UriRule.Instance); _description = new Field <string>(_context, nameof(Description)); _isActive = new Field <bool?>(_context, nameof(IsActive)); _isActive.AddRule(NullableHasValueRule <bool> .Instance); _target = new Field <T>(_context, nameof(Target)); _target.AddRule(NotNullRule <T> .Instance); TrelloConfiguration.Cache.Add(this); }
/// <summary> /// Creates a new <see cref="Action"/> instance. /// </summary> /// <param name="id">The action's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, <see cref="TrelloAuthorization.Default"/> will be used.</param> public Action(string id, TrelloAuthorization auth = null) { Id = id; _context = new ActionContext(id, auth); _context.Synchronized.Add(this); _creator = new Field <Member>(_context, nameof(Creator)); _date = new Field <DateTime?>(_context, nameof(Date)); Data = new ActionData(_context.ActionDataContext); _type = new Field <ActionType?>(_context, nameof(Type)); if (auth != TrelloAuthorization.Null) { TrelloConfiguration.Cache.Add(this); } }
internal BoardBackground(IJsonBoardBackground json, TrelloAuthorization auth) { Id = json.Id; _context = new BoardBackgroundContext(auth); _context.Merge(json); _brightness = new Field <BoardBackgroundBrightness?>(_context, nameof(Brightness)); _color = new Field <WebColor>(_context, nameof(Color)); _topColor = new Field <WebColor>(_context, nameof(TopColor)); _bottomColor = new Field <WebColor>(_context, nameof(BottomColor)); _image = new Field <string>(_context, nameof(Image)); _isTiled = new Field <bool?>(_context, nameof(IsTiled)); ScaledImages = new ReadOnlyBoardBackgroundScalesCollection(_context, auth); TrelloConfiguration.Cache.Add(this); }
/// <summary> /// Creates a new instance of the <see cref="CheckList"/> object. /// </summary> /// <param name="id">The check list's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, <see cref="TrelloAuthorization.Default"/> will be used.</param> public CheckList(string id, TrelloAuthorization auth = null) { Id = id; _context = new CheckListContext(id, auth); _context.Synchronized += Synchronized; _board = new Field <Board>(_context, nameof(Board)); _card = new Field <Card>(_context, nameof(Card)); _card.AddRule(NotNullRule <Card> .Instance); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(NotNullOrWhiteSpaceRule.Instance); _position = new Field <Position>(_context, nameof(Position)); _position.AddRule(NotNullRule <Position> .Instance); _position.AddRule(PositionRule.Instance); TrelloConfiguration.Cache.Add(this); }
/// <summary> /// Creates a new instance of the <see cref="Organization"/> object. /// </summary> /// <param name="id">The organization's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, <see cref="TrelloAuthorization.Default"/> will be used.</param> /// <remarks> /// The supplied ID can be either the full ID or the organization's name. /// </remarks> public Organization(string id, TrelloAuthorization auth = null) { Id = id; _context = new OrganizationContext(id, auth); _context.Synchronized += Synchronized; _description = new Field <string>(_context, nameof(Description)); _displayName = new Field <string>(_context, nameof(DisplayName)); _isBusinessClass = new Field <bool>(_context, nameof(IsBusinessClass)); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(OrganizationNameRule.Instance); Preferences = new OrganizationPreferences(_context.OrganizationPreferencesContext); _url = new Field <string>(_context, nameof(Url)); _website = new Field <string>(_context, nameof(Website)); _website.AddRule(UriRule.Instance); TrelloConfiguration.Cache.Add(this); }
internal BoardPersonalPreferences(Func <string> getOwnerId, TrelloAuthorization auth) { _context = new BoardPersonalPreferencesContext(getOwnerId, auth); _emailList = new Field <List>(_context, nameof(EmailList)); _emailList.AddRule(NotNullRule <List> .Instance); _emailPosition = new Field <Position>(_context, nameof(EmailPosition)); _emailPosition.AddRule(NotNullRule <Position> .Instance); _showListGuide = new Field <bool?>(_context, nameof(ShowListGuide)); _showListGuide.AddRule(NullableHasValueRule <bool> .Instance); _showSidebar = new Field <bool?>(_context, nameof(ShowSidebar)); _showSidebar.AddRule(NullableHasValueRule <bool> .Instance); _showSidebarActivity = new Field <bool?>(_context, nameof(ShowSidebarActivity)); _showSidebarActivity.AddRule(NullableHasValueRule <bool> .Instance); _showSidebarBoardActions = new Field <bool?>(_context, nameof(ShowSidebarBoardActions)); _showSidebarBoardActions.AddRule(NullableHasValueRule <bool> .Instance); _showSidebarMembers = new Field <bool?>(_context, nameof(ShowSidebarMembers)); _showSidebarMembers.AddRule(NullableHasValueRule <bool> .Instance); }
internal Attachment(IJsonAttachment json, string ownerId, TrelloAuthorization auth) { Id = json.Id; _context = new AttachmentContext(Id, ownerId, auth); _context.Synchronized += Synchronized; _bytes = new Field <int?>(_context, nameof(Bytes)); _date = new Field <DateTime?>(_context, nameof(Date)); _member = new Field <Member>(_context, nameof(Member)); _isUpload = new Field <bool?>(_context, nameof(IsUpload)); _mimeType = new Field <string>(_context, nameof(MimeType)); _name = new Field <string>(_context, nameof(Name)); Previews = new ReadOnlyAttachmentPreviewCollection(_context, auth); _url = new Field <string>(_context, nameof(Url)); TrelloConfiguration.Cache.Add(this); _context.Merge(json); }
internal BoardMembership(IJsonBoardMembership json, string ownerId, TrelloAuthorization auth) { Id = json.Id; _context = new BoardMembershipContext(Id, ownerId, auth); _context.Synchronized.Add(this); _member = new Field <Member>(_context, nameof(Member)); _memberType = new Field <BoardMembershipType?>(_context, nameof(MemberType)); _memberType.AddRule(NullableHasValueRule <BoardMembershipType> .Instance); _memberType.AddRule(EnumerationRule <BoardMembershipType?> .Instance); _isDeactivated = new Field <bool?>(_context, nameof(IsDeactivated)); if (auth != TrelloAuthorization.Null) { TrelloConfiguration.Cache.Add(this); } _context.Merge(json); }
/// <summary> /// Creates a new instance of the <see cref="Token"/> object. /// </summary> /// <param name="id">The token's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, <see cref="TrelloAuthorization.Default"/> will be used.</param> /// <remarks> /// The supplied ID can be either the full ID or the token itself. /// </remarks> public Token(string id, TrelloAuthorization auth = null) { Id = id; _context = new TokenContext(id, auth); _context.Synchronized.Add(this); _appName = new Field <string>(_context, nameof(AppName)); BoardPermissions = new TokenPermission(_context.BoardPermissions); _dateCreated = new Field <DateTime?>(_context, nameof(DateCreated)); _dateExpires = new Field <DateTime?>(_context, nameof(DateExpires)); _member = new Field <Member>(_context, nameof(Member)); MemberPermissions = new TokenPermission(_context.MemberPermissions); OrganizationPermissions = new TokenPermission(_context.OrganizationPermissions); if (auth != TrelloAuthorization.Null) { TrelloConfiguration.Cache.Add(this); } }
/// <summary> /// Creates a new instance of the <see cref="List"/> object. /// </summary> /// <param name="id">The list's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, <see cref="TrelloAuthorization.Default"/> will be used.</param> public List(string id, TrelloAuthorization auth = null) { Id = id; _context = new ListContext(id, auth); _context.Synchronized += Synchronized; _board = new Field <Board>(_context, nameof(Board)); _board.AddRule(NotNullRule <Board> .Instance); _isArchived = new Field <bool?>(_context, nameof(IsArchived)); _isArchived.AddRule(NullableHasValueRule <bool> .Instance); _isSubscribed = new Field <bool?>(_context, nameof(IsSubscribed)); _isSubscribed.AddRule(NullableHasValueRule <bool> .Instance); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(NotNullOrWhiteSpaceRule.Instance); _position = new Field <Position>(_context, nameof(Position)); _position.AddRule(NotNullRule <Position> .Instance); _position.AddRule(PositionRule.Instance); TrelloConfiguration.Cache.Add(this); }
internal CustomFieldDefinition(IJsonCustomFieldDefinition json, TrelloAuthorization auth) { Id = json.Id; _context = new CustomFieldDefinitionContext(Id, auth); _board = new Field <IBoard>(_context, nameof(Board)); _fieldGroup = new Field <string>(_context, nameof(FieldGroup)); _name = new Field <string>(_context, nameof(Name)); _position = new Field <Position>(_context, nameof(Position)); _type = new Field <CustomFieldType?>(_context, nameof(Type)); TrelloConfiguration.Cache.Add(this); // we need to enumerate the collection to cache all of the values // ReSharper disable once ReturnValueOfPureMethodIsNotUsed //Options?.ToList(); _context.Merge(json); _context.Synchronized += Synchronized; }
internal CustomFieldDefinition(IJsonCustomFieldDefinition json, TrelloAuthorization auth) { Id = json.Id; _context = new CustomFieldDefinitionContext(Id, auth); _board = new Field <IBoard>(_context, nameof(Board)); DisplayInfo = new CustomFieldDisplayInfo(_context.DisplayInfo); _fieldGroup = new Field <string>(_context, nameof(FieldGroup)); _name = new Field <string>(_context, nameof(Name)); _position = new Field <Position>(_context, nameof(Position)); _type = new Field <CustomFieldType?>(_context, nameof(Type)); if (auth != TrelloAuthorization.Null) { TrelloConfiguration.Cache.Add(this); } _context.Merge(json); _context.Synchronized += Synchronized; }
internal CheckItem(IJsonCheckItem json, string checkListId, TrelloAuthorization auth = null) { Id = json.Id; _context = new CheckItemContext(Id, checkListId, auth); _context.Synchronized += Synchronized; _checkList = new Field <CheckList>(_context, nameof(CheckList)); _checkList.AddRule(NotNullRule <CheckList> .Instance); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(NotNullOrWhiteSpaceRule.Instance); _position = new Field <Position>(_context, nameof(Position)); _position.AddRule(NotNullRule <Position> .Instance); _position.AddRule(PositionRule.Instance); _state = new Field <CheckItemState?>(_context, nameof(State)); _state.AddRule(NullableHasValueRule <CheckItemState> .Instance); _state.AddRule(EnumerationRule <CheckItemState?> .Instance); TrelloConfiguration.Cache.Add(this); _context.Merge(json); }
/// <summary> /// Creates a new instance of the <see cref="Organization"/> object. /// </summary> /// <param name="id">The organization's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, /// <see cref="TrelloAuthorization.Default"/> will be used.</param> /// <remarks> /// The supplied ID can be either the full ID or the organization's name. /// </remarks> public Organization(string id, TrelloAuthorization auth = null) { Id = id; _context = new OrganizationContext(id, auth); _context.Synchronized += Synchronized; Actions = new ReadOnlyActionCollection(typeof(Organization), () => Id, auth); Boards = new BoardCollection(typeof(Organization), () => Id, auth); _description = new Field <string>(_context, nameof(Description)); _displayName = new Field <string>(_context, nameof(DisplayName)); _isBusinessClass = new Field <bool>(_context, nameof(IsBusinessClass)); Members = new ReadOnlyMemberCollection(EntityRequestType.Organization_Read_Members, () => Id, auth); Memberships = new OrganizationMembershipCollection(() => Id, auth); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(OrganizationNameRule.Instance); Preferences = new OrganizationPreferences(_context.OrganizationPreferencesContext); _url = new Field <string>(_context, nameof(Url)); _website = new Field <string>(_context, nameof(Website)); _website.AddRule(UriRule.Instance); TrelloConfiguration.Cache.Add(this); }
internal Attachment(IJsonAttachment json, string ownerId, TrelloAuthorization auth) { Id = json.Id; _context = new AttachmentContext(Id, ownerId, auth); _context.Synchronized += Synchronized; _bytes = new Field <int?>(_context, nameof(Bytes)); _date = new Field <DateTime?>(_context, nameof(Date)); _member = new Field <Member>(_context, nameof(Member)); _edgeColor = new Field <WebColor>(_context, nameof(EdgeColor)); _isUpload = new Field <bool?>(_context, nameof(IsUpload)); _mimeType = new Field <string>(_context, nameof(MimeType)); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(NotNullOrWhiteSpaceRule.Instance); _position = new Field <Position>(_context, nameof(Position)); _position.AddRule(PositionRule.Instance); _url = new Field <string>(_context, nameof(Url)); TrelloConfiguration.Cache.Add(this); _context.Merge(json); }
/// <summary> /// Creates a new instance of the <see cref="Card"/> object. /// </summary> /// <param name="id">The card's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, /// <see cref="TrelloAuthorization.Default"/> will be used.</param> /// <remarks> /// The supplied ID can be either the full or short ID. /// </remarks> public Card(string id, TrelloAuthorization auth = null) { Id = id; _context = new CardContext(id, auth); _context.Synchronized += Synchronized; Actions = new ReadOnlyActionCollection(typeof(Card), () => id, auth); Attachments = new AttachmentCollection(() => Id, auth); Badges = new Badges(_context.BadgesContext); _board = new Field <Board>(_context, nameof(Board)); _board.AddRule(NotNullRule <Board> .Instance); CheckLists = new CheckListCollection(this, auth); Comments = new CommentCollection(() => Id, auth); _description = new Field <string>(_context, nameof(Description)); _dueDate = new Field <DateTime?>(_context, nameof(DueDate)); _isComplete = new Field <bool?>(_context, nameof(IsComplete)); _isArchived = new Field <bool?>(_context, nameof(IsArchived)); _isArchived.AddRule(NullableHasValueRule <bool> .Instance); _isSubscribed = new Field <bool?>(_context, nameof(IsSubscribed)); _isSubscribed.AddRule(NullableHasValueRule <bool> .Instance); Labels = new CardLabelCollection(_context, auth); _lastActivity = new Field <DateTime?>(_context, nameof(LastActivity)); _list = new Field <List>(_context, nameof(List)); _list.AddRule(NotNullRule <List> .Instance); Members = new MemberCollection(EntityRequestType.Card_Read_Members, () => Id, auth); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(NotNullOrWhiteSpaceRule.Instance); _position = new Field <Position>(_context, nameof(Position)); _position.AddRule(PositionRule.Instance); PowerUpData = new ReadOnlyPowerUpDataCollection(EntityRequestType.Card_Read_PowerUpData, () => Id, auth); _shortId = new Field <int?>(_context, nameof(ShortId)); _shortUrl = new Field <string>(_context, nameof(ShortUrl)); Stickers = new CardStickerCollection(() => Id, auth); _url = new Field <string>(_context, nameof(Url)); VotingMembers = new ReadOnlyMemberCollection(EntityRequestType.Card_Read_MembersVoted, () => Id, auth); TrelloConfiguration.Cache.Add(this); }
internal Sticker(IJsonSticker json, string ownerId, TrelloAuthorization auth) { Id = json.Id; _context = new StickerContext(Id, ownerId, auth); _context.Synchronized += Synchronized; _left = new Field <double?>(_context, nameof(Left)); _left.AddRule(NullableHasValueRule <double> .Instance); _name = new Field <string>(_context, nameof(Name)); _rotation = new Field <int?>(_context, nameof(Rotation)); _rotation.AddRule(NullableHasValueRule <int> .Instance); _rotation.AddRule(new NumericRule <int> { Min = 0, Max = 359 }); _top = new Field <double?>(_context, nameof(Top)); _top.AddRule(NullableHasValueRule <double> .Instance); _url = new Field <string>(_context, nameof(ImageUrl)); _zIndex = new Field <int?>(_context, nameof(ZIndex)); _zIndex.AddRule(NullableHasValueRule <int> .Instance); _context.Merge(json); TrelloConfiguration.Cache.Add(this); }
/// <summary> /// Creates a new instance of the <see cref="Board"/> object. /// </summary> /// <param name="id">The board's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, /// <see cref="TrelloAuthorization.Default"/> will be used.</param> public Board(string id, TrelloAuthorization auth = null) { Auth = auth; _context = new BoardContext(id, auth); _context.Synchronized += Synchronized; Id = id; Actions = new ReadOnlyActionCollection(typeof(Board), () => Id, auth); Cards = new ReadOnlyCardCollection(typeof(Board), () => Id, auth); _description = new Field <string>(_context, nameof(Description)); _isClosed = new Field <bool?>(_context, nameof(IsClosed)); _isClosed.AddRule(NullableHasValueRule <bool> .Instance); _isPinned = new Field <bool?>(_context, nameof(IsPinned)); _isPinned.AddRule(NullableHasValueRule <bool> .Instance); _isStarred = new Field <bool?>(_context, nameof(IsStarred)); _isStarred.AddRule(NullableHasValueRule <bool> .Instance); _isSubscribed = new Field <bool?>(_context, nameof(IsSubscribed)); _isSubscribed.AddRule(NullableHasValueRule <bool> .Instance); Labels = new BoardLabelCollection(() => Id, auth); Lists = new ListCollection(() => Id, auth); Members = new ReadOnlyMemberCollection(EntityRequestType.Board_Read_Members, () => Id, auth); Memberships = new BoardMembershipCollection(() => Id, auth); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(NotNullOrWhiteSpaceRule.Instance); _organization = new Field <Organization>(_context, nameof(Organization)); PowerUps = new ReadOnlyPowerUpCollection(() => Id, auth); PowerUpData = new ReadOnlyPowerUpDataCollection(EntityRequestType.Board_Read_PowerUpData, () => Id, auth); Preferences = new BoardPreferences(_context.BoardPreferencesContext); PersonalPreferences = new BoardPersonalPreferences(() => Id, auth); _url = new Field <string>(_context, nameof(Url)); _shortUrl = new Field <string>(_context, nameof(ShortUrl)); _shortLink = new Field <string>(_context, nameof(ShortLink)); _lastActivity = new Field <DateTime?>(_context, nameof(LastActivity)); _lastViewed = new Field <DateTime?>(_context, nameof(LastViewed)); TrelloConfiguration.Cache.Add(this); }
internal Member(string id, bool isMe, TrelloAuthorization auth) { Id = id; _context = new MemberContext(id, isMe, auth); _context.Synchronized += Synchronized; _avatarUrl = new Field <string>(_context, nameof(AvatarUrl)); _bio = new Field <string>(_context, nameof(Bio)); _fullName = new Field <string>(_context, nameof(FullName)); _fullName.AddRule(MemberFullNameRule.Instance); _initials = new Field <string>(_context, nameof(Initials)); _initials.AddRule(MemberInitialsRule.Instance); _isConfirmed = new Field <bool?>(_context, nameof(IsConfirmed)); _status = new Field <MemberStatus?>(_context, nameof(Status)); _trophies = new Field <IEnumerable <string> >(_context, nameof(Trophies)); _url = new Field <string>(_context, nameof(Url)); _userName = new Field <string>(_context, nameof(UserName)); _userName.AddRule(UsernameRule.Instance); if (auth != TrelloAuthorization.Null) { TrelloConfiguration.Cache.Add(this); } }
internal CardStickerCollection(Func <string> getOwnerId, TrelloAuthorization auth) : base(getOwnerId, auth) { }
internal CheckList(IJsonCheckList json, TrelloAuthorization auth) : this(json.Id, auth) { _context.Merge(json); }
internal ReadOnlyOrganizationCollection(Func <string> getOwnerId, TrelloAuthorization auth) : base(getOwnerId, auth) { }
internal BoardMembershipCollection(Func <string> getOwnerId, TrelloAuthorization auth) : base(getOwnerId, auth) { }
internal ReadOnlyStickerPreviewCollection(StickerContext context, TrelloAuthorization auth) : base(() => context.Data.Id, auth) { _context = context; }
internal PowerUpCollection(Func <string> getOwnerId, TrelloAuthorization auth) : base(getOwnerId, auth) { }
internal ReadOnlyCheckListCollection(Func <string> getOwnerId, TrelloAuthorization auth) : base(getOwnerId, auth) { }
internal CardCollection(Func <string> getOwnerId, TrelloAuthorization auth) : base(typeof(List), getOwnerId, auth) { }
internal Organization(IJsonOrganization json, TrelloAuthorization auth) : this(json.Id, auth) { _context.Merge(json); }
internal ReadOnlyBoardMembershipCollection(ReadOnlyBoardMembershipCollection source, TrelloAuthorization auth) : base(() => source.OwnerId, auth) { if (source._additionalParameters != null) { _additionalParameters = new Dictionary <string, object>(source._additionalParameters); } }