Skip to content

Commit

Permalink
Updated entities based on latest GraphQL schema (2023-05-20)
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasvandeweerdt committed May 21, 2023
1 parent 7ef809b commit e3f5fa2
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Scr/Sdk4me.GraphQL.Tests/SyncSetTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Sdk4me.GraphQL.Tests
{
[TestClass]
public class SyncSetTest
{
private readonly Sdk4meClient client = Client.Get();

[TestMethod]
public void Get()
{
DataList<SyncSet> syncSets = client.Get(Query.SyncSet
.View(DefaultView.None)
.SelectAll()
.SelectDescriptionAttachments(new AttachmentQuery()
.SelectAll())
).Result;

Assert.IsNotNull(syncSets);
Console.WriteLine($"Count: {syncSets.Count}");
}
}
}
50 changes: 50 additions & 0 deletions Scr/Sdk4me.GraphQL/Entities/Snapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Diagnostics;

namespace Sdk4me.GraphQL
{
/// <summary>
/// The <see href="https://developer.4me.com/graphql/object/snapshot/">Snapshot</see> object.
/// </summary>
[Sdk4meEntity(ignoreIdentifier: true)]
public class Snapshot : Node
{
/// <summary>
/// The display debugger value.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
internal override string? DebuggerValue
{
get => ToString();
}

/// <summary>
/// The unique identifier used by <see cref="DataList{T}"/>.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
internal override string UniqueIdentifier
{
get => GetHashCode().ToString();
}

/// <summary>
/// Expiring link to the snapshot content.
/// </summary>
[JsonProperty("downloadUrl")]
public string? DownloadUrl { get; internal set; }

/// <summary>
/// Time at which snapshot was taken.
/// </summary>
[JsonProperty("startedAt")]
public DateTime? StartedAt { get; internal set; }

internal override HashSet<QueryPageInfo> GetQueryPageInfo(string fieldName, int depth)
{
return new HashSet<QueryPageInfo>();
}

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

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

/// <summary>
/// Description of the sync set.
/// </summary>
[JsonProperty("description")]
public string? Description { get; internal set; }

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

/// <summary>
/// Files and inline images linked to the <c>description</c> field.
/// </summary>
public DataList<Attachment>? DescriptionAttachments
{
get => DescriptionAttachmentsCollection?.Data;
}

/// <summary>
/// The latest completed snapshot of this sync set.
/// </summary>
[JsonProperty("lastSnapshot")]
public Snapshot? LastSnapshot { get; internal set; }

/// <summary>
/// The name of the sync set.
/// </summary>
[JsonProperty("name")]
public string? Name { get; internal set; }

/// <summary>
/// Record types included in the sync set. The types match the values supported for the <see href="https://developer.4me.com/v1/import/#parameters"><c>type</c> parameter of CSV import</see>.
/// </summary>
[JsonProperty("types")]
public List<string>? Types { 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")]
public DateTime? UpdatedAt { get; internal set; }

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

internal override void AddToCollection(object data)
{
DescriptionAttachments?.AddRange((data as SyncSet)?.DescriptionAttachments);
}
}
}
10 changes: 10 additions & 0 deletions Scr/Sdk4me.GraphQL/Enumerators/Enumerators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,16 @@ public enum PermissionRole
[EnumMember(Value = "specialist")]
Specialist,
/// <summary>
/// Workflow automator auditor.
/// </summary>
[EnumMember(Value = "workflow_automator_auditor")]
WorkflowAutomatorAuditor,
/// <summary>
/// Workflow automator specialist.
/// </summary>
[EnumMember(Value = "workflow_automator_specialist")]
WorkflowAutomatorSpecialist,
/// <summary>
/// Workflow manager.
/// </summary>
[EnumMember(Value = "workflow_manager")]
Expand Down
69 changes: 69 additions & 0 deletions Scr/Sdk4me.GraphQL/Enumerators/FieldEnumerators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8048,6 +8048,23 @@ public enum SlaNotificationSchemeField
UpdatedAt,
}

