iQuantile.DotLib.OAA 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package iQuantile.DotLib.OAA --version 1.0.1                
NuGet\Install-Package iQuantile.DotLib.OAA -Version 1.0.1                
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="iQuantile.DotLib.OAA" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add iQuantile.DotLib.OAA --version 1.0.1                
#r "nuget: iQuantile.DotLib.OAA, 1.0.1"                
#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 iQuantile.DotLib.OAA as a Cake Addin
#addin nuget:?package=iQuantile.DotLib.OAA&version=1.0.1

// Install iQuantile.DotLib.OAA as a Cake Tool
#tool nuget:?package=iQuantile.DotLib.OAA&version=1.0.1                

Object API Helper

Object API helper is designed for Object Oriented programmers to call RESTful API's using Class Objects.Let the Library handle the rest!

Please feel free to fork and submit pull requests to the develop branch.

If you are reporting an issue it is really useful if you can supply an example Excel file as this makes debugging much easier and without it we may not be able to resolve any problems.

Installation

It is recommended to use NuGet. F.ex through the VS Package Manager Console Install-Package <package> or using the VS "Manage NuGet Packages..." extension.

How to use

Create a model class of the API you wish to call. For example we are going to use a open API Battuta that gives us Country list.

Class Model
public class Country
    {
        public string name { get; set; }
        public string code { get; set; }
    }
Constructor

Now we need to create an instance of the API Helper class.You need to pass the class object template that you wish to request over API's and pass the base url through the constructor.

using System.Windows.Forms;
using ObjectAPIAssistant;

namespace Test.App
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            ApiAssistant<Country> assistant=new ApiAssistant<Country>("http://battuta.medunes.net/api/");
             
        }
    }
}

But the API we wish to call returns a list of Countries. So in that case we just need to pass a list of countries as the template.

using System.Collections.Generic;
using System.Windows.Forms;
using ObjectAPIAssistant;

namespace Test.App
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            ApiAssistant<List<Country>> assistant=new ApiAssistant<List<Country>>("http://battuta.medunes.net/api/");
             
        }
    }
}

GET

Now our API helper is ready. We need to update the request URI. Get your API key from Battuta if you are going to test it with that api

 assistant.RequestUri = "country/all/?key={YOUR_API_KEY}";

Now lets get that list of Countries from them. In one line of code.

Countries = await assistant.GetObjectAsync();

Incase you wish to get a HTTP Response Message object and handle the Message Manually

 HttpResponseMessage message = await assistant.GetResponseAsync();

POST

Posting works the same way as get method. But make sure you Update your request URI before calling any other function

assistant.RequestUri = "REQUEST_URI_HERE";

Pass the list of objects and it will return the list of objects after created, Given that the API provider returns the list.

Countries = await assistant.CreateObjectAsync(Countries);

Incase you wish to get a HTTP Response Message object and handle the Message Manually

HttpResponseMessage message = await assistant.CreateObjectResponseAsync(Countries);

PUT

PUT works exactly the same way as POST.

Pass the list of objects and it will return the list of objects after updated, Given that the API provider returns the list.

assistant.RequestUri = "REQUEST_URI_HERE";
Countries = await assistant.UpdateObjectAsync(Countries);

Incase you wish to get a HTTP Response Message object and handle the Message Manually

HttpResponseMessage message = await assistant.UpdateObjectResponseAsync(Countries);

DELETE

DELETE works a bit differently. It Takes only the id as input and returns a Status Code.

assistant.RequestUri = "REQUEST_URI_HERE";
HttpStatusCode code=await assistant.DeleteObjecAsync("ID");
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

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
1.0.2 1,114 3/27/2018
1.0.1 1,047 3/24/2018
1.0.0 1,138 3/23/2018

Official Release