Skip to content

Getting Started

Hassan F edited this page Jan 31, 2021 · 7 revisions

This page provides samples and info about how to get started with ARH.

Current Version: 1.3.0

Installation

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

First Request

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: Uses PascalCase name handling while processing JSON data, e.g.: HelloWorld
  • ArhCamelCaseWrapper: Uses CamelCase name handling while processing JSON data, e.g.: helloWorld
  • ArhSnakeCaseWrapper: Uses SnakeCase name handling while processing JSON data, 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

Clone this wiki locally