/// <summary>
/// The <see cref="Snapshot">Snapshot</see> fields.
/// </summary>
public enum SnapshotField
{
/// <summary>
/// The download url field.
/// </summary>
[EnumMember(Value = "downloadUrl")]
DownloadUrl,
/// <summary>
/// The started at field.
/// </summary>
[EnumMember(Value = "startedAt")]
StartedAt,
}

/// <summary>
/// The <see cref="Sprint">Sprint</see> fields.
/// </summary>
Expand Down Expand Up @@ -8579,6 +8596,58 @@ public enum SurveyResponseField
UpdatedAt,
}

/// <summary>
/// The <see cref="SyncSet">SyncSet</see> fields.
/// </summary>
public enum SyncSetField
{
/// <summary>
/// The account field.
/// </summary>
[EnumMember(Value = "account")]
Account,
/// <summary>
/// The created at field.
/// </summary>
[EnumMember(Value = "createdAt")]
CreatedAt,
/// <summary>
/// The description field.
/// </summary>
[EnumMember(Value = "description")]
Description,
/// <summary>
/// The description attachments field.
/// </summary>
[EnumMember(Value = "descriptionAttachments")]
DescriptionAttachments,
/// <summary>
/// The id field.
/// </summary>
[EnumMember(Value = "id")]
ID,
/// <summary>
/// The last snapshot field.
/// </summary>
[EnumMember(Value = "lastSnapshot")]
LastSnapshot,
/// <summary>
/// The name field.
/// </summary>
[EnumMember(Value = "name")]
Name,
/// <summary>
/// The types field.
/// </summary>
[EnumMember(Value = "types")]
Types,
/// <summary>
/// The updated at field.
/// </summary>
[EnumMember(Value = "updatedAt")]
UpdatedAt,
}

/// <summary>
/// The <see cref="Task">Task</see> fields.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions Scr/Sdk4me.GraphQL/Extensions/Sdk4meClientQueryExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,18 @@ public static async Task<DataList<Survey>> Get(this Sdk4meClient client, SurveyQ
return await client.Get<Survey>(query);
}

/// <summary>
/// Root connection for retrieving SyncSet records.
/// </summary>
/// <param name="client">The <see cref="Sdk4meClient"/>.</param>
/// <param name="query">The query to execute.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
/// <exception cref="Sdk4meException"></exception>
public static async Task<DataList<SyncSet>> Get(this Sdk4meClient client, SyncSetQuery query)
{
return await client.Get<SyncSet>(query);
}

/// <summary>
/// Root connection for retrieving TaskTemplate records.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions Scr/Sdk4me.GraphQL/Queries/Queries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ public sealed class Query
/// </summary>
public static SurveyQuery Survey => new();

/// <summary>
/// Returns a new instance of the <see cref="SyncSet"/> with a default field selection.
/// </summary>
public static SyncSetQuery SyncSet => new();

/// <summary>
/// Returns a new instance of the <see cref="TaskTemplate"/> with a default field selection.
/// </summary>
Expand Down
25 changes: 25 additions & 0 deletions Scr/Sdk4me.GraphQL/Queries/SyncSetQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Sdk4me.GraphQL
{
/// <summary>
/// Root connection for retrieving SyncSet records.
/// </summary>
public class SyncSetQuery : Query<SyncSetQuery, SyncSetField, DefaultView, DefaultOrderField>
{
/// <summary>
/// Initialize a new sync set query instance.
/// </summary>
public SyncSetQuery()
: base("syncSets", typeof(SyncSet), true)
{
}

/// <summary>
/// Files and inline images linked to the <c>description</c> field.
/// </summary>
public SyncSetQuery SelectDescriptionAttachments(AttachmentQuery query)
{
query.FieldName = "descriptionAttachments";
return Select(query);
}
}
}

0 comments on commit e3f5fa2

Please sign in to comment.