MxIO.ApiClient.Abstractions 2.0.150.1

dotnet add package MxIO.ApiClient.Abstractions --version 2.0.150.1
                    
NuGet\Install-Package MxIO.ApiClient.Abstractions -Version 2.0.150.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MxIO.ApiClient.Abstractions" Version="2.0.150.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MxIO.ApiClient.Abstractions" Version="2.0.150.1" />
                    
Directory.Packages.props
<PackageReference Include="MxIO.ApiClient.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MxIO.ApiClient.Abstractions --version 2.0.150.1
                    
#r "nuget: MxIO.ApiClient.Abstractions, 2.0.150.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MxIO.ApiClient.Abstractions@2.0.150.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MxIO.ApiClient.Abstractions&version=2.0.150.1
                    
Install as a Cake Addin
#tool nuget:?package=MxIO.ApiClient.Abstractions&version=2.0.150.1
                    
Install as a Cake Tool

MxIO.ApiClient.Abstractions

This library provides common models and interfaces for standardized API response handling, including pagination, filtering, and error management.

Installation

dotnet add package MxIO.ApiClient.Abstractions

Features

  • Standardized API response models
  • Common collection models for result sets
  • Consistent error model structure
  • Pagination support with metadata
  • OData-like filtering options

Core Models

ApiResponse<T>

The ApiResponse<T> class is a wrapper for API responses that includes:

public class ApiResponse<T>
{
    public HttpStatusCode StatusCode { get; set; }
    public T? Data { get; set; }
    public ApiError[]? Errors { get; set; }
    public ApiPagination? Pagination { get; set; }
    public Dictionary<string, string>? Metadata { get; set; }
    
    // Helper properties
    public bool IsSuccess => (int)StatusCode >= 200 && (int)StatusCode < 300;
    public bool IsNotFound => StatusCode == HttpStatusCode.NotFound;
    public bool IsConflict => StatusCode == HttpStatusCode.Conflict;
    public bool IsBadRequest => StatusCode == HttpStatusCode.BadRequest;
}

ApiError

The ApiError class provides a standardized format for API errors:

public class ApiError
{
    public string Code { get; set; } = string.Empty;
    public string Message { get; set; } = string.Empty;
    public string? Target { get; set; }
    public ApiError[]? Details { get; set; }
}

ApiPagination

The ApiPagination class provides standardized pagination information:

public class ApiPagination
{
    public int TotalCount { get; set; }
    public int FilteredCount { get; set; }
    public int Skip { get; set; }
    public int Top { get; set; }
    public bool HasMore { get; set; }
}

CollectionModel<T>

The CollectionModel<T> class provides a standardized container for collections of resources:

public class CollectionModel<T>
{
    public List<T> Items { get; set; } = new List<T>();
}

FilterOptions

The FilterOptions class provides standardized options for filtering API responses:

public class FilterOptions
{
    public string? FilterExpression { get; set; }
    public string[]? Select { get; set; }
    public string[]? Expand { get; set; }
    public string? OrderBy { get; set; }
    public int Skip { get; set; }
    public int Top { get; set; }
    public bool Count { get; set; }
}

HttpResponseWrapper<T>

The HttpResponseWrapper<T> class wraps API responses with HTTP-specific information:

public class HttpResponseWrapper<T>
{
    public ApiResponse<T>? Result { get; set; }
    public HttpStatusCode StatusCode { get; set; }
    public string? Content { get; set; }
    
    // Helper properties
    public bool IsSuccess { get; }
    public bool IsNotFound { get; }
    public bool IsConflict { get; }
    public bool IsBadRequest { get; }
}

Usage Examples

Creating API Responses

// Success response with data
var successResponse = new ApiResponse<User>
{
    StatusCode = HttpStatusCode.OK,
    Data = user
};

// Error response
var errorResponse = new ApiResponse<User>
{
    StatusCode = HttpStatusCode.BadRequest,
    Errors = new[]
    {
        new ApiError
        {
            Code = "InvalidUsername",
            Message = "Username is invalid",
            Target = "username"
        }
    }
};

// Collection response with pagination
var collectionResponse = new ApiResponse<CollectionModel<User>>
{
    StatusCode = HttpStatusCode.OK,
    Data = new CollectionModel<User>
    {
        Items = users
    },
    Pagination = new ApiPagination
    {
        TotalCount = 100,
        FilteredCount = 10,
        Skip = 0,
        Top = 10,
        HasMore = true
    }
};

Working with Filter Options

// Create filter options for an API request
var filter = new FilterOptions
{
    FilterExpression = "username eq 'john' and active eq true",
    OrderBy = "created desc",
    Skip = 0,
    Top = 20,
    Select = new[] { "username", "email", "firstName", "lastName" },
    Expand = new[] { "roles", "permissions" }
};
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on MxIO.ApiClient.Abstractions:

Package Downloads
MX.GeoLocation.GeoLocationApi.Client

This package provides a web service client to query the geolocation service.

XtremeIdiots.Portal.RepositoryApi.Abstractions

Abstractions for the XtremeIdiots Portal Repository API.

XtremeIdiots.Portal.RepositoryApiClient

Client for the XtremeIdiots Portal Repository API.

XtremeIdiots.Portal.ServersApi.Abstractions

Abstractions for the XtremeIdiots Portal Servers API.

MxIO.ApiClient

