Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/Resend/Automation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// Full automation resource including graph details.
/// </summary>
public class Automation
{
/// <summary>
/// Object type discriminator.
/// </summary>
[JsonPropertyName( "object" )]
public string Object { get; set; } = default!;

/// <summary>
/// Automation identifier.
/// </summary>
[JsonPropertyName( "id" )]
public Guid Id { get; set; }

/// <summary>
/// Display name.
/// </summary>
[JsonPropertyName( "name" )]
public string Name { get; set; } = default!;

/// <summary>
/// Either <c>enabled</c> or <c>disabled</c>.
/// </summary>
[JsonPropertyName( "status" )]
public string Status { get; set; } = default!;

/// <summary>
/// When the automation was created.
/// </summary>
[JsonPropertyName( "created_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime MomentCreated { get; set; }

/// <summary>
/// When the automation was last updated.
/// </summary>
[JsonPropertyName( "updated_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime MomentUpdated { get; set; }

/// <summary>
/// Steps in execution order as stored by the API.
/// </summary>
[JsonPropertyName( "steps" )]
public List<AutomationStep> Steps { get; set; } = default!;

/// <summary>
/// Edges connecting steps.
/// </summary>
[JsonPropertyName( "edges" )]
public List<AutomationEdge> Edges { get; set; } = default!;
}
34 changes: 34 additions & 0 deletions src/Resend/AutomationCreateData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// Request body to create an automation.
/// </summary>
public class AutomationCreateData
{
/// <summary>
/// Display name.
/// </summary>
[JsonPropertyName( "name" )]
public string Name { get; set; } = default!;

/// <summary>
/// Either <c>enabled</c> or <c>disabled</c>. Defaults to <c>disabled</c> when omitted.
/// </summary>
[JsonPropertyName( "status" )]
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
public string? Status { get; set; }

/// <summary>
/// Steps; must include at least one trigger step.
/// </summary>
[JsonPropertyName( "steps" )]
public List<AutomationStepData> Steps { get; set; } = default!;

/// <summary>
/// Edges between steps (may be empty for single-step automations).
/// </summary>
[JsonPropertyName( "edges" )]
public List<AutomationEdge> Edges { get; set; } = default!;
}
27 changes: 27 additions & 0 deletions src/Resend/AutomationDeleteResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// Response from deleting an automation.
/// </summary>
public class AutomationDeleteResult
{
/// <summary>
/// Object type discriminator.
/// </summary>
[JsonPropertyName( "object" )]
public string Object { get; set; } = default!;

/// <summary>
/// Automation identifier.
/// </summary>
[JsonPropertyName( "id" )]
public Guid Id { get; set; }

/// <summary>
/// Whether the automation was deleted.
/// </summary>
[JsonPropertyName( "deleted" )]
public bool Deleted { get; set; }
}
32 changes: 32 additions & 0 deletions src/Resend/AutomationEdge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// Connection between two automation steps.
/// </summary>
/// <remarks>
/// On create and update, <see cref="From"/> and <see cref="To"/> are step refs.
/// On retrieve, they are internal step identifiers.
/// </remarks>
public class AutomationEdge
{
/// <summary>
/// Source step ref or internal id.
/// </summary>
[JsonPropertyName( "from" )]
public string From { get; set; } = default!;

/// <summary>
/// Destination step ref or internal id.
/// </summary>
[JsonPropertyName( "to" )]
public string To { get; set; } = default!;

/// <summary>
/// Edge kind: <c>default</c>, <c>condition_met</c>, <c>condition_not_met</c>, <c>timeout</c>, <c>event_received</c>.
/// </summary>
[JsonPropertyName( "edge_type" )]
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
public string? EdgeType { get; set; }
}
15 changes: 15 additions & 0 deletions src/Resend/AutomationListQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// Query parameters for <see cref="IResend.AutomationListAsync"/>.
/// </summary>
public class AutomationListQuery : PaginatedQuery
{
/// <summary>
/// Filter by <c>enabled</c> or <c>disabled</c>.
/// </summary>
[JsonIgnore]
public string? Status { get; set; }
}
54 changes: 54 additions & 0 deletions src/Resend/AutomationRun.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// A single automation run with per-step execution details.
/// </summary>
public class AutomationRun
{
/// <summary>
/// Object type discriminator.
/// </summary>
[JsonPropertyName( "object" )]
public string Object { get; set; } = default!;

/// <summary>
/// Run identifier.
/// </summary>
[JsonPropertyName( "id" )]
public Guid Id { get; set; }

/// <summary>
/// Run status.
/// </summary>
[JsonPropertyName( "status" )]
public string Status { get; set; } = default!;

/// <summary>
/// When the run started.
/// </summary>
[JsonPropertyName( "started_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime MomentStarted { get; set; }

/// <summary>
/// When the run finished, if applicable.
/// </summary>
[JsonPropertyName( "completed_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime? MomentCompleted { get; set; }

/// <summary>
/// When the run record was created.
/// </summary>
[JsonPropertyName( "created_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime MomentCreated { get; set; }

/// <summary>
/// Per-step execution details.
/// </summary>
[JsonPropertyName( "steps" )]
public List<AutomationRunStep> Steps { get; set; } = default!;
}
15 changes: 15 additions & 0 deletions src/Resend/AutomationRunListQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// Query parameters for <see cref="IResend.AutomationRunListAsync"/>.
/// </summary>
public class AutomationRunListQuery : PaginatedQuery
{
/// <summary>
/// Comma-separated run statuses: <c>running</c>, <c>completed</c>, <c>failed</c>, <c>cancelled</c>.
/// </summary>
[JsonIgnore]
public string? Status { get; set; }
}
57 changes: 57 additions & 0 deletions src/Resend/AutomationRunStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// Execution record for one step within an automation run.
/// </summary>
public class AutomationRunStep
{
/// <summary>
/// Step type.
/// </summary>
[JsonPropertyName( "type" )]
public string Type { get; set; } = default!;

/// <summary>
/// Step execution status.
/// </summary>
[JsonPropertyName( "status" )]
public string Status { get; set; } = default!;

/// <summary>
/// When the step started.
/// </summary>
[JsonPropertyName( "started_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime MomentStarted { get; set; }

/// <summary>
/// When the step finished, if applicable.
/// </summary>
[JsonPropertyName( "completed_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime? MomentCompleted { get; set; }

/// <summary>
/// Step output payload when present.
/// </summary>
[JsonPropertyName( "output" )]
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
public JsonElement? Output { get; set; }

/// <summary>
/// Error details when the step failed.
/// </summary>
[JsonPropertyName( "error" )]
[JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )]
public JsonElement? Error { get; set; }

/// <summary>
/// When the step record was created.
/// </summary>
[JsonPropertyName( "created_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime MomentCreated { get; set; }
}
42 changes: 42 additions & 0 deletions src/Resend/AutomationRunSummary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// A single automation run in a list response.
/// </summary>
public class AutomationRunSummary
{
/// <summary>
/// Run identifier.
/// </summary>
[JsonPropertyName( "id" )]
public Guid Id { get; set; }

/// <summary>
/// Run status.
/// </summary>
[JsonPropertyName( "status" )]
public string Status { get; set; } = default!;

/// <summary>
/// When the run started.
/// </summary>
[JsonPropertyName( "started_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime MomentStarted { get; set; }

/// <summary>
/// When the run finished, if applicable.
/// </summary>
[JsonPropertyName( "completed_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime? MomentCompleted { get; set; }

/// <summary>
/// When the run record was created.
/// </summary>
[JsonPropertyName( "created_at" )]
[JsonConverter( typeof( JsonUtcDateTimeConverter ) )]
public DateTime MomentCreated { get; set; }
}
22 changes: 22 additions & 0 deletions src/Resend/AutomationStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// A step returned when retrieving an automation (responses omit per-step <c>ref</c>).
/// </summary>
public class AutomationStep
{
/// <summary>
/// Step type.
/// </summary>
[JsonPropertyName( "type" )]
public string Type { get; set; } = default!;

/// <summary>
/// Step configuration; shape depends on <see cref="Type"/>.
/// </summary>
[JsonPropertyName( "config" )]
public JsonElement Config { get; set; }
}
28 changes: 28 additions & 0 deletions src/Resend/AutomationStepData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Resend;

/// <summary>
/// A step in an automation graph for create and update requests.
/// </summary>
public class AutomationStepData
{
/// <summary>
/// Unique reference for this step, used by <see cref="AutomationEdge.From"/> and <see cref="AutomationEdge.To"/>.
/// </summary>
[JsonPropertyName( "key" )]
public string Ref { get; set; } = default!;

/// <summary>
/// Step type (for example <c>trigger</c>, <c>send_email</c>, <c>delay</c>).
/// </summary>
[JsonPropertyName( "type" )]
public string Type { get; set; } = default!;

/// <summary>
/// Step configuration; shape depends on <see cref="Type"/>.
/// </summary>
[JsonPropertyName( "config" )]
public JsonElement Config { get; set; }
}
Loading
Loading