N2C.VismaNET.SubscriptionHandler
1.0.0
dotnet add package N2C.VismaNET.SubscriptionHandler --version 1.0.0
NuGet\Install-Package N2C.VismaNET.SubscriptionHandler -Version 1.0.0
<PackageReference Include="N2C.VismaNET.SubscriptionHandler" Version="1.0.0" />
paket add N2C.VismaNET.SubscriptionHandler --version 1.0.0
#r "nuget: N2C.VismaNET.SubscriptionHandler, 1.0.0"
// Install N2C.VismaNET.SubscriptionHandler as a Cake Addin #addin nuget:?package=N2C.VismaNET.SubscriptionHandler&version=1.0.0 // Install N2C.VismaNET.SubscriptionHandler as a Cake Tool #tool nuget:?package=N2C.VismaNET.SubscriptionHandler&version=1.0.0
Subscription Handler
This package is a handler for the Visma.NET API and can be used to manage Subscriptions from the Visma.NET API. The project is written in C# and uses the .NET Core framework.
Installation
You can install the package from NuGet.
dotnet add package N2C.VismaNET.SubscriptionHandler
Version
The current version is 1.0.0 and this is the first version of the package.
Getting Started
You need to have a valid token to be able to use the API. You can get a token by using the Visma.net API Authentication. You can use the N2C.VismaNET.Token package.
The data model for the Subscription is located in the N2C.VismaNET.DTOs.Subscription namespace.
Usage
Use N2C.VismaNET.EventHandler to get available events.
var eventHandler = new N2C.VismaNET.EventHandler.Get(AccessToken, TENANT);
var events = eventHandler.GetEventsAsync().Result;
Get
To get subscriptions you need to use the Get class. Use the method GetSubscriptionsAsync to get all subscriptions.
var getsubscriptionHandler = new N2C.VismaNET.SubscriptionHandler.Get(AccessToken, TENANT);
var subscriptions = getsubscriptionHandler.GetSubscriptionsAsync().Result;
subscriptions.ToList().ForEach(s =>
{
Console.WriteLine($"{s.Id} - {s.Event} - {s.HookUri}");
});
To get a single subscription you need to use the GetSubscriptionAsync method and provide the subscription id.
var subscription = getsubscriptionHandler.GetSubscriptionAsync(1).Result;
Post
To create a subscription you need to use the Post class. The method CreateSubscriptionAsync returns a Subscription and can be used to get the Id of the created subscription.
var postsubscriptionHandler = new N2C.VismaNET.SubscriptionHandler.Post(AccessToken, TENANT);
var create = postsubscriptionHandler.CreateSubscriptionAsync(new Subscription()
{
Event = "project_changed",
HookUri = "https://webhook.site/8e7f6f8a-8b36-11ed-9891-0693d8a7c3dd"
}).Result;
Put
Use Put to update a subscription. The subscription id is required. The method UpdateSubscriptionAsync returns a HttpResponseMessage and can be used to check the status code and reason phrase.
var putSubscriptionHandler = new N2C.VismaNET.SubscriptionHandler.Put(AccessToken, TENANT);
subscriptions.FirstOrDefault().HookUri = "https://webhookproxy.n2c.se/8e7f6f8a-8b36-11ed-9891-0693d8a7c3dd";
var update = putSubscriptionHandler.UpdateSubscriptionAsync(subscriptions.FirstOrDefault()).Result;
Delete
var deleteSubscriptionHandler = new N2C.VismaNET.SubscriptionHandler.Delete(AccessToken, TENANT);
subscriptions.ToList().ForEach(s =>
{
Console.WriteLine($"{s.Id} - {s.Event} - {s.HookUri}");
var result = deleteSubscriptionHandler.DeleteSubscriptionAsync(s.Id).Result;
Console.WriteLine($"{(int)result.StatusCode} - {result.ReasonPhrase}");
});
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net7.0
- N2C.VismaNET.DTOs (>= 1.0.6)
- N2C.VismaNET.HttpBase (>= 1.0.4)
- N2C.VismaNET.Interfaces (>= 1.0.0)
- N2C.VismaNET.Token (>= 1.0.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.0 | 158 | 1/31/2024 |