An abstractions library containing common API client functionality for .NET 7. Contains common interfaces, extensions and models for API clients.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.150.1 818 6/30/2025
2.0.149.1 238 6/25/2025
1.1.147.1 3,833 6/23/2025
1.1.146.1 1,406 6/16/2025
1.1.145.1 423 6/9/2025
1.1.144.1 286 6/2/2025
1.1.143.1 221 5/26/2025
1.1.142.1 234 5/19/2025
1.1.141.1 303 5/12/2025
1.1.140.1 524 5/5/2025
1.1.139.1 880 4/28/2025
1.1.138.1 627 4/26/2025
1.1.137.1 253 4/25/2025
1.1.136.1 992 4/23/2025
1.1.135.1 398 4/21/2025
1.1.134.1 242 4/19/2025
1.1.133.1 157 4/19/2025
1.1.132.1 151 4/19/2025
1.1.131.1 182 4/19/2025
1.1.130.1 553 4/14/2025
1.1.129.1 735 4/7/2025
1.1.128.1 1,144 3/31/2025
1.1.127.1 1,678 3/24/2025
1.1.126.1 1,070 3/17/2025
1.1.125.1 1,238 3/16/2025
1.1.124.1 636 3/10/2025
1.1.123.1 776 3/3/2025
1.1.122.1 1,232 2/24/2025
1.1.115.1 2,737 1/6/2025
1.1.114.1 876 12/31/2024
1.1.113.1 968 12/30/2024
1.1.112.1 1,010 12/23/2024
1.1.111.1 1,014 12/16/2024
1.1.110.1 584 12/9/2024
1.1.109.1 461 12/2/2024
1.1.108.1 783 11/25/2024
1.1.107.1 1,070 11/18/2024
1.1.106.1 927 11/15/2024
1.1.105.1 1,187 11/11/2024
1.1.104.1 1,064 11/4/2024
1.1.103.1 983 10/28/2024
1.1.102.1 482 10/21/2024
1.1.101.1 1,341 10/14/2024
1.1.100.1 1,613 10/7/2024
1.1.99.1 1,286 9/30/2024
1.1.98.1 1,005 9/23/2024
1.1.97.1 1,376 9/17/2024
1.1.92.1 1,372 8/19/2024
1.1.91.1 1,136 8/12/2024
1.1.90.1 1,007 8/5/2024
1.1.89.1 844 7/29/2024
1.1.88.1 776 7/23/2024
1.1.87.1 944 7/22/2024
1.1.86.1 592 7/15/2024
1.1.85.1 988 7/8/2024
1.1.84.1 1,414 7/1/2024
1.1.83.1 2,448 6/24/2024
1.1.82.1 944 6/17/2024
1.1.81.1 1,720 6/10/2024
1.1.80.1 1,250 6/3/2024
1.1.79.1 1,183 5/27/2024
1.1.78.1 1,128 5/20/2024
1.1.77.1 1,088 5/13/2024
1.1.76.1 1,246 5/6/2024
1.1.75.1 2,310 4/29/2024
1.1.74.1 368 4/22/2024
1.1.73.1 392 4/15/2024
1.1.72.1 1,030 4/8/2024
1.1.71.1 455 4/1/2024
1.1.70.1 1,425 3/25/2024
1.1.69.1 311 3/18/2024
1.1.68.1 295 3/11/2024
1.1.67.1 992 3/4/2024
1.1.66.1 321 2/26/2024
1.1.65.1 339 2/19/2024
1.1.64.1 396 2/12/2024
1.1.63.1 392 2/7/2024
1.1.62.1 1,374 2/7/2024
1.1.61.1 1,129 2/6/2024
1.1.60.1 347 2/6/2024
1.1.59.1 534 2/5/2024
1.1.58.1 454 1/29/2024
1.1.57.1 466 1/22/2024
1.1.56.1 443 1/15/2024
1.1.55.1 509 1/8/2024
1.1.54.1 2,372 1/1/2024
1.1.53.1 749 12/25/2023
1.1.52.1 1,547 12/18/2023
1.1.51.1 534 12/11/2023
1.1.50.1 3,635 12/4/2023
1.1.49.1 2,393 11/27/2023
1.1.48.1 968 11/20/2023
1.1.47.1 2,908 11/13/2023
1.1.46.1 619 11/11/2023
1.1.45.1 1,301 11/11/2023
1.1.44.1 460 11/11/2023
1.1.43.1 406 11/11/2023
1.1.42.1 441 11/11/2023
1.1.41.1 435 11/11/2023
1.1.40.1 444 11/11/2023
1.1.39.1 1,094 11/9/2023
1.1.38.1 451 11/9/2023
1.1.37.1 453 11/9/2023
1.1.36.1 460 11/9/2023
1.1.35.1 1,483 11/6/2023
1.1.34.1 1,995 10/30/2023
1.1.33.1 919 10/27/2023
1.1.32.1 1,408 10/23/2023
1.1.31.1 1,333 10/21/2023
1.1.30.1 578 10/21/2023
1.1.29.1 444 10/21/2023
1.1.28.1 482 10/21/2023
1.1.27.1 484 10/20/2023
1.1.26.1 514 10/20/2023
1.1.25.1 552 10/20/2023
1.1.24.1 483 10/20/2023
1.0.23.1 485 10/20/2023