ATK.Command.Communication.Models 0.0.3

dotnet add package ATK.Command.Communication.Models --version 0.0.3
                    
NuGet\Install-Package ATK.Command.Communication.Models -Version 0.0.3
                    
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="ATK.Command.Communication.Models" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ATK.Command.Communication.Models" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="ATK.Command.Communication.Models" />
                    
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 ATK.Command.Communication.Models --version 0.0.3
                    
#r "nuget: ATK.Command.Communication.Models, 0.0.3"
                    
#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 ATK.Command.Communication.Models@0.0.3
                    
#: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=ATK.Command.Communication.Models&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=ATK.Command.Communication.Models&version=0.0.3
                    
Install as a Cake Tool

ATK.Command.Communication.Models

A lightweight .NET Standard 2.1 class library providing reusable data models for web API communication. This library offers essential models for building standardized API responses, handling pagination, managing notifications, and transferring file data.

Features

  • ApiResponse<T> - Generic API response wrapper with status, data, message, and notifications support
  • Paging - Configurable pagination request model with filter, skip, and take parameters
  • PaginationResponse<T> - Generic pagination response model for paginated data
  • Notification - Notification model with severity levels and factory methods (Success, Info, Warning, Error)
  • FileModel - File transfer model with support for both binary and Base64-encoded content

Installation

Install the NuGet package:

dotnet add package ATK.Command.Communication.Models

Or using the NuGet Package Manager:

Install-Package ATK.Command.Communication.Models

Quick Start

ApiResponse

The ApiResponse<T> class provides a standardized API response format with status tracking and notification support:

using ATK.Command.Communication.Models;

// Create a successful response
var response = new ApiResponse<User>
{
    Status = "success",
    Data = user,
    Message = "User retrieved successfully"
};

// Check response status
if (response.IsSuccess)
{
    // Handle success
}

// Add notifications
response.Notifications.Add(Notification.Info("Data loaded from cache"));

Pagination

Use the Paging model for pagination requests and PaginationResponse<T> for responses:

// Create a paging request
var paging = new Paging
{
    Filter = "active",
    Skip = 0,
    Take = 20
};

// Create a paginated response
var response = new PaginationResponse<User>
{
    Total = 150,
    Items = users
};

Notifications

The Notification class provides factory methods for creating different severity levels:

// Create notifications using factory methods
var success = Notification.Success("Operation completed", "Success", new { userId = 123 });
var info = Notification.Info("This is informational", "Info");
var warning = Notification.Warning("Please review this", "Warning");
var error = Notification.Error("An error occurred", "Error");

// Add to response
response.Notifications.AddRange(new[] { success, info });

File Transfer

The FileModel class supports both binary and Base64-encoded file content:

var fileModel = new FileModel
{
    Name = "document.pdf",
    ContentType = "application/pdf",
    Content = fileBytes
};

// Convert to Base64 for transmission
fileModel.ToBase64();

// Convert back from Base64
fileModel.FromBase64();

Models Overview

ApiResponse<T>

Generic API response wrapper for standardized communication.

Properties:

  • Status - Response status (success, fail, error, forbidden)
  • Data - The response payload of type T
  • Message - Additional response message
  • Notifications - List of notification objects

Methods:

  • IsSuccess - Check if status is "success"
  • IsFail - Check if status is "fail"
  • IsForbidden - Check if status is "forbidden"

Paging

Request model for paginating data retrieval.

Properties:

  • Filter - Search/filter term (default: empty string)
  • Skip - Number of records to skip (default: 0)
  • Take - Number of records to retrieve (default: 10)

PaginationResponse<T>

Generic response model for paginated data.

Properties:

  • Total - Total number of items available
  • Items - Collection of paginated items

Notification

Notification object with severity levels.

Properties:

  • Severity - Severity level (success, info, warning, error)
  • Message - Notification message
  • Title - Notification title
  • Variables - Additional data/context

Factory Methods:

  • Success(message, title, variables)
  • Info(message, title, variables)
  • Warning(message, title, variables)
  • Error(message, title, variables)

FileModel

File transfer model supporting binary and Base64 encoding.

Properties:

  • Content - Binary file content (byte array)
  • Base64EncodedContent - Base64-encoded file content
  • Name - File name
  • ContentType - MIME type

Methods:

  • ToBase64() - Convert binary content to Base64
  • FromBase64() - Convert Base64 content to binary

Requirements

  • .NET Standard 2.1 or higher
  • .NET Framework 4.7.2+
  • .NET Core 3.0+
  • .NET 5.0+

License

This project is licensed under the MIT License - see the LICENSE file for details.

Repository

GitHub: a-t-k/WebCommunicationModels

Version History

0.0.3 - Current stable release

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.3 148 4/20/2026