Skip to content

Commit 0e96d04

Browse files
feature(#12): this commit adds attributes to endpoints that must support idempotency
1 parent d7fb8f4 commit 0e96d04

5 files changed

Lines changed: 12 additions & 0 deletions

File tree

Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Controllers/OrdersController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public async Task<IActionResult> GetOrdersAsync([FromQuery] OrdersFetchParameter
3232
}
3333

3434
[HttpPost]
35+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
3536
[Authorize(Roles = Permissions.CreateOrder)]
3637
public async Task<IActionResult> CreateOrderAsync([FromBody] OrderCreationScheme request, CancellationToken cancellation)
3738
{

Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Controllers/PaymentsController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
public sealed class PaymentsController(IDispatcher dispatcher, IEventDispatcher eventDispatcher) : ControllerBase
88
{
99
[HttpPost("online")]
10+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
1011
[Authorize(Roles = Permissions.MakePayment)]
1112
public async Task<IActionResult> CreateOnlineChargeAsync(
1213
[FromBody] CheckoutSessionCreationScheme request, [FromHeader(Name = Headers.Credential)] string credential, CancellationToken cancellation)
@@ -33,6 +34,7 @@ public async Task<IActionResult> CreateOnlineChargeAsync(
3334
}
3435

3536
[HttpPost("offline")]
37+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
3638
[Authorize(Roles = Permissions.MakePayment)]
3739
public async Task<IActionResult> CreateOfflinePaymentAsync([FromBody] OfflinePaymentScheme request, CancellationToken cancellation)
3840
{

Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Controllers/ProfilesController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public async Task<IActionResult> GetCustomersAsync([FromQuery] FetchCustomersPar
3232
}
3333

3434
[HttpPost("customers")]
35+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
3536
[Authorize]
3637
public async Task<IActionResult> CreateCustomerAsync([FromBody] CustomerCreationScheme request, CancellationToken cancellation)
3738
{
@@ -138,6 +139,7 @@ public async Task<IActionResult> GetCustomerAddressesAsync(
138139

139140
[HttpPost("customers/{customerId}/addresses")]
140141
[Authorize(Roles = Permissions.EditCustomers)]
142+
[Idempotent]
141143
public async Task<IActionResult> AssignCustomerAddressAsync(
142144
[FromBody] AssignCustomerAddressScheme request, [FromRoute] string customerId, CancellationToken cancellation)
143145
{
@@ -232,6 +234,7 @@ public async Task<IActionResult> GetOwnersAsync([FromQuery] FetchOwnersParameter
232234
}
233235

234236
[HttpPost("owners")]
237+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
235238
[Authorize]
236239
public async Task<IActionResult> CreateOwnerAsync([FromBody] OwnerCreationScheme request, CancellationToken cancellation)
237240
{

Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Controllers/StoresController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public async Task<IActionResult> GetEstablishmentsAsync(
3535
}
3636

3737
[HttpPost]
38+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
3839
[Authorize(Roles = Permissions.CreateEstablishment)]
3940
public async Task<IActionResult> CreateEstablishmentAsync(
4041
[FromBody] EstablishmentCreationScheme request, CancellationToken cancellation)
@@ -111,6 +112,7 @@ public async Task<IActionResult> DeleteEstablishmentAsync(
111112

112113
[HttpPost("{establishmentId}/checkout")]
113114
[Authorize(Roles = Permissions.MakePayment)]
115+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
114116
public async Task<IActionResult> CheckoutAsync(
115117
[FromBody] CreateCheckoutScheme request, [FromRoute] string establishmentId, CancellationToken cancellation)
116118
{
@@ -162,6 +164,7 @@ public async Task<IActionResult> GetProductsAsync(
162164

163165
[HttpPost("{establishmentId}/products")]
164166
[Authorize(Roles = Permissions.CreateProduct)]
167+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
165168
public async Task<IActionResult> CreateProductAsync(
166169
[FromBody] ProductCreationScheme request, [FromRoute] string establishmentId, CancellationToken cancellation)
167170
{
@@ -292,6 +295,7 @@ public async Task<IActionResult> GetCredentialsAsync(
292295

293296
[HttpPost("{establishmentId}/integrations/credentials")]
294297
[Authorize(Roles = Permissions.CreateCredential)]
298+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
295299
public async Task<IActionResult> AssignCredentialAsync(
296300
[FromBody] CredentialCreationScheme request, [FromRoute] string establishmentId, CancellationToken cancellation)
297301
{

Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Controllers/SubscriptionsController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public sealed class SubscriptionsController(IDispatcher dispatcher) : Controller
66
{
77
[HttpPost]
88
[Authorize(Roles = Permissions.Subscribe)]
9+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
910
public async Task<IActionResult> CreateCheckoutSessionAsync(
1011
[FromBody] SubscriptionCheckoutSessionCreationScheme request, CancellationToken cancellation)
1112
{
@@ -29,6 +30,7 @@ public async Task<IActionResult> CreateCheckoutSessionAsync(
2930

3031
[HttpDelete("{id}")]
3132
[Authorize(Roles = Permissions.CancelSubscription)]
33+
[Idempotent] // https://developer.mozilla.org/en-US/docs/Glossary/Idempotent
3234
public async Task<IActionResult> CancelSubscriptionAsync(
3335
[FromQuery] SubscriptionCancelationScheme request, [FromRoute] string id, CancellationToken cancellation)
3436
{

0 commit comments

Comments
 (0)