Skip to content

Commit 5c9e192

Browse files
authored
Merge pull request #1 from contentstack/develop
API implementation for Sync and Content Type information.
2 parents bf5d631 + 4cef53c commit 5c9e192

35 files changed

Lines changed: 1461 additions & 350 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ packages/
1818
*.config
1919
*.nupkg
2020
*.nuspec
21-
Contentstack.core/docfx_project/*

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### Version: 1.1.0
2+
#### Date: Apr-12-2019
3+
4+
##### New Features:
5+
- ContentstackClient
6+
- added method 'GetContentTypes'
7+
- added method 'SyncRecursive'
8+
- added method 'SyncRecursiveLanguage'
9+
- added method 'SyncPaginationToken'
10+
- added method 'SyncToken'
11+
12+
- CotentType
13+
- added method 'Fetch'
14+
15+
### Version: 1.0.6
16+
#### Date: Apr-12-2019
17+
18+
Localization support for Query and Entry is added.
19+
20+
### Version: 1.0.0
21+
#### Date: Apr-12-2019
22+
23+
- Introduce ContentStack SDK for DOTNET.

Contentstack.AspNetCore/Contentstack.AspNetCore.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
<PackageId>contentstack.aspnetcore</PackageId>
77
<Authors>Contentstack</Authors>
88
<Owners>Contentstack</Owners>
9-
<ReleaseVersion>0.0.1</ReleaseVersion>
9+
<ReleaseVersion>1.1.0</ReleaseVersion>
1010
<PackageVersion>1.0.0</PackageVersion>
1111
<Description>Main release</Description>
12+
<Copyright>Copyright (c) 2012-2019 Contentstack (http://app.contentstack.com). All Rights Reserved
13+
</Copyright>
14+
<PackageProjectUrl>https://github.com/contentstack/contentstack-dotnet</PackageProjectUrl>
15+
<PackageTags>v1.0.0</PackageTags>
1216
</PropertyGroup>
1317

1418
<ItemGroup>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using Xunit;
3+
using Contentstack.Core.Models;
4+
using System.Threading.Tasks;
5+
using Contentstack.Core.Configuration;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text.RegularExpressions;
9+
using System.Collections;
10+
11+
namespace Contentstack.Core.Tests
12+
{
13+
public class ContentTypeTest
14+
15+
{
16+
ContentstackClient client = StackConfig.GetStack();
17+
String source = "source";
18+
19+
[Fact]
20+
public async Task FetchContenTypeSchema()
21+
{
22+
ContentType contenttype = client.ContentType(source);
23+
var result = await contenttype.Fetch();
24+
if (result == null)
25+
{
26+
Assert.False(true, "contenttype.FetchSchema() is not match with expected result.");
27+
}
28+
else
29+
{
30+
Assert.True(true);
31+
}
32+
}
33+
34+
[Fact]
35+
public async Task GetContentTypes()
36+
{
37+
var result = await client.GetContentTypes();
38+
39+
if (result == null)
40+
{
41+
Assert.False(true, "client.getContentTypes is not match with expected result.");
42+
}
43+
else
44+
{
45+
Assert.True(true);
46+
47+
}
48+
}
49+
}
50+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
<TargetFramework>netcoreapp2.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
7-
<ReleaseVersion>0.0.1</ReleaseVersion>
7+
<ReleaseVersion>1.1.0</ReleaseVersion>
88
</PropertyGroup>
99

1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
1212
<PackageReference Include="xunit" Version="2.3.1" />
1313
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
1414
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
15+
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
1516
</ItemGroup>
1617

1718
<ItemGroup>
@@ -33,6 +34,7 @@
3334
<None Remove="TestResults\Prod_2018-09-30_13_16_23.trx" />
3435
<None Remove="TestResults\_Uttams-MacBook-Pro_2018-09-29_00_07_58.trx" />
3536
<None Remove="TestResults\_Uttams-MacBook-Pro_2018-09-29_19_54_44.trx" />
37+
<None Remove="appSetting.xml" />
3638
</ItemGroup>
3739
<ItemGroup>
3840
<ProjectReference Include="..\ContentStack.Core\Contentstack.Core.csproj" />

Contentstack.Core.Tests/EntryTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
using System.Collections.Generic;
77
using System.Linq;
88
using System.Text.RegularExpressions;
9-
9+
using System.Collections;
10+
1011
namespace Contentstack.Core.Tests
1112
{
1213

@@ -15,7 +16,6 @@ public class EntryTest
1516
ContentstackClient client = StackConfig.GetStack();
1617

1718

18-
String numbersContentType = "numbers_content_type";
1919
String source = "source";
2020
String singelEntryFetchUID = "blt1f94e478501bba46";
2121
String referenceFieldUID = "reference";

Contentstack.Core.Tests/StackConfig.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Contentstack.Core;
33
using Contentstack.Core.Models;
44
using System.Configuration;
5+
using Microsoft.Extensions.Options;
56

67
namespace Contentstack.Core.Tests
78
{
@@ -17,6 +18,30 @@ System.Configuration.Configuration assemblyConfiguration
1718
}
1819
}
1920

21+
public static ContentstackClient GetSyncStack()
22+
{
23+
StackConfig config = new StackConfig();
24+
if (config.assemblyConfiguration.HasFile && string.Compare(config.assemblyConfiguration.FilePath, config.currentConfiguration.FilePath, true) != 0)
25+
{
26+
config.assemblyConfiguration.SaveAs(config.currentConfiguration.FilePath);
27+
ConfigurationManager.RefreshSection("appSettings");
28+
ConfigurationManager.RefreshSection("connectionStrings");
29+
}
30+
string apiKey = ConfigurationManager.AppSettings["sync_api_key"];
31+
string accessToken = ConfigurationManager.AppSettings["sync_access_token"];
32+
string environment = ConfigurationManager.AppSettings["sync_environment"];
33+
string host = ConfigurationManager.AppSettings["host"];
34+
Configuration.ContentstackOptions contentstackOptions = new Configuration.ContentstackOptions
35+
{
36+
ApiKey = apiKey,
37+
AccessToken = accessToken,
38+
Environment = environment,
39+
Host = host
40+
};
41+
42+
ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper<Configuration.ContentstackOptions>(contentstackOptions));
43+
return contentstackClient;
44+
}
2045

2146
public static ContentstackClient GetStack()
2247
{
@@ -30,16 +55,16 @@ public static ContentstackClient GetStack()
3055
string apiKey = ConfigurationManager.AppSettings["api_key"];
3156
string accessToken = ConfigurationManager.AppSettings["access_token"];
3257
string environment = ConfigurationManager.AppSettings["environment"];
33-
58+
string host = ConfigurationManager.AppSettings["host"];
3459
Configuration.ContentstackOptions contentstackOptions = new Configuration.ContentstackOptions
3560
{
3661
ApiKey = apiKey,
3762
AccessToken = accessToken,
38-
Environment = environment
63+
Environment = environment,
64+
Host = host
3965
};
4066

41-
ContentstackClient contentstackClient = new ContentstackClient(apiKey, accessToken, environment);
42-
67+
ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper<Configuration.ContentstackOptions>(contentstackOptions));
4368
return contentstackClient;
4469

4570
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
using System;
2+
using Xunit;
3+
using Contentstack.Core.Configuration;
4+
using System.Threading.Tasks;
5+
6+
namespace Contentstack.Core.Tests
7+
{
8+
public class SyncStackTest
9+
{
10+
ContentstackClient client = StackConfig.GetSyncStack();
11+
12+
[Fact]
13+
public async Task SyncInit()
14+
{
15+
16+
var result = await client.SyncRecursive();
17+
18+
if (result == null)
19+
{
20+
Assert.False(true, "Entry.Fetch is not match with expected result.");
21+
}
22+
else
23+
{
24+
Assert.True(true);
25+
}
26+
}
27+
28+
[Fact]
29+
public async Task SyncSyncType()
30+
{
31+
32+
var result = await client.SyncRecursive(SyncType: Models.SyncType.asset_published);
33+
34+
if (result == null)
35+
{
36+
Assert.False(true, "Entry.Fetch is not match with expected result.");
37+
}
38+
else
39+
{
40+
Assert.True(true);
41+
}
42+
}
43+
[Fact]
44+
public async Task SyncContentType()
45+
{
46+
47+
var result = await client.SyncRecursive(ContentTypeUid: "session");
48+
49+
if (result == null)
50+
{
51+
Assert.False(true, "Entry.Fetch is not match with expected result.");
52+
}
53+
else
54+
{
55+
Assert.True(true);
56+
}
57+
}
58+
[Fact]
59+
public async Task SyncStartFrom()
60+
{
61+
62+
var result = await client.SyncRecursive(StartFrom:DateTime.Now);
63+
64+
if (result == null)
65+
{
66+
Assert.False(true, "Entry.Fetch is not match with expected result.");
67+
}
68+
else
69+
{
70+
Assert.True(true);
71+
}
72+
}
73+
[Fact]
74+
public async Task SyncTypeWithContentType()
75+
{
76+
77+
var result = await client.SyncRecursive(SyncType: Models.SyncType.entry_published, ContentTypeUid: "session");
78+
79+
if (result == null)
80+
{
81+
Assert.False(true, "Entry.Fetch is not match with expected result.");
82+
}
83+
else
84+
{
85+
Assert.True(true);
86+
}
87+
}
88+
[Fact]
89+
public async Task SyncTypeWithStartFrom()
90+
{
91+
92+
var result = await client.SyncRecursive(SyncType: Models.SyncType.entry_published, StartFrom:DateTime.Now);
93+
94+
if (result == null)
95+
{
96+
Assert.False(true, "Entry.Fetch is not match with expected result.");
97+
}
98+
else
99+
{
100+
Assert.True(true);
101+
}
102+
}
103+
104+
[Fact]
105+
public async Task SyncPaginationToken()
106+
{
107+
108+
var result = await client.SyncPaginationToken("***REMOVED***");
109+
110+
if (result == null)
111+
{
112+
Assert.False(true, "Entry.Fetch is not match with expected result.");
113+
}
114+
else
115+
{
116+
Assert.True(true);
117+
}
118+
}
119+
120+
[Fact]
121+
public async Task SyncToken()
122+
{
123+
124+
var result = await client.SyncToken("***REMOVED***");
125+
126+
if (result == null)
127+
{
128+
Assert.False(true, "Entry.Fetch is not match with expected result.");
129+
}
130+
else
131+
{
132+
Assert.True(true);
133+
}
134+
}
135+
}
136+
}

Contentstack.Core/Configuration/ContentstackOptions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,14 @@ public class ContentstackOptions
2121
/// </summary>
2222
public string Environment { get; set; }
2323

24+
/// <summary>
25+
/// The Host used to set host url for the ContentStack API.
26+
/// </summary>
27+
public string Host { get; set; }
28+
29+
/// <summary>
30+
/// The Version number for the ContentStack API.
31+
/// </summary>
32+
public string Version { get; set; }
2433
}
2534
}

Contentstack.Core/Contentstack.Core.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
<PackageId>contentstack.csharp</PackageId>
66
<Authors>Contentstack</Authors>
77
<Description>.NET SDK for the Contentstack Content Delivery API.</Description>
8-
<PackageVersion>1.0.6</PackageVersion>
8+
<PackageVersion>1.1.0</PackageVersion>
99
<Owners>Contentstack</Owners>
10-
<PackageReleaseNotes>Localization support for Query and Entry is added.</PackageReleaseNotes>
11-
<ReleaseVersion>0.0.1</ReleaseVersion>
10+
<PackageReleaseNotes>Fetching Content-Type schema
11+
Stack Sync implemented </PackageReleaseNotes>
12+
<ReleaseVersion>1.1.0</ReleaseVersion>
13+
<Copyright>Copyright © 2012-2019 Contentstack. All Rights Reserved
14+
</Copyright>
15+
<PackOnBuild>true</PackOnBuild>
16+
<PackageTags>v1.1.0</PackageTags>
1217
</PropertyGroup>
1318

1419
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -40,6 +45,7 @@
4045
<None Remove="contentstack.csharp.1.0.3-alpha.nupkg" />
4146
<None Remove="contentstack.csharp.1.0.4-alpha.nupkg" />
4247
<None Remove="contentstack.csharp.1.0.5-alpha.nupkg" />
48+
<None Remove="contentstack.csharp.1.0.6.nupkg" />
4349
</ItemGroup>
4450
<ItemGroup>
4551
<Compile Remove="Properties\AssemblyInfo.cs" />

0 commit comments

Comments
 (0)