Dialect.VismaNetCore 0.4.0-alpha.168

Prefix Reserved
Suggested Alternatives

Evolvit.VismaNetCore

Additional Details

This package is deprecated and won't be updated. Switch over to Evolvit.VismaNetCore to continue recieving updates.

This is a prerelease version of Dialect.VismaNetCore.
dotnet add package Dialect.VismaNetCore --version 0.4.0-alpha.168
                    
NuGet\Install-Package Dialect.VismaNetCore -Version 0.4.0-alpha.168
                    
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="Dialect.VismaNetCore" Version="0.4.0-alpha.168" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dialect.VismaNetCore" Version="0.4.0-alpha.168" />
                    
Directory.Packages.props
<PackageReference Include="Dialect.VismaNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dialect.VismaNetCore --version 0.4.0-alpha.168
                    
#r "nuget: Dialect.VismaNetCore, 0.4.0-alpha.168"
                    
#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.
#:package Dialect.VismaNetCore@0.4.0-alpha.168
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dialect.VismaNetCore&version=0.4.0-alpha.168&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Dialect.VismaNetCore&version=0.4.0-alpha.168&prerelease
                    
Install as a Cake Tool

Visma.Net Core

This is an API wrapper written in C# for dotnet core to enable simplified use of the Visma.NET API, both version 2 and version 3. With support for Dependency Injection for smarter use for hosted services

This README is a work in progress and information might be incomplete or outdated.

Usage/Examples

Simplified examples of usage.

Dependency Injection

Console Application
using VismaNetCore;

var services = new ServiceCollection();
services.AddVismaNetClient(vismaNetOptions => {
    vismaNetOptions.GrantType = "client_credentials";
    vismaNetOptions.ClientId = "client_id";
    vismaNetOptions.ClientSecret = "client_secret";
    vismaNetOptions.TenantId = "tenant_id";
    vismaNetOptions.Scopes =
    [
        Scope.ErpServiceCreate,
		Scope.ErpServiceDelete,
		Scope.ErpServiceRead,
		Scope.ErpServiceUpdate,
		Scope.SalesOrderRead,
		Scope.SalesOrderWrite
    ];
})
services.AddSingleton<ImplementingClass>();

var serviceProvider = services.BuildServiceProvider();
var testClient = servicesProvider.GetRequiredService<ImplementingClass>();

await testClient.Test();

public class ImplementingClass
{
	private readonly VismaNetClient _vismaNetClient;

	public ImplementingClass(VismaNetClient vismaNetClient)
	{
		_vismaNetClient = vismaNetClient;
	}

	public async Task Test()
	{
		await _vismaNetClient.RefreshToken();
		var inventoryParameters = new Dictionary<string, string>
		{
			{ "pageSize", "10" }
		};
		var inventory = await _vismaNetClient.InventoryV3.GetInventoryAsync(inventoryParameters);
	}
}
Web Application
Program.cs
using VismaNetCore;
using VismaNetCore.Models.Enums;

var builder = WebApplication.CreateBuilder(args);
// You can also load from appsettings if you fetch that first
builder.Services.AddVismaNetClient(vismaNetOptions => {
    vismaNetOptions.GrantType = "client_credentials";
    vismaNetOptions.ClientId = "client_id";
    vismaNetOptions.ClientSecret = "client_secret";
    vismaNetOptions.TenantId = "tenant_id";
    vismaNetOptions.Scopes =
    [
        Scope.ErpServiceCreate,
		Scope.ErpServiceDelete,
		Scope.ErpServiceRead,
		Scope.ErpServiceUpdate,
		Scope.SalesOrderRead,
		Scope.SalesOrderWrite
    ];
})

WebApplication app = builder.Build();

app.Run();
Endpoints/Inventory/Get.cs
public class Get
{
	private readonly VismaNetClient _vismaNetClient;

	public Get(VismaNetClient vismaNetClient)
	{
		_vismaNetClient = vismaNetClient;
	}

	public void MapEndpoint(IEndpointRouteBuilder app)
	{
		app.MapPost("invoices", async (
			CreateInvoiceRequest request,
			CancellationToken cancellationToken) =>
		{
			// Get or Refresh the token
			await _vismaNetClient.RefreshToken();

			var inventory = await _vismaNetClient.InventoryV3.GetInventoryAsync();

			return Results.Ok(inventory);
		})
		.WithTags("Inventory");
	}
}

Contributing

Contributions are always welcome!

See CONTRIBUTE.md for ways to get started.

Please adhere to this project's contribution guidelines.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.