/SurveySolutionsClient

C# client library to access Survey Solutions public api

Primary LanguageC#MIT LicenseMIT

NuGet package

Survey Solutions Client

C# client library to access Survey Solutions public api.

To get started using api:

  1. create a new api user as described here.
  2. Install nuget package
  3. Then create a api client with following code sample:
Credentials creds = new Credentials("apiUser", "apiPassword");
string surveySolutionsUrl = "https://demo.mysruvey.solutions";
var surveySolutionsApiConfiguration = new SurveySolutionsApiConfiguration(creds, surveySolutionsUrl);
var client = new SurveySolutionsApi(new HttpClient(), surveySolutionsApiConfiguration);
var assignmentsList = await client.Assignments.ListAsync(new AssignmentsListFilter());

More usage examples can be found in tests folder

Dependency Injection

Please use https://www.nuget.org/packages/SurveySolutionsClient.DependencyInjection package to use C# client with Microsoft.Extensions.DependencyInjection library.

Sample configuration in Net 6.0 application

using SurveySolutionsClient;

var builder = WebApplication.CreateBuilder(args);

Credentials creds = new Credentials("apiUser", "apiPassword");
string surveySolutionsUrl = "https://demo.mysruvey.solutions";

builder.Services.ConfigureSurveySolutionsApiClient(creds, surveySolutionsUrl);
builder.Services.AddSurveySolutionsApiClient();

var app = builder.Build();
app.Run();

Options pattern

There is also support for Options pattern in ASP.NET Core

Let's assume, that You configration contains following section:

"SurveySolutions": { 
    "UserName": "apiUser",
    "Password": "apiPassword",
    "Url": "https://demo.mysruvey.solutions",
    "Workspace": "agriculture"
}

Then in C# code

using SurveySolutionsClient;

var builder = WebApplication.CreateBuilder(args);

builder.ConfigureSurveySolutionsApiClient(builder.Configuration.GetSection("SurveySolutions"));
builder.Services.AddSurveySolutionsApiClient();

var app = builder.Build();
app.Run();