- brew install mono
- Intsall VisualStudio
- Go to API docs page https://www.duedil.com/api/docs
- Click the top button "Generate DueDil V4 API client"
- From the dropdown menu select you desired language/platform, for this tutorial "C# .NET 2" and download the ZIP package
- This is for Mac/Linux users only
- Extract the archive with the generated client
- Compile the client code
/bin/bash compile-mono.sh
- The client should be located under bin/IO.Swagger.dll
- Open VisualStudio and create new MVC project
- In the root of the project create new folder "libs/"
- Copy the DLL file of the Swagger client there
- From the top menu select "Project > Edit Preferences > .Net Assembly (tab)"
- Browse and add the Swagger client to the build of the project "./libs/IO.Swagger.dll"
- From the top menu select "Project > Add NuGet Packages ... > Search for "RestSharp.Net2" and install"
- Build the project
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using DuedilApi.Models;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace DuedilApi.Controllers
{
public class HomeController : Controller
{
const string RESPONSE_FORMAT = "json";
const string API_AUTH_TOKEN = "<YOUR_API_KEY_HERE>";
const string DEFAULT_COMPANY_ID = "06999618";
private IEssentialsApi essentialsApi;
public HomeController()
{
Configuration.ApiKey["X-AUTH-TOKEN"] = API_AUTH_TOKEN;
essentialsApi = new EssentialsApi();
}
public IActionResult Index(String CompanyId)
{
try
{
string companyId = CompanyId == null ? DEFAULT_COMPANY_ID: CompanyId;
Debug.WriteLine(CompanyId);
Debug.WriteLine(companyId);
// Company vitals
CompanyResponse result = essentialsApi.CompanyCountryCodeCompanyIdFormatGet("gb", companyId, RESPONSE_FORMAT);
ViewData["companyId"] = result.CompanyId;
ViewData["countryCode"] = result.CountryCode;
ViewData["name"] = result.Name;
ViewData["status"] = result.SimplifiedStatus;
ViewData["address"] = result.RegisteredAddress.FullAddress;
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling EssentialsApi.CompanyCountryCodeCompanyIdFormatGet: " + e.Message);
}
return View();
}
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}