Skip to content

Commit 56574e4

Browse files
committed
refactor: ♻️ added query param support to existing find function
1 parent 2d7f1e2 commit 56574e4

File tree

10 files changed

+88
-82
lines changed

10 files changed

+88
-82
lines changed

.github/workflows/nuget-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
dotnet pack -c Release -o out
2222
2323
- name: Push generated package to GitHub registry
24-
run: dotnet nuget push ./contentstack-management-dotnet/out/*.nupkg --api-key ${{NUGET_AUTH_TOKEN}} --skip-duplicate --no-symbols true
24+
run: dotnet nuget push ./contentstack-management-dotnet/out/*.nupkg --api-key $NUGET_AUTH_TOKEN --skip-duplicate --no-symbols true
2525

2626
publish-git:
2727
runs-on: windows-latest
@@ -40,4 +40,4 @@ jobs:
4040
dotnet pack -c Release -o out
4141
4242
- name: Push generated package to GitHub registry
43-
run: dotnet nuget push ./contentstack-management-dotnet/out/*.nupkg --api-key ${{NUGET_AUTH_TOKEN}} --skip-duplicate --no-symbols true
43+
run: dotnet nuget push ./contentstack-management-dotnet/out/*.nupkg --api-key $NUGET_AUTH_TOKEN --skip-duplicate --no-symbols true

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
## [v0.1.2](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.2) (2023-03-07)
4+
35
## [v0.1.1](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.1) (2022-12-16)
46

57
## [v0.1.0](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.0) (2022-10-19)

Contentstack.Management.ASPNETCore/contentstack.management.aspnetcore.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.1</TargetFramework>
55
<PackageId>contentstack.management.aspnetcore</PackageId>
6-
<PackageVersion>0.1.1</PackageVersion>
6+
<PackageVersion>0.1.2</PackageVersion>
77
<Authors>Contentstack</Authors>
8-
<Copyright>Copyright © 2012-2022 Contentstack. All Rights Reserved</Copyright>
8+
<Copyright>Copyright © 2012-2023 Contentstack. All Rights Reserved</Copyright>
99
<Owners>Contentstack </Owners>
1010
<PackageProjectUrl>https://github.com/contentstack/contentstack-management-dotnet</PackageProjectUrl>
1111
<PackageReleaseNotes>Initial Release</PackageReleaseNotes>
@@ -14,8 +14,8 @@
1414
<Title>Contentstack Management</Title>
1515
<Description>.NET SDK for the Contentstack Content Management API.</Description>
1616
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
17-
<PackageTags>v0.1.1</PackageTags>
18-
<ReleaseVersion>0.1.1</ReleaseVersion>
17+
<PackageTags>v0.1.2</PackageTags>
18+
<ReleaseVersion>0.1.2</ReleaseVersion>
1919
<RootNamespace>Contentstack.Management.ASPNETCore</RootNamespace>
2020
</PropertyGroup>
2121

@@ -28,6 +28,6 @@
2828
<ItemGroup>
2929
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
3030
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
31-
<PackageReference Include="contentstack.management.csharp" Version="0.1.0" />
31+
<PackageReference Include="contentstack.management.csharp" Version="0.1.1" />
3232
</ItemGroup>
3333
</Project>

Contentstack.Management.Core.Tests/Contentstack.Management.Core.Tests.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55

66
<IsPackable>false</IsPackable>
7-
<ReleaseVersion>0.1.1</ReleaseVersion>
7+
<ReleaseVersion>0.1.2</ReleaseVersion>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
12-
<PackageReference Include="MSTest.TestAdapter" Version="3.0.0" />
13-
<PackageReference Include="MSTest.TestFramework" Version="3.0.0" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
12+
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
13+
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
1414
<PackageReference Include="coverlet.collector" Version="3.2.0"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
<PrivateAssets>all</PrivateAssets>
1616
</PackageReference>
1717
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
1818
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.1" />
20-
<PackageReference Include="AutoFixture" Version="4.17.0" />
21-
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
22-
<PackageReference Include="Moq" Version="4.18.3" />
19+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.3" />
20+
<PackageReference Include="AutoFixture" Version="4.18.0" />
21+
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.0" />
22+
<PackageReference Include="Moq" Version="4.18.4" />
2323
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
2424
</ItemGroup>
2525

Contentstack.Management.Core.Unit.Tests/Contentstack.Management.Core.Unit.Tests.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55

66
<IsPackable>false</IsPackable>
7-
<ReleaseVersion>0.1.1</ReleaseVersion>
7+
<ReleaseVersion>0.1.2</ReleaseVersion>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
12-
<PackageReference Include="MSTest.TestAdapter" Version="3.0.0" />
13-
<PackageReference Include="MSTest.TestFramework" Version="3.0.0" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
12+
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
13+
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
1414
<PackageReference Include="coverlet.collector" Version="3.2.0"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
<PrivateAssets>all</PrivateAssets>
1616
</PackageReference>
17-
<PackageReference Include="AutoFixture" Version="4.17.0" />
18-
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
19-
<PackageReference Include="Moq" Version="4.18.3" />
17+
<PackageReference Include="AutoFixture" Version="4.18.0" />
18+
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.0" />
19+
<PackageReference Include="Moq" Version="4.18.4" />
2020
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
2121
</ItemGroup>
2222

Contentstack.Management.Core.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Global
5151
{C90C9782-D041-43A1-B13E-21B72B9A6BE2} = {0977D0FB-EACA-4FBE-A780-2DC2B6523E53}
5252
EndGlobalSection
5353
GlobalSection(MonoDevelopProperties) = preSolution
54-
version = 0.1.1
54+
version = 0.1.2
5555
Policies = $0
5656
$0.DotNetNamingPolicy = $1
5757
$1.DirectoryNamespaceAssociation = PrefixedHierarchical

Contentstack.Management.Core/ContentstackClient.cs

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using Contentstack.Management.Core.Abstractions;
1515
using Contentstack.Management.Core.Runtime.Contexts;
1616
using Contentstack.Management.Core.Runtime.Pipeline;
17-
using Contentstack.Management.Core.Http;
1817
using Contentstack.Management.Core.Services.User;
1918
using Contentstack.Management.Core.Queryable;
2019
using Environment = System.Environment;
@@ -26,7 +25,7 @@ namespace Contentstack.Management.Core
2625
/// <summary>
2726
/// Contentstack Client for interacting with Contentstack Management API.
2827
/// </summary>
29-
public class ContentstackClient: IContentstackClient
28+
public class ContentstackClient : IContentstackClient
3029
{
3130
internal ContentstackRuntimePipeline ContentstackPipeline { get; set; }
3231
internal ContentstackClientOptions contentstackOptions;
@@ -36,8 +35,8 @@ public class ContentstackClient: IContentstackClient
3635
private HttpClient _httpClient;
3736
private bool _disposed = false;
3837

39-
private string Version => "0.1.1";
40-
private string xUserAgent { get => $"contentstack-management-dotnet/{Version}"; }
38+
private string Version => "0.1.2";
39+
private string xUserAgent => $"contentstack-management-dotnet/{Version}";
4140
#endregion
4241

4342

@@ -74,7 +73,8 @@ public ContentstackClient(IOptions<ContentstackClientOptions> contentstackOption
7473
}
7574

7675
public ContentstackClient(ContentstackClientOptions contentstackOptions) :
77-
this(new OptionsWrapper<ContentstackClientOptions>(contentstackOptions)){}
76+
this(new OptionsWrapper<ContentstackClientOptions>(contentstackOptions))
77+
{ }
7878

7979
/// <summary>
8080
/// Initializes new instance of the <see cref="ContentstackClient"/> class.
@@ -96,7 +96,7 @@ public ContentstackClient(ContentstackClientOptions contentstackOptions) :
9696
/// </code></pre>
9797
/// </example>
9898
public ContentstackClient(
99-
string authtoken =null,
99+
string authtoken = null,
100100
string host = "api.contentstack.io",
101101
int port = 443,
102102
string version = "v3",
@@ -122,14 +122,16 @@ public ContentstackClient(
122122
ProxyPort = proxyPort,
123123
ProxyCredentials = proxyCredentials
124124
}
125-
)){}
125+
))
126+
{ }
126127
#endregion
127128

128129
protected void Initialize()
129130
{
130-
var httpClientHandler = new HttpClientHandler();
131-
132-
httpClientHandler.Proxy = contentstackOptions.GetWebProxy();
131+
HttpClientHandler httpClientHandler = new HttpClientHandler
132+
{
133+
Proxy = contentstackOptions.GetWebProxy()
134+
};
133135

134136
_httpClient = new HttpClient(httpClientHandler);
135137

@@ -145,20 +147,13 @@ protected void Initialize()
145147
{
146148
_httpClient.Timeout = contentstackOptions.Timeout;
147149
_httpClient.MaxResponseContentBufferSize = contentstackOptions.MaxResponseContentBufferSize;
148-
if (contentstackOptions.DisableLogging)
149-
{
150-
LogManager = LogManager.EmptyLogger;
151-
}
152-
else
153-
{
154-
LogManager = LogManager.GetLogManager(this.GetType());
155-
}
150+
LogManager = contentstackOptions.DisableLogging ? LogManager.EmptyLogger : LogManager.GetLogManager(GetType());
156151
}
157152

158-
this.SerializerSettings.DateParseHandling = DateParseHandling.None;
159-
this.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
160-
this.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
161-
this.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
153+
SerializerSettings.DateParseHandling = DateParseHandling.None;
154+
SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
155+
SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
156+
SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
162157

163158
foreach (Type t in CsmJsonConverterAttribute.GetCustomAttribute(typeof(CsmJsonConverterAttribute)))
164159
{
@@ -170,8 +165,8 @@ protected void BuildPipeline()
170165
{
171166
HttpHandler httpClientHandler = new HttpHandler(_httpClient);
172167

173-
var retryPolicy = contentstackOptions.RetryPolicy ?? new DefaultRetryPolicy(contentstackOptions.RetryLimit, contentstackOptions.RetryDelay);
174-
this.ContentstackPipeline = new ContentstackRuntimePipeline(new List<IPipelineHandler>()
168+
RetryPolicy retryPolicy = contentstackOptions.RetryPolicy ?? new DefaultRetryPolicy(contentstackOptions.RetryLimit, contentstackOptions.RetryDelay);
169+
ContentstackPipeline = new ContentstackRuntimePipeline(new List<IPipelineHandler>()
175170
{
176171
httpClientHandler,
177172
new RetryHandler(retryPolicy)
@@ -182,15 +177,15 @@ internal ContentstackResponse InvokeSync<TRequest>(TRequest request) where TRequ
182177
{
183178
ThrowIfDisposed();
184179

185-
var context = new ExecutionContext(
180+
ExecutionContext context = new ExecutionContext(
186181
new RequestContext()
187182
{
188-
config = this.contentstackOptions,
183+
config = contentstackOptions,
189184
service = request
190185
},
191186
new ResponseContext());
192187

193-
return (ContentstackResponse)this.ContentstackPipeline.InvokeSync(context).httpResponse;
188+
return (ContentstackResponse)ContentstackPipeline.InvokeSync(context).httpResponse;
194189
}
195190

196191
internal Task<TResponse> InvokeAsync<TRequest, TResponse>(TRequest request)
@@ -199,14 +194,14 @@ internal Task<TResponse> InvokeAsync<TRequest, TResponse>(TRequest request)
199194
{
200195
ThrowIfDisposed();
201196

202-
var context = new ExecutionContext(
197+
ExecutionContext context = new ExecutionContext(
203198
new RequestContext()
204199
{
205-
config = this.contentstackOptions,
200+
config = contentstackOptions,
206201
service = request
207202
},
208203
new ResponseContext());
209-
return this.ContentstackPipeline.InvokeAsync<TResponse>(context);
204+
return ContentstackPipeline.InvokeAsync<TResponse>(context);
210205
}
211206

212207
#region Dispose methods
@@ -222,14 +217,15 @@ public void Dispose()
222217
protected virtual void Dispose(bool disposing)
223218
{
224219
if (_disposed)
220+
{
225221
return;
222+
}
226223

227224
if (disposing)
228225
{
229226
_httpClient.Dispose();
230227
}
231-
if (ContentstackPipeline != null)
232-
ContentstackPipeline.Dispose();
228+
ContentstackPipeline?.Dispose();
233229

234230
_disposed = true;
235231

@@ -238,8 +234,10 @@ protected virtual void Dispose(bool disposing)
238234
private void ThrowIfDisposed()
239235
{
240236
//_httpClient.SendAsync
241-
if (this._disposed)
237+
if (_disposed)
238+
{
242239
throw new ObjectDisposedException(GetType().FullName);
240+
}
243241
}
244242
#endregion
245243

@@ -310,9 +308,9 @@ public Stack Stack(string apiKey = null, string managementToken = null, string b
310308
public ContentstackResponse Login(ICredentials credentials, string token = null)
311309
{
312310
ThrowIfAlreadyLoggedIn();
313-
var Login = new LoginService(this.serializer, credentials, token);
311+
LoginService Login = new LoginService(serializer, credentials, token);
314312

315-
return this.InvokeSync(Login);
313+
return InvokeSync(Login);
316314
}
317315

318316
/// <summary>
@@ -331,25 +329,25 @@ public ContentstackResponse Login(ICredentials credentials, string token = null)
331329
public Task<ContentstackResponse> LoginAsync(ICredentials credentials, string token = null)
332330
{
333331
ThrowIfAlreadyLoggedIn();
334-
var Login = new LoginService(this.serializer, credentials, token);
332+
LoginService Login = new LoginService(serializer, credentials, token);
335333

336-
return this.InvokeAsync<LoginService, ContentstackResponse>(Login);
334+
return InvokeAsync<LoginService, ContentstackResponse>(Login);
337335
}
338336
#endregion
339337

340338
#region Throw Error
341339

342340
internal void ThrowIfAlreadyLoggedIn()
343341
{
344-
if (!string.IsNullOrEmpty(this.contentstackOptions.Authtoken))
342+
if (!string.IsNullOrEmpty(contentstackOptions.Authtoken))
345343
{
346344
throw new InvalidOperationException(CSConstants.YouAreLoggedIn);
347345
}
348346
}
349347

350348
internal void ThrowIfNotLoggedIn()
351349
{
352-
if (string.IsNullOrEmpty(this.contentstackOptions.Authtoken))
350+
if (string.IsNullOrEmpty(contentstackOptions.Authtoken))
353351
{
354352
throw new InvalidOperationException(CSConstants.YouAreNotLoggedIn);
355353
}
@@ -370,10 +368,10 @@ internal void ThrowIfNotLoggedIn()
370368
/// <returns>The <see cref="ContentstackResponse" /></returns>
371369
public ContentstackResponse Logout(string authtoken = null)
372370
{
373-
var token = authtoken ?? this.contentstackOptions.Authtoken;
374-
var logout = new LogoutService(this.serializer, token);
371+
string token = authtoken ?? contentstackOptions.Authtoken;
372+
LogoutService logout = new LogoutService(serializer, token);
375373

376-
return this.InvokeSync(logout);
374+
return InvokeSync(logout);
377375
}
378376
/// <summary>
379377
///
@@ -388,10 +386,10 @@ public ContentstackResponse Logout(string authtoken = null)
388386
/// <returns>The Task.</returns>
389387
public Task<ContentstackResponse> LogoutAsync(string authtoken = null)
390388
{
391-
var token = authtoken ?? this.contentstackOptions.Authtoken;
392-
var logout = new LogoutService(this.serializer, token);
389+
string token = authtoken ?? contentstackOptions.Authtoken;
390+
LogoutService logout = new LogoutService(serializer, token);
393391

394-
return this.InvokeAsync<LogoutService, ContentstackResponse>(logout);
392+
return InvokeAsync<LogoutService, ContentstackResponse>(logout);
395393
}
396394
#endregion
397395

@@ -409,9 +407,9 @@ public ContentstackResponse GetUser(ParameterCollection collection = null)
409407
{
410408
ThrowIfNotLoggedIn();
411409

412-
var getUser = new GetLoggedInUserService(this.serializer, collection);
410+
GetLoggedInUserService getUser = new GetLoggedInUserService(serializer, collection);
413411

414-
return this.InvokeSync(getUser);
412+
return InvokeSync(getUser);
415413
}
416414

417415
/// <summary>
@@ -428,9 +426,9 @@ public Task<ContentstackResponse> GetUserAsync(ParameterCollection collection =
428426
{
429427
ThrowIfNotLoggedIn();
430428

431-
var getUser = new GetLoggedInUserService(this.serializer, collection);
429+
GetLoggedInUserService getUser = new GetLoggedInUserService(serializer, collection);
432430

433-
return this.InvokeAsync<GetLoggedInUserService, ContentstackResponse>(getUser);
431+
return InvokeAsync<GetLoggedInUserService, ContentstackResponse>(getUser);
434432
}
435433
}
436434
}

0 commit comments

Comments
 (0)