Skip to content

Commit

Permalink
1.11.2: Added TrelloPlan Info and Bump of System.Text.Json
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjdk committed Oct 9, 2024
1 parent 332b3f2 commit 104a477
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Changelog
*Below is the version history of [TrelloDotNet](https://github.com/rwjdk/TrelloDotNet) (An wrapper of the Trello API)*

## Unreleased
## 1.11.2 (9th of October 2024)
#### TrelloClient
- `GetBoardOptions` now have Filter options (All, Open, Closed or Starred boards)

- Added [GetTrelloPlanInformationForOrganization](https://github.com/rwjdk/TrelloDotNet/wiki/GetTrelloPlanInformationForOrganization) and [GetTrelloPlanInformationForBoard](https://github.com/rwjdk/TrelloDotNet/wiki/GetTrelloPlanInformationForBoard) to get information what features the Workspace/Board support
- Bumped System.Text.Json dependency to version 8.0.5 due to [Security Vulnerability CVE-2024-43485](https://github.com/rwjdk/TrelloDotNet/security/dependabot/3) in previous version)

<hr/>

## 1.11.1 (5th of October 2024)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Text.Json.Serialization;

// ReSharper disable UnusedMember.Global

namespace TrelloDotNet.Model.Options.GetBoardOptions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System;
using TrelloDotNet.Model.Options.GetCardOptions;

namespace TrelloDotNet.Model.Options.GetLabelOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/TrelloDotNet/Model/Options/LabelFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public LabelFields(params string[] fields)
/// <param name="fields">Type of Field to include</param>
public LabelFields(params LabelFieldsType[] fields)
{
Fields = fields.Select(x => EnumHelper.GetJsonPropertyName(x)).ToArray();
Fields = fields.Select(x => x.GetJsonPropertyName()).ToArray();
}
}
}
2 changes: 2 additions & 0 deletions src/TrelloDotNet/Model/Options/LabelFieldsType.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Text.Json.Serialization;

// ReSharper disable UnusedMember.Global

namespace TrelloDotNet.Model.Options
{
/// <summary>
Expand Down
33 changes: 33 additions & 0 deletions src/TrelloDotNet/Model/TrelloPlan.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace TrelloDotNet.Model
{
/// <summary>
/// What Trello Plan a Board/Workspace is using (https://trello.com/pricing)
/// </summary>
public enum TrelloPlan
{
/// <summary>
/// The Plan could not be determined
/// </summary>
Unknown,

/// <summary>
/// The Free Plan
/// </summary>
Free,

/// <summary>
/// The Standard Plan
/// </summary>
Standard,

/// <summary>
/// The Premium Plan
/// </summary>
Premium,

/// <summary>
/// The Enterprise Plan
/// </summary>
Enterprise
}
}
82 changes: 82 additions & 0 deletions src/TrelloDotNet/Model/TrelloPlanInformation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

// ReSharper disable UnusedMember.Global

namespace TrelloDotNet.Model
{
/// <summary>
/// Contains what Trello Plan a Board/Workspace is using (Free, Standard, Premium, Enterprise) and thereby what features are supported
/// </summary>
public class TrelloPlanInformation
{
/// <summary>
/// Id of the Board/Workspace
/// </summary>
[JsonPropertyName("id")]
[JsonInclude]
public string Id { get; set; }

/// <summary>
/// Name of the Board/Workspace
/// </summary>
[JsonPropertyName("name")]
[JsonInclude]
public string Name { get; set; }

/// <summary>
/// What subscription plan (Free, Standard, Premium or Enterprise)
/// </summary>
public TrelloPlan Plan
{
get
{
if (Features == null || Features.Count == 0)
{
return TrelloPlan.Unknown;
}

if (Features.Contains("isEnterprise"))
{
return TrelloPlan.Enterprise;
}

if (Features.Contains("isPremium"))
{
return TrelloPlan.Premium;
}

if (Features.Contains("isStandard"))
{
return TrelloPlan.Standard;
}

return TrelloPlan.Free;
}
}

/// <summary>
/// List of Features for the Board/Workspace
/// </summary>
[JsonPropertyName("premiumFeatures")]
[JsonInclude]
public List<string> Features { get; private set; }

/// <summary>
/// If this board support Custom Fields (Only populated if GetBoardOptions.CardFields include 'premiumFeatures')
/// </summary>
// ReSharper disable once UnusedMember.Global
public bool IsCustomFieldsSupported => Plan == TrelloPlan.Standard || Plan == TrelloPlan.Premium || Plan == TrelloPlan.Enterprise;

/// <summary>
/// If this board support Advanced Checklists (Only populated if GetBoardOptions.CardFields include 'premiumFeatures')
/// </summary>
// ReSharper disable once UnusedMember.Global
public bool IsAdvancedChecklistsSupported => Plan == TrelloPlan.Standard || Plan == TrelloPlan.Premium || Plan == TrelloPlan.Enterprise;

/// <summary>
/// If this board support List Colors (Only populated if GetBoardOptions.CardFields include 'premiumFeatures')
/// </summary>
public bool IsListColorsSupported => Plan == TrelloPlan.Standard || Plan == TrelloPlan.Premium || Plan == TrelloPlan.Enterprise;
}
}
2 changes: 2 additions & 0 deletions src/TrelloDotNet/TrelloClient.Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using TrelloDotNet.Model.Actions;
using TrelloDotNet.Model.Options.GetActionsOptions;

// ReSharper disable UnusedMember.Global

namespace TrelloDotNet
{
public partial class TrelloClient
Expand Down
16 changes: 16 additions & 0 deletions src/TrelloDotNet/TrelloClient.Boards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using TrelloDotNet.Control;
using TrelloDotNet.Model;
using TrelloDotNet.Model.Options;
using TrelloDotNet.Model.Options.GetBoardOptions;

// ReSharper disable UnusedMember.Global
Expand Down Expand Up @@ -95,6 +96,21 @@ public async Task<Board> GetBoardAsync(string boardId, CancellationToken cancell
return await _apiRequestController.Get<Board>(GetUrlBuilder.GetBoard(boardId), cancellationToken);
}


/// <summary>
/// Get Plan Information for a specific board (Free, Standard, Premium, Enterprise) + what features are supported
/// </summary>
/// <param name="boardId">Id of the Board</param>
/// <param name="cancellationToken">Cancellation Token</param>
/// <returns>The Plan Info</returns>
public async Task<TrelloPlanInformation> GetTrelloPlanInformationForBoard(string boardId, CancellationToken cancellationToken = default)
{
return await _apiRequestController.Get<TrelloPlanInformation>(GetUrlBuilder.GetBoard(boardId, new GetBoardOptions
{
BoardFields = new BoardFields("name", "premiumFeatures")
}), cancellationToken);
}

/// <summary>
/// Get a Board by its Id
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions src/TrelloDotNet/TrelloClient.Organizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,16 @@ public async Task DeleteOrganizationAsync(string organizationId, CancellationTok
throw new SecurityException("Deletion of Organizations are disabled via Options.AllowDeleteOfOrganizations (You need to enable this as a secondary confirmation that you REALLY wish to use that option as there is no going back)");
}
}

/// <summary>
/// Get Plan Information for a specific Workspace (Free, Standard, Premium, Enterprise) + what features are supported
/// </summary>
/// <param name="organizationId">Id of the Workspace</param>
/// <param name="cancellationToken">Cancellation Token</param>
/// <returns>The Plan Info</returns>
public async Task<TrelloPlanInformation> GetTrelloPlanInformationForOrganization(string organizationId, CancellationToken cancellationToken = default)
{
return await _apiRequestController.Get<TrelloPlanInformation>(GetUrlBuilder.GetOrganization(organizationId), cancellationToken, new QueryParameter("fields", "id,name,premiumFeatures"));
}
}
}
2 changes: 1 addition & 1 deletion src/TrelloDotNet/TrelloDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageProjectUrl>https://github.com/rwjdk/TrelloDotNet/wiki</PackageProjectUrl>
<PackageIcon>trello.png</PackageIcon>
<PackageTags>trello api rest .NET dotNet crud wrapper webhook automation</PackageTags>
<Version>1.11.1</Version>
<Version>1.11.2</Version>
<Company>RWJDK</Company>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
Expand Down

0 comments on commit 104a477

Please sign in to comment.