Repository navigation
Getting Started
This page provides samples and info about how to get started with ARH.
Current Version: 1.3.0
Before we start requesting a service, we need to install the package, or consume it somehow, and I just happen to create a Nuget package for this case. You can install using following command or by using other command provided by Nuget, or even consume it just by using the released file in Github.
- just search for AdvancedRestHandler in NuGet Package Manager UI
- using Package Manager Console command:
Install-Package AdvancedRestHandler -Version 1.3.0 - using .Net CLI command:
dotnet add package AdvancedRestHandler --version 1.3.0
To make your first request you will need to create an instance of AdvancedRestHandler class, or it's wrappers.
The classes that currently can be used are:
-
AdvancedRestHandler: UsesPascalCasename handling while processingJSONdata, e.g.:HelloWorld -
ArhCamelCaseWrapper: UsesCamelCasename handling while processingJSONdata, e.g.:helloWorld -
ArhSnakeCaseWrapper: UsesSnakeCasename handling while processingJSONdata, e.g.:hello_world
So simply check what version of naming the desired service uses the most, and choose the corresponding wrapper to keep your manual name handling at minimum.
The simplest call you can make can be like this:
namespace ArhExamples
{
class Program
{
static void Main(string[] args)
{
var response = new AdvancedRestHandler().GetData<GettingStartedResponse>(
"https://6016529c55dfbd00174cad29.mockapi.io/api/getting-started");
}
}
public class GettingStartedResponse
{
public string Data { get; set; }
public bool Succeed { get; set; }
}
}I create an online mock service for you, and this request works in real life