-
Notifications
You must be signed in to change notification settings - Fork 1
Quick Start Guide
Mitchell Currey edited this page Jul 26, 2022
·
5 revisions
In order to get started, please follow these steps.
1. Install the NuGet package using one of the following commands
Package Manager
Install-Package Forbury.Integrations -Version 1.2.0
.NET CLI
dotnet add PROJECT package Forbury.Integrations --version 1.2.0
PackageReference
<PackageReference Include="Forbury.Integrations" Version="1.2.0" />
For a full list of the latest releases, please see the package release page.
2. Add the following to your appsettings.config (replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET)
"Forbury": {
"Api": {
"Url": "https://api.forbury.com/",
"Version": 1
},
"Authentication": {
"Url": "https://account.forbury.com/",
"ClientId": "YOUR_CLIENT_ID",
"ClientSecret": "YOUR_CLIENT_SECRET"
}
}3. Add the following inside your Startup.cs (.NET 3.1 and .NET 5).
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddForburyApi(Configuration);
...
}Alternatively, if you are using the new .NET 6 design without a Startup.cs, add the following inside your Program.cs (.NET 6).
using Forbury.Integrations.API;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddForburyApi(builder.Configuration);You should now be ready to use the API!
Example usage inside a Service.
Note: Please take note of the using statements, its important to import usings from the correct version (see versions below).
using Forbury.Integrations.API.v1.Dto;
using Forbury.Integrations.API.v1.Interfaces;
...
public class ForburyDataService
{
private readonly IForburyTeamApiClient _forburyTeamApiClient;
public ForburyDataService(IForburyTeamApiClient forburyTeamApiClient)
{
_forburyTeamApiClient = forburyTeamApiClient;
}
public async Task GetTeams(int amount = 20, int page = 1)
{
PagedResult<TeamDto> teams = await _forburyTeamApiClient.GetTeams(amount, page);
// Do work here
...
}
public async Task GetModelDataForTeam(int id, DateTime? fromDate = null, int amount = 20, int page = 1)
{
PagedResult<ModelDto> models = await _forburyTeamApiClient.GetModelsByTeamId(id, fromDate, null, amount, page);
// Do work here
...
}
}