Skip to content

Latest commit

 

History

History
96 lines (62 loc) · 2.25 KB

File metadata and controls

96 lines (62 loc) · 2.25 KB

FiveAnts.Endpoint

project-image

The Endpoint class in C# is a versatile HTTP client wrapper for making RESTful API calls. It supports various HTTP methods like GET POST PUT DELETE and PATCH and allows for header cookie and query parameter manipulation. It also provides basic and bearer token authentication.

🧐 Features

Here're some of the project's best features:

🛠️ Installation Steps:

Installation via command line using dotnet CLI.

dotnet add package FiveAnts.Endpoint

Example

public class Todo
{
    [JsonProperty("userId")]
    public int UserId;

    [JsonProperty("id")]
    public int Id;

    [JsonProperty("title")]
    public string? Title;

    [JsonProperty("completed")]
    public bool Completed;
}

public static async Task<Todo> GetTodo()
{
    var endpoint = new Endpoint<Todo>("https://jsonplaceholder.typicode.com");

    //https://jsonplaceholder.typicode.com/todos/1
    return await endpoint
        .AppendPathSegments("todos", "1")
        .GetAsync();
}
  public class Comments
  {
      [JsonProperty("postId")]
      public int PostId;

      [JsonProperty("id")]
      public int Id;

      [JsonProperty("name")]
      public string? Name;

      [JsonProperty("email")]
      public string? Email;

      [JsonProperty("body")]
      public string? Body;
  }

  public static async Task<List<Comments>> GetComment()
  {
      var endpoint = new Endpoint<List<Comments>>("https://jsonplaceholder.typicode.com");

      //https://jsonplaceholder.typicode.com/comments?postId=1
      return await endpoint
          .AppendPathSegment("comments")
          .SetQueryParam("postId", 1)
          .GetAsync();
  }

💻 Built with

Technologies used in the project:

  • .NET 8.0
  • Newtonsot.Json

🛡️ License:

This project is licensed under the MIT License