Skip to content

Commit

Permalink
Updated entities based on latest GraphQL schema (2023-04-08)
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasvandeweerdt committed Apr 10, 2023
1 parent 9012310 commit e06ee5f
Show file tree
Hide file tree
Showing 15 changed files with 456 additions and 37 deletions.
22 changes: 22 additions & 0 deletions Scr/Sdk4me.GraphQL.Tests/KnowledgeArticleTemplateTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Sdk4me.GraphQL.Tests
{
[TestClass]
public class KnowledgeArticleTemplateTest
{
private readonly Sdk4meClient client = Client.Get();

[TestMethod]
public void Get()
{
DataList<KnowledgeArticleTemplate> knowledgeArticleTemplates = client.Get(Query.KnowledgeArticleTemplate
.View(KnowledgeArticleTemplateView.All)
.SelectAll()
.SelectServiceInstances(new ServiceInstanceQuery()
.SelectAll())
).Result;

Assert.IsNotNull(knowledgeArticleTemplates);
Console.WriteLine($"Count: {knowledgeArticleTemplates.Count}");
}
}
}
2 changes: 2 additions & 0 deletions Scr/Sdk4me.GraphQL.Tests/KnowledgeArticleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public void Get()
DataList<KnowledgeArticle> knowledgeArticles = client.Get(Query.KnowledgeArticle
.View(KnowledgeArticleView.All)
.SelectAll()
.SelectCustomFieldsAttachments(new AttachmentQuery()
.SelectAll())
.SelectDescriptionAttachments(new AttachmentQuery()
.SelectAll())
.SelectInstructionsAttachments(new AttachmentQuery()
Expand Down
2 changes: 1 addition & 1 deletion Scr/Sdk4me.GraphQL.Tests/NoteTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void AddNote()
{
Text = "Hello World !!!",
Internal = true,
OwnerId = "NG1lMjQuMjMwMzE5MjI1MDU5QDRtZS1kZW1vLmNvbS9SZXEvNzA1MzE"
OwnerId = "NG1lMjQuMjMwNDEwMDAyODU3QDRtZS1kZW1vLmNvbS9SZXEvNzA1MzE"
}
).Result;

Expand Down
27 changes: 26 additions & 1 deletion Scr/Sdk4me.GraphQL/Entities/KnowledgeArticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ public class KnowledgeArticle : Node
[JsonProperty("createdBy")]
public Person? CreatedBy { get; internal set; }

/// <summary>
/// Values of custom fields.
/// </summary>
[JsonProperty("customFields")]
public CustomFieldCollection? CustomFields { get; internal set; }

[JsonProperty("customFieldsAttachments")]
internal NodeCollection<Attachment>? CustomFieldsAttachmentsCollection { get; set; }

/// <summary>
/// Inline images linked to one of the custom fields.
/// </summary>
public DataList<Attachment>? CustomFieldsAttachments
{
get => CustomFieldsAttachmentsCollection?.Data;
}

/// <summary>
/// Describes the situation and/or environment in which the instructions of the knowledge article may be helpful.
/// </summary>
Expand Down Expand Up @@ -120,7 +137,7 @@ public DataList<Request>? Requests
internal NodeCollection<ServiceInstance>? ServiceInstancesCollection { get; set; }

/// <summary>
/// Services linked to this knowledge article.
/// Service instances linked to this knowledge article.
/// </summary>
public DataList<ServiceInstance>? ServiceInstances
{
Expand Down Expand Up @@ -151,6 +168,12 @@ public DataList<ServiceInstance>? ServiceInstances
[JsonProperty("subject"), Sdk4meField(true)]
public string? Subject { get; internal set; }

/// <summary>
/// The knowledge article template that this knowledge article is based on.
/// </summary>
[JsonProperty("template")]
public KnowledgeArticleTemplate? Template { get; internal set; }

[JsonProperty("translations")]
internal NodeCollection<Translation>? TranslationsCollection { get; set; }

Expand All @@ -177,6 +200,7 @@ public DataList<Translation>? Translations
internal override HashSet<QueryPageInfo> GetQueryPageInfo(string fieldName, int depth)
{
HashSet<QueryPageInfo> retval = new();
retval.AddRange(CustomFieldsAttachmentsCollection?.GetQueryPageInfo("customFieldsAttachments", depth + 1));
retval.AddRange(DescriptionAttachmentsCollection?.GetQueryPageInfo("descriptionAttachments", depth + 1));
retval.AddRange(InstructionsAttachmentsCollection?.GetQueryPageInfo("instructionsAttachments", depth + 1));
retval.AddRange(RequestsCollection?.GetQueryPageInfo("requests", depth + 1));
Expand All @@ -187,6 +211,7 @@ internal override HashSet<QueryPageInfo> GetQueryPageInfo(string fieldName, int

internal override void AddToCollection(object data)
{
CustomFieldsAttachments?.AddRange((data as KnowledgeArticle)?.CustomFieldsAttachments);
DescriptionAttachments?.AddRange((data as KnowledgeArticle)?.DescriptionAttachments);
InstructionsAttachments?.AddRange((data as KnowledgeArticle)?.InstructionsAttachments);
Requests?.AddRange((data as KnowledgeArticle)?.Requests);
Expand Down
67 changes: 50 additions & 17 deletions Scr/Sdk4me.GraphQL/Entities/KnowledgeArticleCreateInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class KnowledgeArticleCreateInput : PropertyChangeSet
{
private string? source;
private string? sourceID;
private CustomFieldCollection? customFields;
private List<AttachmentInput>? customFieldsAttachments;
private DateOnly? archiveDate;
private bool? coveredSpecialists;
private string? createdById;
private string? description;
Expand All @@ -17,10 +20,10 @@ public class KnowledgeArticleCreateInput : PropertyChangeSet
private bool? keyContacts;
private string? keywords;
private string? serviceId;
private List<string>? serviceInstanceIds;
private KnowledgeArticleStatus? status;
private string? subject;
private DateOnly? archiveDate;
private List<string>? serviceInstanceIds;
private string? templateId;
private string? clientMutationId;

/// <summary>
Expand All @@ -43,6 +46,36 @@ public string? SourceID
set => sourceID = Set("sourceID", value);
}

/// <summary>
/// Values for custom fields to be used by the UI Extension that is linked to the record.
/// </summary>
[JsonProperty("customFields")]
public CustomFieldCollection? CustomFields
{
get => customFields;
set => customFields = Set("customFields", value);
}

/// <summary>
/// The attachments used in the custom fields' values.
/// </summary>
[JsonProperty("customFieldsAttachments")]
public List<AttachmentInput>? CustomFieldsAttachments
{
get => customFieldsAttachments;
set => customFieldsAttachments = Set("customFieldsAttachments", value);
}

/// <summary>
/// The date until which the knowledge article will be active. The knowledge article will be archived at the beginning of this day. When the knowledge article is archived, its status will automatically be set to "Archived".
/// </summary>
[JsonProperty("archiveDate")]
public DateOnly? ArchiveDate
{
get => archiveDate;
set => archiveDate = Set("archiveDate", value);
}

/// <summary>
/// Whether the knowledge article needs to be available to the people who are a member of the support team of one of the service instances that are selected in the Coverage section of an active SLA for the service that is linked to the article.
/// </summary>
Expand Down Expand Up @@ -143,6 +176,16 @@ public string? ServiceId
set => serviceId = Set("serviceId", value);
}

/// <summary>
/// Identifiers of service instances linked to this knowledge article.
/// </summary>
[JsonProperty("serviceInstanceIds")]
public List<string>? ServiceInstanceIds
{
get => serviceInstanceIds;
set => serviceInstanceIds = Set("serviceInstanceIds", value);
}

/// <summary>
/// The current status of the knowledge article.
/// </summary>
Expand All @@ -164,23 +207,13 @@ public string? Subject
}

/// <summary>
/// The date until which the knowledge article will be active. The knowledge article will be archived at the beginning of this day. When the knowledge article is archived, its status will automatically be set to "Archived".
/// Identifier of the knowledge article template that this knowledge article is based on.
/// </summary>
[JsonProperty("archiveDate")]
public DateOnly? ArchiveDate
[JsonProperty("templateId")]
public string? TemplateId
{
get => archiveDate;
set => archiveDate = Set("archiveDate", value);
}

/// <summary>
/// Identifiers of services linked to this knowledge article.
/// </summary>
[JsonProperty("serviceInstanceIds")]
public List<string>? ServiceInstanceIds
{
get => serviceInstanceIds;
set => serviceInstanceIds = Set("serviceInstanceIds", value);
get => templateId;
set => templateId = Set("templateId", value);
}

/// <summary>
Expand Down
85 changes: 85 additions & 0 deletions Scr/Sdk4me.GraphQL/Entities/KnowledgeArticleTemplate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
namespace Sdk4me.GraphQL
{
/// <summary>
/// The <see href="https://developer.4me.com/graphql/object/knowledgearticletemplate/">KnowledgeArticleTemplate</see> object.
/// </summary>
public class KnowledgeArticleTemplate : Node
{
/// <summary>
/// The account this record belongs to.
/// </summary>
[JsonProperty("account"), Sdk4meField(true)]
public Account? Account { get; internal set; }

/// <summary>
/// The date and time at which the record was created.
/// </summary>
[JsonProperty("createdAt"), Sdk4meField(true)]
public DateTime? CreatedAt { get; internal set; }

/// <summary>
/// Whether the knowledge article template may no longer be used to create knowledge articles.
/// </summary>
[JsonProperty("disabled"), Sdk4meField(true)]
public bool? Disabled { get; internal set; }

/// <summary>
/// Service that is applied to knowledge articles using this template.
/// </summary>
[JsonProperty("service"), Sdk4meField(true)]
public Service? Service { get; internal set; }

[JsonProperty("serviceInstances")]
internal NodeCollection<ServiceInstance>? ServiceInstancesCollection { get; set; }

/// <summary>
/// Service instances that are applied to knowledge articles using this template.
/// </summary>
public DataList<ServiceInstance>? ServiceInstances
{
get => ServiceInstancesCollection?.Data;
}

/// <summary>
/// An identifier for the client application submitting the resource or the name of an external system.
/// </summary>
[JsonProperty("source"), Sdk4meField(true)]
public string? Source { get; internal set; }

/// <summary>
/// The unique identifier of the resource in an external system.
/// </summary>
[JsonProperty("sourceID"), Sdk4meField(true)]
public string? SourceID { get; internal set; }

/// <summary>
/// A short description of the knowledge article template.
/// </summary>
[JsonProperty("subject"), Sdk4meField(true)]
public string? Subject { get; internal set; }

/// <summary>
/// The UI extension that is applied to knowledge articles using this template.
/// </summary>
[JsonProperty("uiExtension")]
public UiExtension? UiExtension { get; internal set; }

/// <summary>
/// The date and time of the last update of the record. If the record has no updates it contains the <c>createdAt</c> value.
/// </summary>
[JsonProperty("updatedAt"), Sdk4meField(true)]
public DateTime? UpdatedAt { get; internal set; }

internal override HashSet<QueryPageInfo> GetQueryPageInfo(string fieldName, int depth)
{
HashSet<QueryPageInfo> retval = new();
retval.AddRange(ServiceInstancesCollection?.GetQueryPageInfo("serviceInstances", depth + 1));
return retval;
}

internal override void AddToCollection(object data)
{
ServiceInstances?.AddRange((data as KnowledgeArticleTemplate)?.ServiceInstances);
}
}
}
Loading

0 comments on commit e06ee5f

Please sign in to comment.