Skip to content

Commit 43c2d1c

Browse files
Merge pull request #75 from contentstack/staging
DX | 09-06-2025 | Release
2 parents aede469 + ab7888e commit 43c2d1c

33 files changed

+788
-648
lines changed

CHANGELOG.md

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

3+
## [v0.1.12](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.12)
4+
- Fix
5+
- Fix the Delivery Token URL
6+
- Made the Summary More Readable
7+
38
## [v0.1.11](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.11)
49
- Feat
510
- Add support for custom Http client and IHttpClientFactory

Contentstack.Management.ASPNETCore/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright © 2012-2024 Contentstack. All Rights Reserved
3+
Copyright © 2012-2025 Contentstack. All Rights Reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PackageId>contentstack.management.aspnetcore</PackageId>
66
<PackageVersion>$(Version)</PackageVersion>
77
<Authors>Contentstack</Authors>
8-
<Copyright>Copyright © 2012-2024 Contentstack. All Rights Reserved</Copyright>
8+
<Copyright>Copyright © 2012-2025 Contentstack. All Rights Reserved</Copyright>
99
<Owners>Contentstack </Owners>
1010
<PackageProjectUrl>https://github.com/contentstack/contentstack-management-dotnet</PackageProjectUrl>
1111
<PackageReleaseNotes>Initial Release</PackageReleaseNotes>
@@ -15,7 +15,7 @@
1515
<Description>.NET SDK for the Contentstack Content Management API.</Description>
1616
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
1717
<PackageTags>v$(Version)</PackageTags>
18-
<ReleaseVersion>0.1.3</ReleaseVersion>
18+
<ReleaseVersion>$(Version)</ReleaseVersion>
1919
<RootNamespace>Contentstack.Management.ASPNETCore</RootNamespace>
2020
</PropertyGroup>
2121

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using AutoFixture;
4+
using Contentstack.Management.Core.Models;
5+
using Contentstack.Management.Core.Models.Token;
6+
using Contentstack.Management.Core.Queryable;
7+
using Contentstack.Management.Core.Unit.Tests.Mokes;
8+
using Microsoft.VisualStudio.TestTools.UnitTesting;
9+
10+
namespace Contentstack.Management.Core.Unit.Tests.Models
11+
{
12+
[TestClass]
13+
public class DeliveryTokenTest
14+
{
15+
private Stack _stack;
16+
private readonly IFixture _fixture = new Fixture();
17+
private ContentstackResponse _contentstackResponse;
18+
19+
[TestInitialize]
20+
public void initialize()
21+
{
22+
var client = new ContentstackClient();
23+
_contentstackResponse = MockResponse.CreateContentstackResponse("MockResponse.txt");
24+
client.ContentstackPipeline.ReplaceHandler(new MockHttpHandler(_contentstackResponse));
25+
client.contentstackOptions.Authtoken = _fixture.Create<string>();
26+
_stack = new Stack(client, _fixture.Create<string>());
27+
}
28+
29+
[TestMethod]
30+
public void Initialize_DeliveryToken()
31+
{
32+
DeliveryToken token = new DeliveryToken(_stack);
33+
Assert.IsNull(token.Uid);
34+
Assert.AreEqual("stacks/delivery_tokens", token.resourcePath);
35+
Assert.ThrowsException<InvalidOperationException>(() => token.Fetch());
36+
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => token.FetchAsync());
37+
Assert.ThrowsException<InvalidOperationException>(() => token.Update(_fixture.Create<DeliveryTokenModel>()));
38+
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => token.UpdateAsync(_fixture.Create<DeliveryTokenModel>()));
39+
Assert.ThrowsException<InvalidOperationException>(() => token.Delete());
40+
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => token.DeleteAsync());
41+
Assert.AreEqual(token.Query().GetType(), typeof(Query));
42+
}
43+
44+
[TestMethod]
45+
public void Initialize_DeliveryToken_With_Uid()
46+
{
47+
string uid = _fixture.Create<string>();
48+
DeliveryToken token = new DeliveryToken(_stack, uid);
49+
Assert.AreEqual(uid, token.Uid);
50+
Assert.AreEqual($"stacks/delivery_tokens/{uid}", token.resourcePath);
51+
}
52+
53+
[TestMethod]
54+
public void Should_Create_DeliveryToken()
55+
{
56+
ContentstackResponse response = _stack.DeliveryToken().Create(_fixture.Create<DeliveryTokenModel>());
57+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
58+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
59+
}
60+
61+
[TestMethod]
62+
public async Task Should_Create_DeliveryToken_Async()
63+
{
64+
ContentstackResponse response = await _stack.DeliveryToken().CreateAsync(_fixture.Create<DeliveryTokenModel>());
65+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
66+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
67+
}
68+
69+
[TestMethod]
70+
public void Should_Query_DeliveryToken()
71+
{
72+
ContentstackResponse response = _stack.DeliveryToken().Query().Find();
73+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
74+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
75+
}
76+
77+
[TestMethod]
78+
public async Task Should_Query_DeliveryToken_Async()
79+
{
80+
ContentstackResponse response = await _stack.DeliveryToken().Query().FindAsync();
81+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
82+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
83+
}
84+
85+
[TestMethod]
86+
public void Should_Fetch_DeliveryToken()
87+
{
88+
ContentstackResponse response = _stack.DeliveryToken(_fixture.Create<string>()).Fetch();
89+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
90+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
91+
}
92+
93+
[TestMethod]
94+
public async Task Should_Fetch_DeliveryToken_Async()
95+
{
96+
ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create<string>()).FetchAsync();
97+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
98+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
99+
}
100+
101+
[TestMethod]
102+
public void Should_Update_DeliveryToken()
103+
{
104+
ContentstackResponse response = _stack.DeliveryToken(_fixture.Create<string>()).Update(_fixture.Create<DeliveryTokenModel>());
105+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
106+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
107+
}
108+
109+
[TestMethod]
110+
public async Task Should_Update_DeliveryToken_Async()
111+
{
112+
ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create<string>()).UpdateAsync(_fixture.Create<DeliveryTokenModel>());
113+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
114+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
115+
}
116+
117+
[TestMethod]
118+
public void Should_Delete_DeliveryToken()
119+
{
120+
ContentstackResponse response = _stack.DeliveryToken(_fixture.Create<string>()).Delete();
121+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
122+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
123+
}
124+
125+
[TestMethod]
126+
public async Task Should_Delete_DeliveryToken_Async()
127+
{
128+
ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create<string>()).DeleteAsync();
129+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
130+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
131+
}
132+
}
133+
}

