Skip to content

Commit

Permalink
Merge pull request #55 from gaensebluemchenritter/master
Browse files Browse the repository at this point in the history
Upgrade to Refit 5.0.23
  • Loading branch information
jlucansky authored Jun 19, 2020
2 parents 4ac5d7a + 239eaab commit 3719893
Show file tree
Hide file tree
Showing 30 changed files with 163 additions and 70 deletions.
13 changes: 9 additions & 4 deletions Camunda.Api.Client.Tests/Camunda.Api.Client.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Refit" Version="4.6.16" />
<PackageReference Include="RichardSzalay.MockHttp" Version="3.2.1" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

Expand Down
29 changes: 18 additions & 11 deletions Camunda.Api.Client/Camunda.Api.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,43 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.5.0</Version>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
<VersionSuffix></VersionSuffix>
<VersionPrefix>2.5.1</VersionPrefix>
<FileVersion>2.5.1.0</FileVersion>
<Product>Camunda REST API Client</Product>
<Title>Camunda REST API Client</Title>
<Authors>Jan Lucansky</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/jlucansky/Camunda.Api.Client</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<Description>Camunda REST API Client for .NET platform</Description>
<PackageTags>camunda rest refit bpmn bpm</PackageTags>
<PackageReleaseNotes></PackageReleaseNotes>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<RepositoryType></RepositoryType>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<NoWarn>1701;1702;1705;1591</NoWarn>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<!-- Don't increment AssemblyVersion -->
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Refit" Version="4.6.16" />
<PackageReference Include="Refit" Version="5.0.23" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

<ItemGroup>
<None Include="..\LICENSE" Pack="true" PackagePath="" />
<None Include="icon.png" Pack="true" PackagePath=""/>
<None Include="icon.png" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<Reference Include="Microsoft.CSharp.dll" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<!-- wait for manually signing to complete -->
<Exec Condition="$(SIGNTOOL_WAIT) != ''" Command="start cmd /c pause" />
</Target>

</Project>
24 changes: 13 additions & 11 deletions Camunda.Api.Client/CamundaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net.Http;
using System.Reflection;
using System.Globalization;

using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Refit;
Expand All @@ -26,6 +25,7 @@
using Camunda.Api.Client.User;
using Camunda.Api.Client.UserTask;
using Camunda.Api.Client.VariableInstance;
using JsonSerializer = Newtonsoft.Json.JsonSerializer;

namespace Camunda.Api.Client
{
Expand Down Expand Up @@ -56,9 +56,9 @@ public class CamundaClient
private HttpClient _httpClient;

private RefitSettings _refitSettings;
private static JsonSerializerSettings _jsonSerializerSettings;
private HttpMessageHandler _httpMessageHandler;
internal static JsonSerializerSettings JsonSerializerSettings => _jsonSerializerSettings;
internal static JsonSerializerSettings JsonSerializerSettings { get; private set; }
internal static IContentSerializer JsonContentSerializer { get; private set; }

internal class HistoricApi
{
Expand All @@ -76,14 +76,16 @@ internal class HistoricApi

static CamundaClient()
{
_jsonSerializerSettings = _jsonSerializerSettings ?? new JsonSerializerSettings
JsonSerializerSettings = JsonSerializerSettings ?? new JsonSerializerSettings
{
ContractResolver = new CustomCamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore, // do not send empty fields
};

_jsonSerializerSettings.Converters.Add(new StringEnumConverter());
_jsonSerializerSettings.Converters.Add(new CustomIsoDateTimeConverter());
JsonSerializerSettings.Converters.Add(new StringEnumConverter());
JsonSerializerSettings.Converters.Add(new CustomIsoDateTimeConverter());

JsonContentSerializer = JsonContentSerializer ?? new JsonContentSerializer(JsonSerializerSettings);
}

private class CustomIsoDateTimeConverter : Newtonsoft.Json.Converters.IsoDateTimeConverter
Expand Down Expand Up @@ -139,20 +141,20 @@ private void Initialize()

_refitSettings = _refitSettings ?? new RefitSettings
{
JsonSerializerSettings = _jsonSerializerSettings,
ContentSerializer = JsonContentSerializer,
UrlParameterFormatter = new CustomUrlParameterFormatter(),
HttpMessageHandlerFactory = () => _httpMessageHandler
};
}

private class CustomUrlParameterFormatter : DefaultUrlParameterFormatter
{
public override string Format(object parameterValue, ParameterInfo parameterInfo)
public override string Format(object parameterValue, ICustomAttributeProvider attributeProvider, Type type)
{
if (parameterValue is bool)
return string.Format(CultureInfo.InvariantCulture, "{0}", parameterValue).ToLower();
else
return base.Format(parameterValue, parameterInfo);
return string.Format(CultureInfo.InvariantCulture, "{0}", parameterValue).ToLowerInvariant();

return base.Format(parameterValue, attributeProvider, type);
}
}

Expand Down
5 changes: 4 additions & 1 deletion Camunda.Api.Client/CaseDefinition/CaseDefinitionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class CaseDefinitionService
public CaseDefinitionResource ByKey(string caseDefinitionKey, string tenantId) => new CaseDefinitionResourceByKeyAndTenantId(_api, caseDefinitionKey, tenantId);

public QueryResource<CaseDefinitionQuery, CaseDefinitionInfo> Query(CaseDefinitionQuery query = null) =>
new QueryResource<CaseDefinitionQuery, CaseDefinitionInfo>(_api, query);
new QueryResource<CaseDefinitionQuery, CaseDefinitionInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));
}
}
6 changes: 4 additions & 2 deletions Camunda.Api.Client/CaseExecution/CaseExecutionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ internal CaseExecutionService(ICaseExecutionRestService api)
public CaseExecutionResource this[string caseExecutionId] => new CaseExecutionResource(_api, caseExecutionId);

