HttUnicorn 0.1.0

dotnet add package HttUnicorn --version 0.1.0
NuGet\Install-Package HttUnicorn -Version 0.1.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="HttUnicorn" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HttUnicorn --version 0.1.0
#r "nuget: HttUnicorn, 0.1.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 HttUnicorn as a Cake Addin
#addin nuget:?package=HttUnicorn&version=0.1.0

// Install HttUnicorn as a Cake Tool
#tool nuget:?package=HttUnicorn&version=0.1.0

HttUnicorn v0.1.0

NuGet

Designed to help C# programmers creating HTTP Requests, this is The Hypertext Transfer Unicorn 🦄

Usage

Nuget

You can get HttpUnicorn by installing our NuGet Package;

Config

HttUnicorn uses a config object called UnicornConfig that need a string with the url.

var config = new UnicornConfig("http://localhost:3000/todos/");

You can also use UnicornConfig to set the Timeout and Headers

var config = new UnicornConfig(
  "http://localhost:3000/todos/",
  timeout: new TimeSpan(0, 0, 45),
  headers: new List<UnicornHeader>(
    new UnicornHeader("header_name", "header_value"),
    new UnicornHeader("other_header_name", "other_header_value")
  ));

You can pass the timeout directly as seconds

var config = new UnicornConfig(
  "http://localhost:3000/todos/",
  timeoutSeconds: 35
  );

You can start following the examples bellow:

Get

List<Todo> todos = await new Unicorn(config).GetModelAsync<List<Todo>>();

string todosString = await new Unicorn(config).GetStringAsync();

using(HttpResponseMessage responseMessage = 
  await new Unicorn(config).GetResponsegAsync())
{
    //deal with the response message
}

Post

Todo generatedTodo = await new Unicorn(config)
  .PostModelAsync<Todo, Todo>(new Todo
  {
    Completed = true,
    Title = "todo",
    UserId = 36
  });
string stringResponseBody = await new Unicorn(config)
  .PostStringAsync(new Todo
  {
    Completed = true,
    Title = "todo",
    UserId = 36
  });
using(HttpResponseMessage responseMessage = 
  await new Unicorn(config).PostResponsegAsync())
{
    //deal with the response message
}

Put

Todo updatedTodo = await new Unicorn(config)
                    .PutModelAsync<Todo, Todo>(todo);

Delete

MyApiResponse response = await new new Unicorn(config)
                          .DeleteModelAsync<MyApiResponse>(key);
//This one is for situations when the requested API returns an object in the body of the response.

Contact us

Tyler Mendes de Brito - @tylerbryto (Github) – colorigotica (Twitter) – tyler.brito99@gmail.com

Contributing

See git flow cheatsheet.

  1. Fork it (https://github.com/tylerbryto/httunicorn/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request
  6. Wait for our response

🦄

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.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 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
0.1.0 781 11/15/2018
0.0.2-alfa 551 10/14/2018

Migrated to dotnet core