RefitRestMethodsPackage 1.0.8

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

// Install RefitRestMethodsPackage as a Cake Tool
#tool nuget:?package=RefitRestMethodsPackage&version=1.0.8

RestMethodsRefit

The package will be used to simplify the use of http methods (PUT, POST, GET, DELETE) through the REFIT library

Build

example workflow Nuget

How to use

import the package:

using RefitMethods; 

Instance the variables:

//left parameter is how do you want serialize the Object that you send to the server (RequestClass) 
//and in the right there is how do you want to deserialize the Object that the server send to the client (ResponseClass)
ApiRestMethods<RequestClass, ResponseClass> rest = new ApiRestMethods<RequestClass, ResponseClass>();

//if you use basic auth add username and password
ApiRestMethods<RequestClass, ResponseClass> rest = new ApiRestMethods<RequestClass, ResponseClass>(username,password);

POST METHOD:

/// <summary>
/// The method send data in json format to a server to create/update a resource.
/// </summary>
  /// <param name="request"> 
    /// Is the object that the method send to the server
  /// </param>
  /// <param name="URL">
    /// Is the uniform resource locator, it's a Uri class object
      /// <example> 
        /// <code>Uri url = new Uri("http://localhost:3000")</code>
      /// </example>
  /// </param>
  /// <param name="customHeaders">
    /// header's list, it's a dictionary<string,string>
      /// <example>
        /// <code> Dictionary<string, string> header = new Dictionary<string, string>();
        ///         header.Add("key", "value"); </code>
      /// </example>
  /// </param>
        
Response responseFromServer = await rest.PostMethod(request, URL, headers(optional).ConfigureAwait(true);

POST WITH QUERY METHOD:

/// <summary>
  /// The method send data in json format to a server to create/update a resource. In additional the client can send query params
/// </summary>
  /// <param name="queryParams">
    /// dictionary of params <key,value>
  /// </param>
  /// <param name="request"> 
    /// Is the object that the method send to the server
  /// </param>
  /// <param name="url">
    /// Is the uniform resource locator
  /// </param>
  /// <param name="customHeaders">
    /// header's list 
  /// </param>
  
Response responseFromServer = await rest.PostQueryMethod(request, queyParams, url, headers(optional));

GET METHOD:

/// <summary>
  /// The method retrieve data in json format from server.
/// </summary>
  /// <param name="url">
    /// Is the uniform resource locator
  /// </param>
  /// <param name="customHeaders">
    /// header's list 
  /// </param>
  
Response responseFromServer = await rest.GetMethod(url, headers(optional));

GET WITH QUERY METHOD:

/// <summary>
  /// The method retrieve data in json format from server, the client send a query string in the path.
/// </summary>
  /// <param name="queryParams">
    /// the params that will be add in url, dictionary<string,string> query
  /// </param>
  /// <param name="url">
    /// Is the uniform resource locator
  /// </param>
  /// <param name="customHeaders">
    /// header's list 
 /// </param>
        
Response responseFromServer =  await rest.GetQueryMethod(queryParams,url, headers(optional));

PUT METHOD:

 /// <summary>
    /// PUT method is used to update resource available on the server. 
  /// </summary>
    /// <param name="queryParams">
      /// list of params <key,value>, optional
    /// </param>
    /// <param name="request"> 
      /// Is the object that the method send to the server
    /// </param>
    /// <param name="url">
      /// Is the uniform resource locator
    /// </param>
    /// <param name="customHeaders">
     /// header's list 
    /// </param>
        
Response responseFromServer = await rest.PutMethod(request,url,headers(optional),queryParams:(optional))

DELETE METHOD:

 /// <summary>
    /// The HTTP DELETE method is used to delete a resource from the server
  /// </summary>
    /// <param name="url">
      /// Is the uniform resource locator
    /// </param>
      /// <param name="customHeaders">
      /// header's list 
    /// </params>
        
Response responseFromServer = await rest.DeleteMethod(url,headers:(optional))

The response class is always the same:

 /// <summary>
        /// Class response that deserialize a response of each call client/server
 /// </summary>
        Response
        {
            HttpStatusCode statusCode 
            bool isSuccess 
            string message 
            // J is the class you created for the response from the server (ResponseClass in example)
            J payload 
            ApiException error
        }
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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.

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.6 288 2/2/2023
1.1.5 252 2/2/2023
1.1.4 261 1/27/2023
1.1.3 297 1/19/2023
1.1.2 428 7/12/2022
1.1.1 441 5/5/2022
1.1.0 450 2/15/2022
1.0.9 322 10/4/2021
1.0.8 308 9/30/2021
1.0.7 319 9/28/2021
1.0.6 306 9/28/2021
1.0.5 295 9/28/2021
1.0.4 307 9/28/2021
1.0.3 296 9/27/2021
1.0.2 280 9/27/2021
1.0.1 284 9/23/2021
1.0.0 314 9/23/2021