Skip to content

Commit

Permalink
Update RestSharp to latest, fixing code issue. Also move '/api' part …
Browse files Browse the repository at this point in the history
…of the SDK resource path (#51)
  • Loading branch information
typotter authored Oct 31, 2024
1 parent 00055bb commit 15bb4d9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions dot-net-sdk/constants/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace eppo_sdk.constants;

public class Constants
{
public const string DEFAULT_BASE_URL = "https://fscdn.eppo.cloud/api";
public const string DEFAULT_BASE_URL = "https://fscdn.eppo.cloud";

public const int REQUEST_TIMEOUT_MILLIS = 1000;

Expand All @@ -14,7 +14,7 @@ public class Constants

public const int MAX_CACHE_ENTRIES = 1000;

public const string UFC_ENDPOINT = "/flag-config/v1/config";
public const string UFC_ENDPOINT = "/api/flag-config/v1/config";

public const string BANDIT_ENDPOINT = "/flag-config/v1/bandits";
public const string BANDIT_ENDPOINT = "/api/flag-config/v1/bandits";
}
2 changes: 1 addition & 1 deletion dot-net-sdk/eppo-sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.2" />
<PackageReference Include="NuGet.Versioning" Version="6.9.1" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="RestSharp" Version="112.0.0" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion dot-net-sdk/http/EppoHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public VersionedResourceResponse<TResource> Get<TResource>(string url,
// Prepare request.
var request = new RestRequest
{
Timeout = _requestTimeoutMillis
Timeout = TimeSpan.FromMilliseconds(_requestTimeoutMillis)
};

// Add query parameters.
Expand Down
6 changes: 3 additions & 3 deletions eppo-sdk-test/EppoClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void SetupMockServer()
_mockServer = WireMockServer.Start();
var response = GetMockFlagConfig();
this._mockServer
.Given(Request.Create().UsingGet().WithPath(new RegexMatcher("flag-config/v1/config")))
.Given(Request.Create().UsingGet().WithPath(new RegexMatcher("api/flag-config/v1/config")))
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK).WithBody(response).WithHeader("Content-Type", "application/json"));
}

Expand Down Expand Up @@ -153,7 +153,7 @@ public void ShouldRunInClientMode()
_mockServer!.Should()
.HaveReceivedACall()
.UsingGet()
.And.AtUrl($"{baseUrl}/flag-config/v1/config?apiKey=mock-api-key&sdkName=dotnet-client&sdkVersion={sdkVersion}");
.And.AtUrl($"{baseUrl}/api/flag-config/v1/config?apiKey=mock-api-key&sdkName=dotnet-client&sdkVersion={sdkVersion}");

// Assert - Result verification
That(result, Is.EqualTo(3));
Expand Down Expand Up @@ -256,7 +256,7 @@ private void VerifyApiCalls(int callCount, string sdkName = "dotnet-server")
_mockServer!.Should()
.HaveReceived(callCount).Calls()
.UsingGet()
.And.AtUrl($"{baseUrl}/flag-config/v1/config?apiKey=mock-api-key&sdkName={sdkName}&sdkVersion={sdkVersion}");
.And.AtUrl($"{baseUrl}/api/flag-config/v1/config?apiKey=mock-api-key&sdkName={sdkName}&sdkVersion={sdkVersion}");
}

static List<AssignmentTestCase> GetTestAssignmentData()
Expand Down
4 changes: 2 additions & 2 deletions eppo-sdk-test/http/HttpClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void SetupMockServer()
var currentETag = "CURRENT";

MockServer
.Given(Request.Create().UsingGet().WithPath(new RegexMatcher("flag-config/v1/config")))
.Given(Request.Create().UsingGet().WithPath(new RegexMatcher("api/flag-config/v1/config")))
.RespondWith(Response.Create()
.WithStatusCode(HttpStatusCode.OK)
.WithBody(response)
Expand Down Expand Up @@ -99,7 +99,7 @@ public void ShouldSendSDKParams()
MockServer.Should()
.HaveReceivedACall()
.UsingGet()
.And.AtUrl($"{BaseUrl}/flag-config/v1/config?apiKey=none&sdkName=dotnetTest&sdkVersion=9.9.9");
.And.AtUrl($"{BaseUrl}/api/flag-config/v1/config?apiKey=none&sdkName=dotnetTest&sdkVersion=9.9.9");
}

[Test]
Expand Down

0 comments on commit 15bb4d9

Please sign in to comment.