Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [v0.1.12](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.12)
- Fix
- Fix the Delivery Token URL
- Made the Summary More Readable

## [v0.1.11](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.11)
- Feat
- Add support for custom Http client and IHttpClientFactory
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Management.ASPNETCore/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright © 2012-2024 Contentstack. All Rights Reserved
Copyright © 2012-2025 Contentstack. All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PackageId>contentstack.management.aspnetcore</PackageId>
<PackageVersion>$(Version)</PackageVersion>
<Authors>Contentstack</Authors>
<Copyright>Copyright © 2012-2024 Contentstack. All Rights Reserved</Copyright>
<Copyright>Copyright © 2012-2025 Contentstack. All Rights Reserved</Copyright>
<Owners>Contentstack </Owners>
<PackageProjectUrl>https://github.com/contentstack/contentstack-management-dotnet</PackageProjectUrl>
<PackageReleaseNotes>Initial Release</PackageReleaseNotes>
Expand All @@ -15,7 +15,7 @@
<Description>.NET SDK for the Contentstack Content Management API.</Description>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageTags>v$(Version)</PackageTags>
<ReleaseVersion>0.1.3</ReleaseVersion>
<ReleaseVersion>$(Version)</ReleaseVersion>
<RootNamespace>Contentstack.Management.ASPNETCore</RootNamespace>
</PropertyGroup>

Expand Down
133 changes: 133 additions & 0 deletions Contentstack.Management.Core.Unit.Tests/Models/DeliveryTokenTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using System;
using System.Threading.Tasks;
using AutoFixture;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Models.Token;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Unit.Tests.Mokes;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Contentstack.Management.Core.Unit.Tests.Models
{
[TestClass]
public class DeliveryTokenTest
{
private Stack _stack;
private readonly IFixture _fixture = new Fixture();
private ContentstackResponse _contentstackResponse;

[TestInitialize]
public void initialize()
{
var client = new ContentstackClient();
_contentstackResponse = MockResponse.CreateContentstackResponse("MockResponse.txt");
client.ContentstackPipeline.ReplaceHandler(new MockHttpHandler(_contentstackResponse));
client.contentstackOptions.Authtoken = _fixture.Create<string>();
_stack = new Stack(client, _fixture.Create<string>());
}

[TestMethod]
public void Initialize_DeliveryToken()
{
DeliveryToken token = new DeliveryToken(_stack);
Assert.IsNull(token.Uid);
Assert.AreEqual("stacks/delivery_tokens", token.resourcePath);
Assert.ThrowsException<InvalidOperationException>(() => token.Fetch());
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => token.FetchAsync());
Assert.ThrowsException<InvalidOperationException>(() => token.Update(_fixture.Create<DeliveryTokenModel>()));
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => token.UpdateAsync(_fixture.Create<DeliveryTokenModel>()));
Assert.ThrowsException<InvalidOperationException>(() => token.Delete());
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => token.DeleteAsync());
Assert.AreEqual(token.Query().GetType(), typeof(Query));
}

[TestMethod]
public void Initialize_DeliveryToken_With_Uid()
{
string uid = _fixture.Create<string>();
DeliveryToken token = new DeliveryToken(_stack, uid);
Assert.AreEqual(uid, token.Uid);
Assert.AreEqual($"stacks/delivery_tokens/{uid}", token.resourcePath);
}

