From 6f24f01fc7232f5340bbc170d86e0cd53d3c8d04 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Fri, 10 Apr 2026 12:19:43 +0100 Subject: [PATCH] Add UpdateMerchantSchedule method to client interface Introduced UpdateMerchantSchedule to ITransactionProcessorClient and its implementation, enabling merchant schedule updates via HTTP PATCH. Improved exception messages for schedule operations. No functional changes to GetMerchantSchedule. --- .../ITransactionProcessorClient.cs | 7 ++++ .../TransactionProcessorClient.cs | 34 ++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/TransactionProcessor.Client/ITransactionProcessorClient.cs b/TransactionProcessor.Client/ITransactionProcessorClient.cs index 4cea6fd8..1494ab84 100644 --- a/TransactionProcessor.Client/ITransactionProcessorClient.cs +++ b/TransactionProcessor.Client/ITransactionProcessorClient.cs @@ -113,6 +113,13 @@ Task CreateMerchantSchedule(String accessToken, CreateMerchantScheduleRequest createMerchantScheduleRequest, CancellationToken cancellationToken); + Task UpdateMerchantSchedule(String accessToken, + Guid estateId, + Guid merchantId, + Int32 year, + UpdateMerchantScheduleRequest updateMerchantScheduleRequest, + CancellationToken cancellationToken); + Task> GetMerchant(String accessToken, Guid estateId, Guid merchantId, diff --git a/TransactionProcessor.Client/TransactionProcessorClient.cs b/TransactionProcessor.Client/TransactionProcessorClient.cs index 863c3ef7..88ae4e6b 100644 --- a/TransactionProcessor.Client/TransactionProcessorClient.cs +++ b/TransactionProcessor.Client/TransactionProcessorClient.cs @@ -762,17 +762,41 @@ public async Task CreateMerchantSchedule(String accessToken, return Result.Success(); } catch (Exception ex) { - Exception exception = new($"Error creating merchant schedule for merchant {merchantId} for estate {estateId}.", ex); + Exception exception = new($"Error creating schedule for merchant {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task UpdateMerchantSchedule(String accessToken, + Guid estateId, + Guid merchantId, + Int32 year, + UpdateMerchantScheduleRequest updateMerchantScheduleRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/schedules/{year}"); + + try + { + var result = await this.SendHttpPatchRequest(requestUri, updateMerchantScheduleRequest, accessToken, cancellationToken); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) + { + Exception exception = new($"Error updating {year} schedule for merchant {merchantId} for estate {estateId}.", ex); throw exception; } } public async Task> GetMerchantSchedule(String accessToken, - Guid estateId, - Guid merchantId, - Int32 year, - CancellationToken cancellationToken) { + Guid estateId, + Guid merchantId, + Int32 year, + CancellationToken cancellationToken) { String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/schedules/{year}"); try {