littleshop/LittleShop.Client/Models/ApiResponse.cs
sysadmin 1f7c0af497 Add LittleShop.Client SDK library with complete API wrapper
Features:
- Complete .NET client SDK for LittleShop API
- JWT authentication with automatic token management
- Catalog service for products and categories
- Order service with payment creation
- Retry policies using Polly for resilience
- Error handling middleware
- Dependency injection support
- Comprehensive documentation and examples

SDK Components:
- Authentication service with token refresh
- Strongly-typed models for all API responses
- HTTP handlers for retry and error handling
- Extension methods for easy DI registration
- Example console application demonstrating usage

Test Updates:
- Fixed test compilation errors
- Updated test data builders for new models
- Corrected service constructor dependencies
- Fixed enum value changes (PaymentStatus, OrderStatus)

Documentation:
- Complete project README with features and usage
- Client SDK README with detailed examples
- API endpoint documentation
- Security considerations
- Deployment guidelines

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 18:15:35 +01:00

40 lines
1.0 KiB
C#

using System.Net;
namespace LittleShop.Client.Models;
public class ApiResponse<T>
{
public bool IsSuccess { get; set; }
public T? Data { get; set; }
public string? ErrorMessage { get; set; }
public HttpStatusCode StatusCode { get; set; }
public static ApiResponse<T> Success(T data, HttpStatusCode statusCode = HttpStatusCode.OK)
{
return new ApiResponse<T>
{
IsSuccess = true,
Data = data,
StatusCode = statusCode
};
}
public static ApiResponse<T> Failure(string errorMessage, HttpStatusCode statusCode)
{
return new ApiResponse<T>
{
IsSuccess = false,
ErrorMessage = errorMessage,
StatusCode = statusCode
};
}
}
public class PagedResult<T>
{
public List<T> Items { get; set; } = new();
public int TotalCount { get; set; }
public int PageNumber { get; set; }
public int PageSize { get; set; }
public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);
}