csharp-netcore.ApiResponse.mustache Maven / Gradle / Ivy
{{>partial_header}}
using System;
using System.Collections.Generic;
using System.Net;
namespace {{packageName}}.Client
{
///
/// Provides a non-generic contract for the ApiResponse wrapper.
///
public interface IApiResponse
{
///
/// The data type of
///
Type ResponseType { get; }
///
/// The content of this response
///
Object Content { get; }
///
/// Gets or sets the status code (HTTP status code)
///
/// The status code.
HttpStatusCode StatusCode { get; }
///
/// Gets or sets the HTTP headers
///
/// HTTP headers
Multimap Headers { get; }
///
/// Gets or sets any error text defined by the calling client.
///
String ErrorText { get; set; }
///
/// Gets or sets any cookies passed along on the response.
///
List Cookies { get; set; }
}
///
/// API Response
///
public class ApiResponse : IApiResponse
{
#region Properties
///
/// Gets or sets the status code (HTTP status code)
///
/// The status code.
public HttpStatusCode StatusCode { get; }
///
/// Gets or sets the HTTP headers
///
/// HTTP headers
public Multimap Headers { get; }
///
/// Gets or sets the data (parsed HTTP body)
///
/// The data.
public T Data { get; }
///
/// Gets or sets any error text defined by the calling client.
///
public String ErrorText { get; set; }
///
/// Gets or sets any cookies passed along on the response.
///
public List Cookies { get; set; }
///
/// The content of this response
///
public Type ResponseType
{
get { return typeof(T); }
}
///
/// The data type of
///
public object Content
{
get { return Data; }
}
#endregion Properties
#region Constructors
///
/// Initializes a new instance of the class.
///
/// HTTP status code.
/// HTTP headers.
/// Data (parsed HTTP body)
public ApiResponse(HttpStatusCode statusCode, Multimap headers, T data)
{
StatusCode = statusCode;
Headers = headers;
Data = data;
}
///
/// Initializes a new instance of the class.
///
/// HTTP status code.
/// Data (parsed HTTP body)
public ApiResponse(HttpStatusCode statusCode, T data)
{
StatusCode = statusCode;
Data = data;
}
#endregion Constructors
}
}