final
This commit is contained in:
@@ -8,4 +8,5 @@ public interface IMessageService
|
||||
Task<bool> MarkMessageAsSentAsync(Guid messageId, string? platformMessageId = null);
|
||||
Task<bool> MarkMessageAsFailedAsync(Guid messageId, string reason);
|
||||
Task<bool> CreateCustomerMessageAsync(object messageData);
|
||||
Task<List<CustomerMessage>?> GetCustomerMessagesAsync(Guid customerId);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ public interface IOrderService
|
||||
{
|
||||
Task<ApiResponse<Order>> CreateOrderAsync(CreateOrderRequest request);
|
||||
Task<ApiResponse<List<Order>>> GetOrdersByIdentityAsync(string identityReference);
|
||||
Task<ApiResponse<List<Order>>> GetOrdersByCustomerIdAsync(Guid customerId);
|
||||
Task<ApiResponse<Order>> GetOrderByIdAsync(Guid id);
|
||||
Task<ApiResponse<CryptoPayment>> CreatePaymentAsync(Guid orderId, int currency);
|
||||
Task<ApiResponse<List<CryptoPayment>>> GetOrderPaymentsAsync(Guid orderId);
|
||||
|
||||
@@ -84,4 +84,26 @@ public class MessageService : IMessageService
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<CustomerMessage>?> GetCustomerMessagesAsync(Guid customerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetAsync($"api/bot/messages/customer/{customerId}");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var messages = await response.Content.ReadFromJsonAsync<List<CustomerMessage>>();
|
||||
return messages ?? new List<CustomerMessage>();
|
||||
}
|
||||
|
||||
_logger.LogWarning("Failed to get customer messages: {StatusCode}", response.StatusCode);
|
||||
return new List<CustomerMessage>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error getting customer messages");
|
||||
return new List<CustomerMessage>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,30 @@ public class OrderService : IOrderService
|
||||
System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<List<Order>>> GetOrdersByCustomerIdAsync(Guid customerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetAsync($"api/orders/by-customer/{customerId}");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var orders = await response.Content.ReadFromJsonAsync<List<Order>>();
|
||||
return ApiResponse<List<Order>>.Success(orders ?? new List<Order>());
|
||||
}
|
||||
|
||||
var error = await response.Content.ReadAsStringAsync();
|
||||
return ApiResponse<List<Order>>.Failure(error, response.StatusCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to get orders for customer {CustomerId}", customerId);
|
||||
return ApiResponse<List<Order>>.Failure(
|
||||
ex.Message,
|
||||
System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<Order>> GetOrderByIdAsync(Guid id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user