HttUnicorn 0.1.0

Package Description

Install-Package HttUnicorn -Version 0.1.0
dotnet add package HttUnicorn --version 0.1.0
paket add HttUnicorn --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

HttUnicorn v0.1.0

NuGet

Designed to help C# programmers creating HTTP Requests, this is The Hypertext Transfer Unicorn :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 &#39;Add some fooBar&#39;)
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request
  6. Wait for our response

🦄

HttUnicorn v0.1.0

NuGet

Designed to help C# programmers creating HTTP Requests, this is The Hypertext Transfer Unicorn :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 &#39;Add some fooBar&#39;)
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request
  6. Wait for our response

🦄

Release Notes

Migrated to dotnet core

Version History

Version Downloads Last updated
0.1.0 88 11/15/2018
0.0.2-alfa 88 10/14/2018