-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented models for events and webhooks
- Loading branch information
Showing
5 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ namespace Close.Models.Common; | |
|
||
public enum ObjectType | ||
{ | ||
lead, | ||
emailthread, | ||
call, | ||
opportunity, | ||
|
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,53 @@ | ||
using System.Text.Json.Serialization; | ||
using Close.Models.Common; | ||
using Close.Services.Interfaces; | ||
|
||
namespace Close.Models.Events; | ||
|
||
public class Event<TEntity> : ICloseEntity where TEntity : ICloseEntity | ||
{ | ||
[JsonPropertyName("action")] | ||
public EventAction Action { get; set; } | ||
|
||
[JsonPropertyName("id")] | ||
public string Id { get; set; } | ||
|
||
[JsonPropertyName("api_key_id")] | ||
public string ApiKeyId { get; set; } | ||
|
||
[JsonPropertyName("changed_fields")] | ||
public List<string> ChangedFields { get; set; } | ||
|
||
[JsonPropertyName("data")] | ||
public TEntity Data { get; set; } | ||
|
||
[JsonPropertyName("previous_data")] | ||
public TEntity PreviousData { get; set; } | ||
|
||
[JsonPropertyName("lead_id")] | ||
public string LeadId { get; set; } | ||
|
||
[JsonPropertyName("meta")] | ||
public EventMetaData Meta { get; set; } | ||
|
||
[JsonPropertyName("object_id")] | ||
public string ObjectId { get; set; } | ||
|
||
[JsonPropertyName("object_type")] | ||
public ObjectType ObjectType { get; set; } | ||
|
||
[JsonPropertyName("request_id")] | ||
public string RequestId { get; set; } | ||
|
||
[JsonPropertyName("user_id")] | ||
public string UserId { get; set; } | ||
|
||
[JsonPropertyName("organization_id")] | ||
public string OrganizationId { get; set; } | ||
|
||
[JsonPropertyName("date_created")] | ||
public DateTimeOffset DateCreated { get; set; } | ||
|
||
[JsonPropertyName("date_updated")] | ||
public DateTimeOffset? DateUpdated { get; set; } | ||
} |
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,8 @@ | ||
namespace Close.Models.Events; | ||
|
||
public enum EventAction | ||
{ | ||
created, | ||
updated, | ||
deleted | ||
} |
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,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Close.Models.Events; | ||
|
||
public class EventMetaData | ||
{ | ||
[JsonPropertyName("request_method")] | ||
public string RequestMethod { get; set; } | ||
|
||
[JsonPropertyName("request_path")] | ||
public string RequestPath { get; set; } | ||
} |
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,14 @@ | ||
using System.Text.Json.Serialization; | ||
using Close.Models.Events; | ||
using Close.Services.Interfaces; | ||
|
||
namespace Close.Models.Webhooks; | ||
|
||
public class Webhook<TEntity> where TEntity : ICloseEntity | ||
{ | ||
[JsonPropertyName("subscription_id")] | ||
public string SubscriptionId { get; set; } | ||
|
||
[JsonPropertyName("event")] | ||
public Event<TEntity> Event { get; set; } | ||
} |