Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4d67ea2

Browse files
authoredNov 1, 2019
Merge pull request #190 from contentful/fix/content-types-limits
Fix/content types limits
2 parents e4a0e5e + 5fd1f01 commit 4d67ea2

7 files changed

+94
-12
lines changed
 

‎Contentful.AspNetCore/Contentful.AspNetCore.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<PackageProjectUrl>https://github.com/contentful/contentful.net</PackageProjectUrl>
1414
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1515
<RepositoryType>git</RepositoryType>
16-
<Version>4.2.0</Version>
17-
<AssemblyVersion>4.2.0.0</AssemblyVersion>
16+
<Version>4.3.0</Version>
17+
<AssemblyVersion>4.3.0.0</AssemblyVersion>
1818
<RepositoryUrl>https://github.com/contentful/contentful.net</RepositoryUrl>
1919
</PropertyGroup>
2020
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@@ -24,7 +24,7 @@
2424
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2525
</PropertyGroup>
2626
<ItemGroup>
27-
<PackageReference Include="contentful.csharp" Version="4.1.1" />
27+
<PackageReference Include="contentful.csharp" Version="4.3.0" />
2828
<PackageReference Include="gitlink" Version="3.1.0">
2929
<PrivateAssets>all</PrivateAssets>
3030
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

‎Contentful.Core.Tests/ContentfulManagementClientTests.cs

+25-3
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public async Task GetActivatedContentTypesShouldSerializeCorrectly()
425425

426426
//Assert
427427
Assert.Equal(5, res.Count());
428-
Assert.Equal($"https://api.contentful.com/spaces/666/public/content_types", requestUrl);
428+
Assert.Equal($"https://api.contentful.com/spaces/666/public/content_types/", requestUrl);
429429
Assert.Equal("someName", res.First().Name);
430430
Assert.Equal(8, (res.First().Fields.First().Validations.First() as SizeValidator).Max);
431431
Assert.Equal(8, ((res.First().Fields.Last().Validations.First() as NodesValidator).EmbeddedEntryInline.First() as SizeValidator).Max);
@@ -3078,7 +3078,29 @@ public async Task SettingEnvironmentForContentTypesShouldYieldCorrectUrl()
30783078
Assert.Equal(5, res.Count());
30793079
Assert.Equal("someName", res.First().Name);
30803080
Assert.Equal(8, (res.First().Fields.First().Validations.First() as SizeValidator).Max);
3081-
Assert.Equal("https://api.contentful.com/spaces/564/environments/special/content_types", path);
3081+
Assert.Equal("https://api.contentful.com/spaces/564/environments/special/content_types/", path);
3082+
}
3083+
3084+
[Fact]
3085+
public async Task SettingEnvironmentAndQueryContentTypesShouldYieldCorrectUrl()
3086+
{
3087+
//Arrange
3088+
_handler.Response = GetResponseFromFile(@"ContenttypesCollectionManagement.json");
3089+
var client = GetClientWithEnvironment();
3090+
var path = "";
3091+
_handler.VerifyRequest = (HttpRequestMessage request) =>
3092+
{
3093+
path = request.RequestUri.ToString();
3094+
};
3095+
3096+
//Act
3097+
var res = await client.GetContentTypes("?limit=1000", "564");
3098+
3099+
//Assert
3100+
Assert.Equal(5, res.Count());
3101+
Assert.Equal("someName", res.First().Name);
3102+
Assert.Equal(8, (res.First().Fields.First().Validations.First() as SizeValidator).Max);
3103+
Assert.Equal("https://api.contentful.com/spaces/564/environments/special/content_types/?limit=1000", path);
30823104
}
30833105

30843106
[Fact]
@@ -3198,7 +3220,7 @@ public async Task SettingEnvironmentForGetActivatedContentTypesShouldYieldCorrec
31983220
await client.GetActivatedContentTypes();
31993221