public QueryResource<CaseExecutionQuery, CaseExecutionInfo> Query(CaseExecutionQuery query = null) =>
new QueryResource<CaseExecutionQuery, CaseExecutionInfo>(_api, query);

new QueryResource<CaseExecutionQuery, CaseExecutionInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));
}
}
7 changes: 6 additions & 1 deletion Camunda.Api.Client/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
using System.Globalization;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Camunda.Api.Client.Tests")]
[assembly: InternalsVisibleTo("Camunda.Api.Client.Tests,PublicKey=" +
"00240000048000009400000006020000002400005253413100040000010001004196a3758b909b" +
"46774069391580d90f2078e831d76f42a00c3d584321fd9b394b12d3a46eab643bc339f526d1d9" +
"5f7450cfd7a0a0316ce2eea145b9d9013f6b677aac1333d94007c79c33e2804af6a749c732ac45" +
"90f17f078d33445a25c45598f744f0774d2c3d82e2a8b0309203be7e3d0b719f7825d4ded4577b" +
"435db7ae")]
namespace Camunda.Api.Client
{
internal static class DateTimeExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ internal DecisionDefinitionService(IDecisionDefinitionRestService api)

public DecisionDefinitionResource ByKey(string decisionDefinitionKey, string tenantId) => new DecisionDefinitionResourceByKeyAndTenantId(_api, decisionDefinitionKey, tenantId);

public QueryResource<DecisionDefinitionQuery, DecisionDefinitionInfo> Query(DecisionDefinitionQuery query = null) =>
new QueryResource<DecisionDefinitionQuery, DecisionDefinitionInfo>(_api, query);
public QueryResource<DecisionDefinitionQuery, DecisionDefinitionInfo> Query(
DecisionDefinitionQuery query = null) =>
new QueryResource<DecisionDefinitionQuery, DecisionDefinitionInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));
}
}
5 changes: 4 additions & 1 deletion Camunda.Api.Client/Deployment/DeploymentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class DeploymentService
public DeploymentResource this[string deploymentId] => new DeploymentResource(_api, deploymentId);

public QueryResource<DeploymentQuery, DeploymentInfo> Query(DeploymentQuery query = null) =>
new QueryResource<DeploymentQuery, DeploymentInfo>(_api, query);
new QueryResource<DeploymentQuery, DeploymentInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <summary>
/// Create a deployment.
Expand Down
7 changes: 5 additions & 2 deletions Camunda.Api.Client/Execution/ExecutionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ internal ExecutionService(IExecutionRestService api)

public ExecutionResource this[string executionId] => new ExecutionResource(_api, executionId);

public QueryResource<ExecutionQuery, ExecutionInfo> Query(ExecutionQuery query = null)
=> new QueryResource<ExecutionQuery, ExecutionInfo>(_api, query);
public QueryResource<ExecutionQuery, ExecutionInfo> Query(ExecutionQuery query = null) =>
new QueryResource<ExecutionQuery, ExecutionInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

}
}
5 changes: 4 additions & 1 deletion Camunda.Api.Client/ExternalTask/ExternalTaskService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ public class ExternalTaskService
internal ExternalTaskService(IExternalTaskRestService api) { _api = api; }