[TestMethod]
public void Should_Create_DeliveryToken()
{
ContentstackResponse response = _stack.DeliveryToken().Create(_fixture.Create<DeliveryTokenModel>());
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public async Task Should_Create_DeliveryToken_Async()
{
ContentstackResponse response = await _stack.DeliveryToken().CreateAsync(_fixture.Create<DeliveryTokenModel>());
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public void Should_Query_DeliveryToken()
{
ContentstackResponse response = _stack.DeliveryToken().Query().Find();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public async Task Should_Query_DeliveryToken_Async()
{
ContentstackResponse response = await _stack.DeliveryToken().Query().FindAsync();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public void Should_Fetch_DeliveryToken()
{
ContentstackResponse response = _stack.DeliveryToken(_fixture.Create<string>()).Fetch();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public async Task Should_Fetch_DeliveryToken_Async()
{
ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create<string>()).FetchAsync();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public void Should_Update_DeliveryToken()
{
ContentstackResponse response = _stack.DeliveryToken(_fixture.Create<string>()).Update(_fixture.Create<DeliveryTokenModel>());
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public async Task Should_Update_DeliveryToken_Async()
{
ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create<string>()).UpdateAsync(_fixture.Create<DeliveryTokenModel>());
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public void Should_Delete_DeliveryToken()
{
ContentstackResponse response = _stack.DeliveryToken(_fixture.Create<string>()).Delete();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}

[TestMethod]
public async Task Should_Delete_DeliveryToken_Async()
{
ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create<string>()).DeleteAsync();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
}
}
}
36 changes: 18 additions & 18 deletions Contentstack.Management.Core/ContentstackClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ContentstackClient : IContentstackClient
private HttpClient _httpClient;
private bool _disposed = false;

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

Expand All @@ -59,10 +59,10 @@ public class ContentstackClient : IContentstackClient
/// <pre><code>
/// var options = new ContentstackClientOptions()
/// {
/// Host = &quot;&lt;API_HOST&gt;&quot;,
/// Authtoken = &quot;&lt;AUTHTOKEN&gt;&quot;
/// Host = "<API_HOST>",
/// Authtoken = "<AUTHTOKEN>"
/// }
/// ContentstackClient client = new ContentstackClient(new OptionsWrapper&lt;ContentstackClientOptions&gt;(options));
/// ContentstackClient client = new ContentstackClient(new OptionsWrapper<ContentstackClientOptions>(options));
/// </code></pre>
/// </example>
public ContentstackClient(IOptions<ContentstackClientOptions> contentstackOptions)
Expand Down Expand Up @@ -116,7 +116,7 @@ public ContentstackClient(ContentstackClientOptions contentstackOptions) :
/// <param name="proxyCredentials">Credentials to use with a proxy.</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// </code></pre>
/// </example>
public ContentstackClient(
Expand Down Expand Up @@ -283,7 +283,7 @@ private void ThrowIfDisposed()
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// User user = client.User();
/// </code></pre>
/// </example>
Expand All @@ -300,8 +300,8 @@ public User User()
/// <param name="uid">Organization uid.</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// Organization organization = client.Organization(&quot;&lt;ORG_UID&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// Organization organization = client.Organization("<ORG_UID>");
/// </code></pre>
/// </example>
/// <returns>The <see cref="Models.Organization" />.</returns>
Expand All @@ -318,8 +318,8 @@ public Organization Organization(string uid = null)
/// <param name="managementToken">Stack Management token </param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// Stack Stack = client.Stack(&quot;&lt;API_KEY&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// Stack Stack = client.Stack("<API_KEY>");
/// </code></pre>
/// </example>
/// <returns>The <see cref="Models.Stack" />.</returns>
Expand All @@ -336,8 +336,8 @@ public Stack Stack(string apiKey = null, string managementToken = null, string b
/// <param name="token">The optional 2FA token.</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// NetworkCredential credentials = new NetworkCredential(&quot;&lt;EMAIL&gt;&quot;, &quot;&lt;PASSWORD&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// NetworkCredential credentials = new NetworkCredential("<EMAIL>", "<PASSWORD>");
/// ContentstackResponse contentstackResponse = client.Login(credentials);
/// </code></pre>
/// </example>
Expand All @@ -357,8 +357,8 @@ public ContentstackResponse Login(ICredentials credentials, string token = null)
/// <param name="token">The optional 2FA token.</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// NetworkCredential credentials = new NetworkCredential(&quot;&lt;EMAIL&gt;&quot;, &quot;&lt;PASSWORD&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// NetworkCredential credentials = new NetworkCredential("<EMAIL>", "<PASSWORD>");
/// ContentstackResponse contentstackResponse = await client.LoginAsync(credentials);
/// </code></pre>
/// </example>
Expand Down Expand Up @@ -398,7 +398,7 @@ internal void ThrowIfNotLoggedIn()
/// <param name="authtoken">The optional authroken in case user want to logout.</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.Logout();
/// </code></pre>
/// </example>
Expand All @@ -416,7 +416,7 @@ public ContentstackResponse Logout(string authtoken = null)
/// <param name="authtoken">The optional authroken in case user want to logout.</param>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.LogoutAsync();
/// </code></pre>
/// </example>
Expand All @@ -435,7 +435,7 @@ public Task<ContentstackResponse> LogoutAsync(string authtoken = null)
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = client.GetUser();
/// </code></pre>
/// </example>
Expand All @@ -454,7 +454,7 @@ public ContentstackResponse GetUser(ParameterCollection collection = null)
/// </summary>
/// <example>
/// <pre><code>
/// ContentstackClient client = new ContentstackClient(&quot;&lt;AUTHTOKEN&gt;&quot;, &quot;&lt;API_HOST&gt;&quot;);
/// ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");
/// ContentstackResponse contentstackResponse = await client.GetUserAsync();
/// </code></pre>
/// </example>
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Management.Core/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright © 2012-2024 Contentstack. All Rights Reserved
Copyright © 2012-2025 Contentstack. All Rights Reserved

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