Skip to content

Commit

Permalink
feat: add additional webhook params
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Feb 14, 2025
1 parent a78d48e commit 0aff42c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions EasyPost.Tests/ServicesTests/WebhookServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public async Task TestCreate()

string url = $"https://example.com/create/{TestUtils.NetVersion}";

// TODO: Add webhook_secret and custom_headers params
Webhook webhook = await Client.Webhook.Create(new Dictionary<string, object> { { "url", url } });
CleanUpAfterTest(webhook.Id);

Expand Down Expand Up @@ -162,6 +163,7 @@ public async Task TestUpdate()
Thread.Sleep(10000); // Wait enough time to process
}

// TODO: Add webhook_secret and custom_headers params
webhook = await Client.Webhook.Update(webhook.Id, new Dictionary<string, object>());

Assert.IsType<Webhook>(webhook);
Expand Down
2 changes: 2 additions & 0 deletions EasyPost/Parameters/Webhook/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class Create : BaseParameters<Models.API.Webhook>, IWebhookParameter
[TopLevelRequestParameter(Necessity.Required, "url")]
public string? Url { get; set; }

// TODO: Add custom_headers

#endregion
}
}
2 changes: 2 additions & 0 deletions EasyPost/Parameters/Webhook/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Update : BaseParameters<Models.API.Webhook>
[TopLevelRequestParameter(Necessity.Optional, "webhook_secret")]
public string? Secret { get; set; }

// TODO: Add custom_headers

#endregion
}
}
2 changes: 2 additions & 0 deletions EasyPost/Services/WebhookService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public async Task<Webhook> Create(Parameters.Webhook.Create parameters, Cancella
[CrudOperations.Update]
public async Task<Webhook> Update(string id, Dictionary<string, object>? parameters = null, CancellationToken cancellationToken = default)
{
parameters = parameters?.Wrap("webhook");
return await RequestAsync<Webhook>(Method.Put, $"webhooks/{id}", cancellationToken, parameters);
}

Expand All @@ -113,6 +114,7 @@ public async Task<Webhook> Update(string id, Dictionary<string, object>? paramet
[CrudOperations.Update]
public async Task<Webhook> Update(string id, Parameters.Webhook.Update? parameters = null, CancellationToken cancellationToken = default)
{
// TODO: Validate, do we need to wrap the params here too or is it implicitly done somehow?
return await RequestAsync<Webhook>(Method.Put, $"webhooks/{id}", cancellationToken, parameters?.ToDictionary());
}

Expand Down

0 comments on commit 0aff42c

Please sign in to comment.