Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Version interface to package #78

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Camunda.Api.Client.Tests/ProcessInstanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public async Task GetList()
{
var mockHttp = new MockHttpMessageHandler();

mockHttp.Expect(HttpMethod.Post, "http://localhost:8080/engine-rest")
.Respond(HttpStatusCode.OK, "text/html", "OK");
mockHttp.Expect(HttpMethod.Post, "http://localhost:8080/engine-rest/process-instance")
.Respond(HttpStatusCode.OK, "application/json", "[]");


var client = CamundaClient.Create("http://localhost:8080/engine-rest", mockHttp);
Expand Down
26 changes: 26 additions & 0 deletions Camunda.Api.Client.Tests/VersionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using RichardSzalay.MockHttp;
using Xunit;

namespace Camunda.Api.Client.Tests
{
public class VersionTests
{
[Fact]
public async Task GetVersion()
{
var mockHttp = new MockHttpMessageHandler();

mockHttp.Expect(HttpMethod.Get, "http://localhost:8080/engine-rest/version")
.Respond(HttpStatusCode.OK, "application/json", "{\"version\": \"7.14.0\"}");


var client = CamundaClient.Create("http://localhost:8080/engine-rest", mockHttp);
var version = await client.Version.Get();

Assert.Equal("7.14.0", version.Version);
}
}
}
6 changes: 6 additions & 0 deletions Camunda.Api.Client/CamundaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

using JsonSerializer = Newtonsoft.Json.JsonSerializer;
using Camunda.Api.Client.Filter;
using Camunda.Api.Client.Version;

namespace Camunda.Api.Client
{
Expand All @@ -56,6 +57,7 @@ public class CamundaClient
private Lazy<IUserTaskRestService> _userTaskApi;
private Lazy<IVariableInstanceRestService> _variableInstanceApi;
private Lazy<IFilterRestService> _filterApi;
private Lazy<IVersionRestService> _versionApi;

private HistoricApi _historicApi;

Expand Down Expand Up @@ -219,6 +221,7 @@ private void CreateServices()
_userTaskApi = CreateService<IUserTaskRestService>();
_variableInstanceApi = CreateService<IVariableInstanceRestService>();
_filterApi = CreateService<IFilterRestService>();
_versionApi = CreateService<IVersionRestService>();

_historicApi = new HistoricApi()
{
Expand Down Expand Up @@ -326,5 +329,8 @@ public static CamundaClient Create(HttpClient httpClient)

/// <see href="https://docs.camunda.org/manual/7.9/reference/rest/filter/"/>
public FilterService Filters => new FilterService(_filterApi.Value);

/// <see href="https://docs.camunda.org/manual/7.9/reference/rest/version/"/>
public VersionService Version => new VersionService(_versionApi.Value);
}
}
11 changes: 11 additions & 0 deletions Camunda.Api.Client/Version/IVersionRestService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Refit;
using System.Threading.Tasks;

namespace Camunda.Api.Client.Version
{
internal interface IVersionRestService
{
[Get("/version")]
Task<VersionInfo> Get();
}
}
10 changes: 10 additions & 0 deletions Camunda.Api.Client/Version/VersionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Camunda.Api.Client.Version
{
public class VersionInfo
{
/// <summary>
/// The version of the camunda engine.
/// </summary>
public string Version;
}
}
15 changes: 15 additions & 0 deletions Camunda.Api.Client/Version/VersionService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Linq;
using System.Threading.Tasks;

namespace Camunda.Api.Client.Version
{
public class VersionService
{
private IVersionRestService _api;

internal VersionService(IVersionRestService api) { _api = api; }

public Task<VersionInfo> Get() =>
_api.Get();
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Each part listed below is fully covered according to https://docs.camunda.org/ma
- [x] [Tenant](https://docs.camunda.org/manual/latest/reference/rest/tenant/)
- [x] [User](https://docs.camunda.org/manual/latest/reference/rest/user/)
- [x] [Variable Instance](https://docs.camunda.org/manual/latest/reference/rest/variable-instance/)
- [x] [Version](https://docs.camunda.org/manual/latest/reference/rest/version/)

## Install
The Camunda REST API Client is available on [nuget.org](https://www.nuget.org/packages/Camunda.Api.Client)
Expand Down