32003222
//Assert
3201-
Assert.Equal("https://api.contentful.com/spaces/564/environments/special/public/content_types", path);
3223+
Assert.Equal("https://api.contentful.com/spaces/564/environments/special/public/content_types/", path);
32023224
}
32033225

32043226
[Fact]

‎Contentful.Core/Contentful.Core.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
1919
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
2020
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
21-
<AssemblyVersion>4.2.0.0</AssemblyVersion>
22-
<FileVersion>4.2.0.0</FileVersion>
23-
<Version>4.2.0</Version>
21+
<AssemblyVersion>4.3.0.0</AssemblyVersion>
22+
<FileVersion>4.3.0.0</FileVersion>
23+
<Version>4.3.0</Version>
2424
</PropertyGroup>
2525
<ItemGroup>
2626
<PackageReference Include="gitlink" Version="3.1.0">

‎Contentful.Core/ContentfulClient.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,18 @@ public async Task<ContentType> GetContentType(string contentTypeId, Cancellation
472472
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
473473
public async Task<IEnumerable<ContentType>> GetContentTypes(CancellationToken cancellationToken = default)
474474
{
475-
var res = await Get($"{_baseUrl}{_options.SpaceId}/{EnvironmentsBase}content_types/", cancellationToken).ConfigureAwait(false);
475+
return await GetContentTypes(null, cancellationToken);
476+
}
477+
478+
/// <summary>
479+
/// Get all content types of a space.
480+
/// </summary>
481+
/// <param name="queryString">The optional querystring to add additional filtering to the query.</param>
482+
/// <param name="cancellationToken">The optional cancellation token to cancel the operation.</param>
483+
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
484+
public async Task<IEnumerable<ContentType>> GetContentTypes(string queryString, CancellationToken cancellationToken = default)
485+
{
486+
var res = await Get($"{_baseUrl}{_options.SpaceId}/{EnvironmentsBase}content_types/{queryString}", cancellationToken).ConfigureAwait(false);
476487

477488
var jsonObject = JObject.Parse(await res.Content.ReadAsStringAsync().ConfigureAwait(false));
478489
var contentTypes = jsonObject.SelectTokens("$..items[*]").Select(t => t.ToObject<ContentType>(Serializer));

‎Contentful.Core/ContentfulManagementClient.cs

+26-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,19 @@ public async Task DeleteSpace(string id, CancellationToken cancellationToken = d
167167
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
168168
public async Task<IEnumerable<ContentType>> GetContentTypes(string spaceId = null, CancellationToken cancellationToken = default)
169169
{
170-
var res = await GetAsync($"{_baseUrl}{spaceId ?? _options.SpaceId}/{EnvironmentsBase}content_types", cancellationToken).ConfigureAwait(false);
170+
return await GetContentTypes(null, spaceId, cancellationToken);
171+
}
172+
173+
/// <summary>
174+
/// Get all content types of a space.
175+
/// </summary>
176+
/// <param name="queryString">The optional querystring to add additional filtering to the query.</param>
177+
/// <param name="spaceId">The id of the space to get the content types of. Will default to the one set when creating the client.</param>
178+
/// <param name="cancellationToken">The optional cancellation token to cancel the operation.</param>
179+
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
180+
public async Task<IEnumerable<ContentType>> GetContentTypes(string queryString, string spaceId = null, CancellationToken cancellationToken = default)
181+
{
182+
var res = await GetAsync($"{_baseUrl}{spaceId ?? _options.SpaceId}/{EnvironmentsBase}content_types/{queryString}", cancellationToken).ConfigureAwait(false);
171183

172184
await EnsureSuccessfulResult(res).ConfigureAwait(false);
173185

@@ -307,7 +319,19 @@ public async Task DeactivateContentType(string contentTypeId, string spaceId = n
307319
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
308320
public async Task<IEnumerable<ContentType>> GetActivatedContentTypes(string spaceId = null, CancellationToken cancellationToken = default)
309321
{
310-
var res = await GetAsync($"{_baseUrl}{spaceId ?? _options.SpaceId}/{EnvironmentsBase}public/content_types", cancellationToken).ConfigureAwait(false);
322+
return await GetActivatedContentTypes(null, spaceId, cancellationToken);
323+
}
324+
325+
/// <summary>
326+
/// Get all activated content types of a space.
327+
/// </summary>
328+
/// <param name="queryString">The optional querystring to add additional filtering to the query.</param>
329+
/// <param name="spaceId">The id of the space to get the activated content types of. Will default to the one set when creating the client.</param>
330+
/// <param name="cancellationToken">The optional cancellation token to cancel the operation.</param>
331+
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
332+
public async Task<IEnumerable<ContentType>> GetActivatedContentTypes(string queryString, string spaceId = null, CancellationToken cancellationToken = default)
333+
{
334+
var res = await GetAsync($"{_baseUrl}{spaceId ?? _options.SpaceId}/{EnvironmentsBase}public/content_types/{queryString}", cancellationToken).ConfigureAwait(false);
311335

312336
await EnsureSuccessfulResult(res).ConfigureAwait(false);
313337

‎Contentful.Core/IContentfulClient.cs

+7
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ public interface IContentfulClient
157157
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
158158
Task<IEnumerable<ContentType>> GetContentTypes(CancellationToken cancellationToken = default);
159159

160+
/// <summary>
161+
/// Get all content types of a space.
162+
/// </summary>
163+
/// <param name="queryString">The optional querystring to add additional filtering to the query.</param>
164+
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
165+
Task<IEnumerable<ContentType>> GetContentTypes(string queryString, CancellationToken cancellationToken = default);
166+
160167
/// <summary>
161168
/// Get all locales of an environment.
162169
/// </summary>

‎Contentful.Core/IContentfulManagementClient.cs

+18
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,15 @@ public interface IContentfulManagementClient
301301
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
302302
Task<IEnumerable<ContentType>> GetActivatedContentTypes(string spaceId = null, CancellationToken cancellationToken = default);
303303

304+
/// <summary>
305+
/// Get all activated content types of a space.
306+
/// </summary>
307+
/// <param name="queryString">The optional querystring to add additional filtering to the query.</param>
308+
/// <param name="spaceId">The id of the space to get the activated content types of. Will default to the one set when creating the client.</param>
309+
/// <param name="cancellationToken">The optional cancellation token to cancel the operation.</param>
310+
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
311+
Task<IEnumerable<ContentType>> GetActivatedContentTypes(string queryString, string spaceId = null, CancellationToken cancellationToken = default);
312+
304313
/// <summary>
305314
/// Gets a collection of all <see cref="Contentful.Core.Models.Management.ApiKey"/> in a space.
306315
/// </summary>
@@ -410,6 +419,15 @@ public interface IContentfulManagementClient
410419
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
411420
Task<IEnumerable<ContentType>> GetContentTypes(string spaceId = null, CancellationToken cancellationToken = default);
412421

422+
/// <summary>
423+
/// Get all content types of a space.
424+
/// </summary>
425+
/// <param name="queryString">The optional querystring to add additional filtering to the query.</param>
426+
/// <param name="spaceId">The id of the space to get the content types of. Will default to the one set when creating the client.</param>
427+
/// <param name="cancellationToken">The optional cancellation token to cancel the operation.</param>
428+
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ContentType"/>.</returns>
429+
Task<IEnumerable<ContentType>> GetContentTypes(string queryString, string spaceId = null, CancellationToken cancellationToken = default);
430+
413431
/// <summary>
414432
/// Gets a <see cref="Contentful.Core.Models.Management.EditorInterface"/> for a specific <seealso cref="ContentType"/>.
415433
/// </summary>

0 commit comments

Comments
 (0)
Please sign in to comment.