Skip to content

Commit 24959d5

Browse files
feat!: bump Flagsmith SDK to 8.x/9.x, drop IFlagsmithConfiguration (#644)
Signed-off-by: Adam Vialpando <adamvialpando@gmail.com>
1 parent 291f0b6 commit 24959d5

4 files changed

Lines changed: 15 additions & 13 deletions

File tree

src/OpenFeature.Contrib.Providers.Flagsmith/FlagsmithProvider.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public class FlagsmithProvider : FeatureProvider
3333
/// Creates new instance of <see cref="FlagsmithProvider"/>
3434
/// </summary>
3535
/// <param name="providerOptions">Open feature provider options. You can just use <see cref="FlagsmithProviderConfiguration"/> class </param>
36-
/// <param name="flagsmithOptions">Flagsmith client options. You can just use <see cref="FlagsmithConfiguration"/> class</param>
37-
public FlagsmithProvider(IFlagsmithProviderConfiguration providerOptions, IFlagsmithConfiguration flagsmithOptions)
36+
/// <param name="flagsmithOptions">Flagsmith client options.</param>
37+
public FlagsmithProvider(IFlagsmithProviderConfiguration providerOptions, FlagsmithConfiguration flagsmithOptions)
3838
{
3939
Configuration = providerOptions;
4040
_flagsmithClient = new FlagsmithClient(flagsmithOptions);
@@ -43,13 +43,14 @@ public FlagsmithProvider(IFlagsmithProviderConfiguration providerOptions, IFlags
4343
/// <summary>
4444
/// Creates new instance of <see cref="FlagsmithProvider"/>
4545
/// </summary>
46-
/// <param name="flagsmithOptions">Flagsmith client options. You can just use <see cref="FlagsmithConfiguration"/> class</param>
46+
/// <param name="flagsmithOptions">Flagsmith client options.</param>
4747
/// <param name="providerOptions">Open feature provider options. You can just use <see cref="FlagsmithProviderConfiguration"/> class </param>
4848
/// <param name="httpClient">Http client that will be used for flagsmith requests. You also can use it to register <see cref="FeatureProvider"/> as Typed HttpClient with <see cref="FeatureProvider"> as abstraction</see></param>
49-
public FlagsmithProvider(IFlagsmithProviderConfiguration providerOptions, IFlagsmithConfiguration flagsmithOptions, HttpClient httpClient)
49+
public FlagsmithProvider(IFlagsmithProviderConfiguration providerOptions, FlagsmithConfiguration flagsmithOptions, HttpClient httpClient)
5050
{
5151
Configuration = providerOptions;
52-
_flagsmithClient = new FlagsmithClient(flagsmithOptions, httpClient);
52+
flagsmithOptions.HttpClient = httpClient;
53+
_flagsmithClient = new FlagsmithClient(flagsmithOptions);
5354
}
5455

5556

src/OpenFeature.Contrib.Providers.Flagsmith/OpenFeature.Contrib.Providers.Flagsmith.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</ItemGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="Flagsmith" Version="5.4.3" />
22+
<PackageReference Include="Flagsmith" Version="[8.0,10.0)" />
2323
</ItemGroup>
2424

2525
<ItemGroup>

src/OpenFeature.Contrib.Providers.Flagsmith/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ var providerConfig = new FlagsmithProviderConfiguration();
5757
// Flagsmith client configuration
5858
var flagsmithConfig = new FlagsmithConfiguration
5959
{
60-
ApiUrl = "https://edge.api.flagsmith.com/api/v1/",
60+
ApiUri = new Uri("https://edge.api.flagsmith.com/api/v1/"),
6161
EnvironmentKey = "",
62-
EnableClientSideEvaluation = false,
63-
EnvironmentRefreshIntervalSeconds = 60,
62+
EnableLocalEvaluation = false,
63+
EnvironmentRefreshInterval = TimeSpan.FromSeconds(60),
6464
EnableAnalytics = false,
6565
Retries = 1,
6666
};

test/OpenFeature.Contrib.Providers.Flagsmith.Test/FlagsmithProviderTest.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public class UnitTestFlagsmithProvider
1616
{
1717
private static FlagsmithConfiguration GetDefaultFlagsmithConfiguration() => new()
1818
{
19-
ApiUrl = "https://edge.api.flagsmith.com/api/v1/",
19+
ApiUri = new Uri("https://edge.api.flagsmith.com/api/v1/"),
2020
EnvironmentKey = "some-key",
21-
EnableClientSideEvaluation = false,
22-
EnvironmentRefreshIntervalSeconds = 60,
21+
EnableLocalEvaluation = false,
22+
EnvironmentRefreshInterval = TimeSpan.FromSeconds(60),
2323
EnableAnalytics = false,
2424
Retries = 1
2525
};
@@ -48,12 +48,13 @@ public void CreateFlagmithProvider_WithValidCredentialsAndCustomHttpClient_Creat
4848
var config = GetDefaultFlagsmithConfiguration();
4949
var providerConfig = GetDefaultFlagsmithProviderConfigurationConfiguration();
5050
using var httpClient = new HttpClient();
51+
5152
// Act
5253
var flagsmithProvider = new FlagsmithProvider(providerConfig, config, httpClient);
5354

54-
5555
// Assert
5656
Assert.NotNull(flagsmithProvider._flagsmithClient);
57+
Assert.Same(httpClient, config.HttpClient);
5758
}
5859

5960
[Fact]

0 commit comments

Comments
 (0)