Respify 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Respify --version 1.0.0                
NuGet\Install-Package Respify -Version 1.0.0                
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="Respify" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Respify --version 1.0.0                
#r "nuget: Respify, 1.0.0"                
#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.
// Install Respify as a Cake Addin
#addin nuget:?package=Respify&version=1.0.0

// Install Respify as a Cake Tool
#tool nuget:?package=Respify&version=1.0.0                

Respify

Respify is a C# library designed to standardize API responses. It provides a consistent structure for both paginated and non-paginated data, making it easier to handle API responses in a uniform way.

Installation

To install Respify, you can add it to your project via NuGet Package Manager:

dotnet add package Respify

Generating Success Responses

You can generate success responses for both paginated and non-paginated return object using the ResponseHelper class.

Paginated Response

using Respify;
using Respify.helpers;

var cars = new List<Car>();
var paginatedResponse = new PaginatedResponse<List<Car>>(Items: cars, Count: cars.Count, PageNumber: 1, PageSize: 15, OrderBy: "Make", SortBy: "desc");
var response = ResponseHelper.Success(Data: paginatedResponse, Message: "Success", StatusCode: 200);

Non-Paginated Response

using Respify;
using Respify.helpers;

var cars = new List<Car>();
var nonPaginatedResponse = new NonPaginatedResponse<List<Car>>(Items: cars, Count: cars.Count);
var response = ResponseHelper.Success(Data: nonPaginatedResponse, Message: "Success", StatusCode: 200);

Generating Failure Responses

You can generate failure responses with optional return object and a list of errors.

using Respify;
using Respify.helpers;

var response = ResponseHelper.Failure<object>(Data: null, Message: "Failure", StatusCode: 400);

Or

You also can generate failure responses with optional 'Message' with a list of errors.

using Respify;
using Respify.helpers;

var errors = new List<string>();
var response = ResponseHelper.Failure<object>(Data: null, Message: null, StatusCode: 400, Errors: errors);

Creating Custom Responses

You can create custom responses with specific object, message, status code, success flag, and errors.

using Respify;
using Respify.helpers;

int id = 1;
var response = ResponseHelper.CreateResponse(Data: id, Message: "message", StatusCode: 201, Success: true, Errors: null);

Or

var response = ResponseHelper.CreateResponse<object>(Data: null, Message: "message", StatusCode: 201, Success: true, Errors: null);

GitHub

License

This project is licensed under the MIT License.

This README.md file provides an overview of the Respify library, installation instructions, usage examples, and class definitions. Respify is a C# library designed to standardize API responses. It provides a consistent structure for both paginated and non-paginated data, making it easier to handle API responses in a uniform way.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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
1.1.0 91 12/28/2024
1.0.0 80 12/22/2024