public QueryResource<ExternalTaskQuery, ExternalTaskInfo> Query(ExternalTaskQuery query = null) =>
new QueryResource<ExternalTaskQuery, ExternalTaskInfo>(_api, query);
new QueryResource<ExternalTaskQuery, ExternalTaskInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="externalTaskId">The id of the external task to be retrieved.</param>
public ExternalTaskResource this[string externalTaskId] => new ExternalTaskResource(_api, externalTaskId);
Expand Down
7 changes: 5 additions & 2 deletions Camunda.Api.Client/Group/GroupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ internal GroupService(IGroupRestService api)
_api = api;
}

public QueryResource<GroupQuery, GroupInfo> Query(GroupQuery query = null) =>
new QueryResource<GroupQuery, GroupInfo>(_api, query);
public QueryResource<GroupQuery, GroupInfo> Query(GroupQuery query = null) =>
new QueryResource<GroupQuery, GroupInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="groupId">The id of the group to be retrieved.</param>
public GroupResource this[string groupId] => new GroupResource(_api, groupId);
Expand Down
8 changes: 6 additions & 2 deletions Camunda.Api.Client/History/HistoricActivityInstanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ internal HistoricActivityInstanceService(IHistoricActivityInstanceRestService ap
_api = api;
}

public QueryResource<HistoricActivityInstanceQuery, HistoricActivityInstance> Query(HistoricActivityInstanceQuery query = null) =>
new QueryResource<HistoricActivityInstanceQuery, HistoricActivityInstance>(_api, query);
public QueryResource<HistoricActivityInstanceQuery, HistoricActivityInstance> Query(
HistoricActivityInstanceQuery query = null) =>
new QueryResource<HistoricActivityInstanceQuery, HistoricActivityInstance>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="activityInstanceId">The id of the historic activity instance to be retrieved.</param>
public HistoricActivityInstanceResource this[string activityInstanceId] => new HistoricActivityInstanceResource(_api, activityInstanceId);
Expand Down
8 changes: 6 additions & 2 deletions Camunda.Api.Client/History/HistoricCaseInstanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ internal HistoricCaseInstanceService(IHistoricCaseInstanceRestService api)
_api = api;
}

public QueryResource<HistoricCaseInstanceQuery, HistoricCaseInstance> Query(HistoricCaseInstanceQuery query = null) =>
new QueryResource<HistoricCaseInstanceQuery, HistoricCaseInstance>(_api, query);
public QueryResource<HistoricCaseInstanceQuery, HistoricCaseInstance> Query(
HistoricCaseInstanceQuery query = null) =>
new QueryResource<HistoricCaseInstanceQuery, HistoricCaseInstance>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="caseInstanceId">The id of the historic case instance to be retrieved.</param>
public HistoricCaseInstanceResource this[string caseInstanceId] => new HistoricCaseInstanceResource(_api, caseInstanceId);
Expand Down
8 changes: 6 additions & 2 deletions Camunda.Api.Client/History/HistoricDecisionInstanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ internal HistoricDecisionInstanceService(IHistoricDecisionInstanceRestService ap
_api = api;
}

public QueryResource<HistoricDecisionInstanceQuery, HistoricDecisionInstance> Query(HistoricDecisionInstanceQuery query = null) =>
new QueryResource<HistoricDecisionInstanceQuery, HistoricDecisionInstance>(_api, query);
public QueryResource<HistoricDecisionInstanceQuery, HistoricDecisionInstance> Query(
HistoricDecisionInstanceQuery query = null) =>
new QueryResource<HistoricDecisionInstanceQuery, HistoricDecisionInstance>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="decisionInstanceId">The id of the historic decision instance to be retrieved.</param>
public HistoricDecisionInstanceResource this[string decisionInstanceId] => new HistoricDecisionInstanceResource(_api, decisionInstanceId);
Expand Down
5 changes: 4 additions & 1 deletion Camunda.Api.Client/History/HistoricDetailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ internal HistoricDetailService(IHistoricDetailRestService api)
}