Contentstack.Management.Core/ContentstackClient.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class ContentstackClient : IContentstackClient
3535
private HttpClient _httpClient;
3636
private bool _disposed = false;
3737

38-
private string Version => "0.1.11";
38+
private string Version => "0.1.12";
3939
private string xUserAgent => $"contentstack-management-dotnet/{Version}";
4040
#endregion
4141

@@ -59,10 +59,10 @@ public class ContentstackClient : IContentstackClient
5959
/// <pre><code>
6060
/// var options = new ContentstackClientOptions()
6161
/// {
62-
/// Host = &quot;&lt;API_HOST&gt;&quot;,
63-
/// Authtoken = &quot;&lt;AUTHTOKEN&gt;&quot;
62+
/// Host = "<API_HOST>",
63+
/// Authtoken = "<AUTHTOKEN>"
6464
/// }
65-
/// ContentstackClient client = new ContentstackClient(new OptionsWrapper&lt;ContentstackClientOptions&gt;(options));
65+
/// ContentstackClient client = new ContentstackClient(new OptionsWrapper<ContentstackClientOptions>(options));
6666
/// </code></pre>
6767
/// </example>
6868
public ContentstackClient(IOptions<ContentstackClientOptions> contentstackOptions)
@@ -116,7 +116,7 @@ public ContentstackClient(ContentstackClientOptions contentstackOptions) :
116116
/// <param name="proxyCredentials">Credentials to use with a proxy.</param>
117117
/// <example>
118118
/// <pre><code>
119-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
119+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
120120
/// </code></pre>
121121
/// </example>
122122
public ContentstackClient(
@@ -283,7 +283,7 @@ private void ThrowIfDisposed()
283283
/// </summary>
284284
/// <example>
285285
/// <pre><code>
286-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
286+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
287287
/// User user = client.User();
288288
/// </code></pre>
289289
/// </example>
@@ -300,8 +300,8 @@ public User User()
300300
/// <param name="uid">Organization uid.</param>
301301
/// <example>
302302
/// <pre><code>
303-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
304-
/// Organization organization = client.Organization(&quot;&lt;ORG_UID&gt;&quot;);
303+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
304+
/// Organization organization = client.Organization("<ORG_UID>");
305305
/// </code></pre>
306306
/// </example>
307307
/// <returns>The <see cref="Models.Organization" />.</returns>
@@ -318,8 +318,8 @@ public Organization Organization(string uid = null)
318318
/// <param name="managementToken">Stack Management token </param>
319319
/// <example>
320320
/// <pre><code>
321-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
322-
/// Stack Stack = client.Stack(&quot;&lt;API_KEY&gt;&quot;);
321+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
322+
/// Stack Stack = client.Stack("<API_KEY>");
323323
/// </code></pre>
324324
/// </example>
325325
/// <returns>The <see cref="Models.Stack" />.</returns>
@@ -336,8 +336,8 @@ public Stack Stack(string apiKey = null, string managementToken = null, string b
336336
/// <param name="token">The optional 2FA token.</param>
337337
/// <example>
338338
/// <pre><code>
339-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
340-
/// NetworkCredential credentials = new NetworkCredential(&quot;&lt;EMAIL&gt;&quot;, &quot;&lt;PASSWORD&gt;&quot;);
339+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
340+
/// NetworkCredential credentials = new NetworkCredential("<EMAIL>", "<PASSWORD>");
341341
/// ContentstackResponse contentstackResponse = client.Login(credentials);
342342
/// </code></pre>
343343
/// </example>
@@ -357,8 +357,8 @@ public ContentstackResponse Login(ICredentials credentials, string token = null)
357357
/// <param name="token">The optional 2FA token.</param>
358358
/// <example>
359359
/// <pre><code>
360-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
361-
/// NetworkCredential credentials = new NetworkCredential(&quot;&lt;EMAIL&gt;&quot;, &quot;&lt;PASSWORD&gt;&quot;);
360+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
361+
/// NetworkCredential credentials = new NetworkCredential("<EMAIL>", "<PASSWORD>");
362362
/// ContentstackResponse contentstackResponse = await client.LoginAsync(credentials);
363363
/// </code></pre>
364364
/// </example>
@@ -398,7 +398,7 @@ internal void ThrowIfNotLoggedIn()
398398
/// <param name="authtoken">The optional authroken in case user want to logout.</param>
399399
/// <example>
400400
/// <pre><code>
401-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
401+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
402402
/// ContentstackResponse contentstackResponse = client.Logout();
403403
/// </code></pre>
404404
/// </example>
@@ -416,7 +416,7 @@ public ContentstackResponse Logout(string authtoken = null)
416416
/// <param name="authtoken">The optional authroken in case user want to logout.</param>
417417
/// <example>
418418
/// <pre><code>
419-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
419+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
420420
/// ContentstackResponse contentstackResponse = await client.LogoutAsync();
421421
/// </code></pre>
422422
/// </example>
@@ -435,7 +435,7 @@ public Task<ContentstackResponse> LogoutAsync(string authtoken = null)
435435
/// </summary>
436436
/// <example>
437437
/// <pre><code>
438-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
438+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
439439
/// ContentstackResponse contentstackResponse = client.GetUser();
440440
/// </code></pre>
441441
/// </example>
@@ -454,7 +454,7 @@ public ContentstackResponse GetUser(ParameterCollection collection = null)
454454
/// </summary>
455455
/// <example>
456456
/// <pre><code>
457-
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
457+
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
458458
/// ContentstackResponse contentstackResponse = await client.GetUserAsync();
459459
/// </code></pre>
460460
/// </example>

Contentstack.Management.Core/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright © 2012-2024 Contentstack. All Rights Reserved
3+
Copyright © 2012-2025 Contentstack. All Rights Reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)