-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2045fe
commit 9149af7
Showing
2 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Kontent.Ai.Urls/Delivery/QueryParameters/ExcludeParameter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Kontent.Ai.Delivery.Abstractions; | ||
|
||
namespace Kontent.Ai.Urls.Delivery.QueryParameters | ||
{ | ||
/// <summary> | ||
/// Specifies the content elements to exclude from response. | ||
/// </summary> | ||
public sealed class ExcludeParameter : IQueryParameter | ||
{ | ||
/// <summary> | ||
/// Gets the list of codenames of content elements that should be excluded from response. | ||
/// </summary> | ||
public IReadOnlyList<string> ElementCodenames { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ExcludeParameter"/> class using the specified content elements codenames. | ||
/// </summary> | ||
/// <param name="elementCodenames">An array that contains zero or more codenames of the content elements that should be excluded from response.</param> | ||
public ExcludeParameter(params string[] elementCodenames) | ||
{ | ||
ElementCodenames = elementCodenames.ToList().AsReadOnly(); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the query string representation of the query parameter. | ||
/// </summary> | ||
public string GetQueryStringParameter() | ||
{ | ||
return $"exclude={string.Join(Uri.EscapeDataString(","), ElementCodenames.Select(Uri.EscapeDataString))}"; | ||
} | ||
} | ||
} |