public QueryResource<HistoricDetailQuery, HistoricDetail> Query(HistoricDetailQuery query = null) =>
new QueryResource<HistoricDetailQuery, HistoricDetail>(_api, query);
new QueryResource<HistoricDetailQuery, HistoricDetail>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="historicJobLogId">The id of the detail entry.</param>
public HistoricDetailResource this[string historicJobLogId] => new HistoricDetailResource(_api, historicJobLogId);
Expand Down
6 changes: 4 additions & 2 deletions Camunda.Api.Client/History/HistoricIncidentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ internal HistoricIncidentService(IHistoricIncidentRestService api)
}

public QueryResource<HistoricIncidentQuery, HistoricIncident> Query(HistoricIncidentQuery query = null) =>
new QueryResource<HistoricIncidentQuery, HistoricIncident>(_api, query);

new QueryResource<HistoricIncidentQuery, HistoricIncident>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));
}
}
5 changes: 4 additions & 1 deletion Camunda.Api.Client/History/HistoricJobLogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ internal HistoricJobLogService(IHistoricJobLogRestService api)
}

public QueryResource<HistoricJobLogQuery, HistoricJobLog> Query(HistoricJobLogQuery query = null) =>
new QueryResource<HistoricJobLogQuery, HistoricJobLog>(_api, query);
new QueryResource<HistoricJobLogQuery, HistoricJobLog>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="historicJobLogId">The id of the log entry.</param>
public HistoricJobLogResource this[string historicJobLogId] => new HistoricJobLogResource(_api, historicJobLogId);
Expand Down
8 changes: 6 additions & 2 deletions Camunda.Api.Client/History/HistoricProcessInstanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ internal HistoricProcessInstanceService(IHistoricProcessInstanceRestService api)
_api = api;
}

public QueryResource<HistoricProcessInstanceQuery, HistoricProcessInstance> Query(HistoricProcessInstanceQuery query = null) =>
new QueryResource<HistoricProcessInstanceQuery, HistoricProcessInstance>(_api, query);
public QueryResource<HistoricProcessInstanceQuery, HistoricProcessInstance> Query(
HistoricProcessInstanceQuery query = null) =>
new QueryResource<HistoricProcessInstanceQuery, HistoricProcessInstance>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="processInstanceId">The id of the historic process instance to be retrieved.</param>
public HistoricProcessInstanceResource this[string processInstanceId] => new HistoricProcessInstanceResource(_api, processInstanceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ internal interface IHistoricCaseInstanceRestService

[Post("/history/case-instance")]
Task<List<HistoricCaseInstance>> GetList([Body]HistoricCaseInstanceQuery query, int? firstResult, int? maxResults);

[Post("/history/case-instance/count")]
Task<CountResult> GetListCount([Body] HistoricCaseInstanceQuery query);
}
}
5 changes: 4 additions & 1 deletion Camunda.Api.Client/Incident/IncidentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ internal IncidentService(IIncidentRestService api)
}

public QueryResource<IncidentQuery, IncidentInfo> Query(IncidentQuery query = null) =>
new QueryResource<IncidentQuery, IncidentInfo>(_api, query);
new QueryResource<IncidentQuery, IncidentInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));
}
}
2 changes: 1 addition & 1 deletion Camunda.Api.Client/Job/JobService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal JobService(IJobRestService api)
}

public QueryResource<JobQuery, JobInfo> Query(JobQuery query = null) =>
new QueryResource<JobQuery, JobInfo>(_api, query);
new QueryResource<JobQuery, JobInfo>(query, (q, f, m) => _api.GetList(q, f, m), q => _api.GetListCount(q));

/// <param name="jobId">The id of the job to be retrieved.</param>
public JobResource this[string jobId] => new JobResource(_api, jobId);
Expand Down
5 changes: 4 additions & 1 deletion Camunda.Api.Client/JobDefinition/JobDefinitionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ internal JobDefinitionService(IJobDefinitionRestService api)
}

public QueryResource<JobDefinitionQuery, JobDefinitionInfo> Query(JobDefinitionQuery query = null) =>
new QueryResource<JobDefinitionQuery, JobDefinitionInfo>(_api, query);
new QueryResource<JobDefinitionQuery, JobDefinitionInfo>(
query,
(q, f, m) => _api.GetList(q, f, m),
q => _api.GetListCount(q));

/// <param name="jobDefinitionId">The id of the job to be retrieved.</param>
public JobDefinitionResource this[string jobDefinitionId] => new JobDefinitionResource(_api, jobDefinitionId);
Expand Down
Loading

0 comments on commit 3719893

Please sign in to comment.