Fortnox.NET 3.3.0

dotnet add package Fortnox.NET --version 3.3.0                
NuGet\Install-Package Fortnox.NET -Version 3.3.0                
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="Fortnox.NET" Version="3.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Fortnox.NET --version 3.3.0                
#r "nuget: Fortnox.NET, 3.3.0"                
#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.
// Install Fortnox.NET as a Cake Addin
#addin nuget:?package=Fortnox.NET&version=3.3.0

// Install Fortnox.NET as a Cake Tool
#tool nuget:?package=Fortnox.NET&version=3.3.0                

<img src=".github/Banner.png" style="width:100%;">

Fortnox.NET

Tests Nuget

.NET bindings for the <a href="https://developer.fortnox.se/documentation/">Fortnox</a> API.

We at Zenta have worked with Fortnox integrations since 2017. During this time we have helped several companies connect their systems with Fortnox and their API. During this time we've gathered a lot of knowledge and established a good relation with Fortnox. Because of our good relaiton with Fortnox we have the opportunity to be first out with the latest technology and updates that Fortnox offers.

This SDK makes working with the Fortnox API much easier and allows the community to work together to help improve it.

Usage

To access the Fortnox API you need an Access Token and Client Secret: <a href="https://developer.fortnox.se/general/authentication/">https://developer.fortnox.se/general/authentication/</a>.

The unit tests in this repository serves as a way for us to make sure our code works as well as examples of how to call the different routes that the Fortnox API provides. There are mainly two ways to make a request using this SDK, one for requesting a list of resources and one for requesting a single resource.

Listed resource

When requesting a list of resources you create a ListRequest object of the type of resource you are interested in.

var request = new OrderListRequest("ACCESS-TOKEN", "CLIENT-SECRET");
var orders = await OrderService.GetOrdersAsync(request);

You can also add filters and ordering to routes that accepts it, for example:

var request = new EmployeeListRequest("ACCESS-TOKEN", "CLIENT-SECRET")
{
    Filter = EmployeeFilters.Active
};
var employeeList = await EmployeeService.GetEmployeesAsync(request);

Single resource

When requesting a single resource you create a FortnoxApiRequest object and pass that into the service to make your request.

var request = new FortnoxApiRequest("ACCESS-TOKEN", "CLIENT-SECRET");
var response = await ArticleService.GetArticleAsync(request, "100370");

WebSocket

If you want to subscribe to changes instead of having to poll for new information you can use the Fortnox WebSocket API. You start by creating a FortnoxWebSocketClient with your ClientSecret. Proceed with calling Connect to initiate the connection with Fortnox followed by adding the desired topics and tenants to your connection and once you're ready call Subscribe to start receiving events.

var client = new FortnoxWebSocketClient(this.connectionSettings.ClientSecret);
await client.Connect();
await client.AddTenant(this.connectionSettings.AccessToken);
await client.AddTopic(WebSocketTopic.Articles);
await client.Subscribe();

Once you're subscribed you can call Receive to receive incoming messages. Performing actions such as AddTenant, AddTopic and Subscribe also results in a message being returned, if you wish you can handle those as well. In the following snippet we see an example which stores all action responses in their own variables followed by a while loop listening for incoming events.

var client = new FortnoxWebSocketClient(this.connectionSettings.ClientSecret);
await client.Connect();

await client.AddTenant(this.connectionSettings.AccessToken);
var addTenantResponse = await client.Receive();

await client.AddTopic(WebSocketTopic.Articles);
var addTopicResponse = await client.Receive();

await client.Subscribe();
var subscribeResponse = await client.Receive();

while (ListenToIncomingEvents)
{
    var response = await client.Receive();
    if (response.Type == WebSocketResponseType.EventResponse)
    {
        // Handle events
    }

    if (response.Type == WebSocketResponseType.CommandResponse)
    {
        // Handle commands
    }
}

await client.Close();

More examples of how to use the Fortnox WebSocket API exists within the unit tests for the FortnoxWebSocketClient class.

Features

Bellow is a list of the supported API endpoints within the SDK.

  • Absence Transactions
  • Account Charts
  • Accounts
  • Archive
  • Article File Connections
  • Articles
  • Asset File Connections
  • Asset Types
  • Assets
  • Attendance Transactions
  • Company Information
  • Company Settings
  • Contracts
  • Contract Templates
  • Cost Centers
  • Currencies
  • Customers
  • Employees
  • Expenses
  • Finnancial Years
  • Inbox
  • Invoice Payments
  • Invoices
  • Labels
  • Locked Period
  • Modes of Payments
  • Offers
  • Orders
  • Predefined Accounts
  • Price Lists
  • Prices
  • Print Templates
  • Projects
  • Salary Transactions
  • SIE
  • Supplier Invoice External URL Connections
  • Supplier Invoice File Connections
  • Supplier Invoice Payments
  • Supplier Invoices
  • Suppliers
  • Tax Reductions
  • Terms of Deliveries
  • Terms of Payments
  • Trusted Email Domains
  • Units
  • Voucher Series
  • Vouchers
  • Way of Deliveries

WebSockets

This library also supports the Fortnox WebSocket API which allows the user to get notifications about changes instead of having to poll using the above API endpoints.

The supported topics to subscribe to for changes are the following:

  • Invoices
  • Customers
  • Orders
  • Offers
  • Articles
  • Currencies
  • TermsOfDeliveries
  • WaysOfDeliveries
  • TermsOfPayments

Contributing

Thank you for considering contributing to Fortnox.NET. This part of the document provides information on how to get the project to run and build the project.

Developing

The project is using a service oriented structure where you, for example, have ArticleService.cs that defines operations that you can perform for the Articles endpoint. For resources that can be filtered, sorted or ordered an additional helper object ArticleListRequest.cs is also created.

Testing

Currently the tests are only made to be working for our dataset, hence most of the tests will fail. If you are contributing to this project you are encouraged to make a test that would work for any dataset and not only ours.

License

MIT License

Copyright (c) 2022 Zenta AB

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.

Version Downloads Last updated
3.3.0 174 9/23/2024
3.2.0 2,212 5/4/2022
3.1.0 533 11/22/2021
3.0.0 624 6/3/2021
3.0.0-alpha3 266 6/2/2021
3.0.0-alpha2 250 1/27/2021
3.0.0-alpha 254 1/11/2021
2.5.3 689 12/4/2020
2.5.2 373 11/27/2020
2.4.1 397 11/13/2020
2.3.1 376 11/11/2020
2.2.1 440 10/14/2020
2.2.0 399 10/14/2020
2.1.0 460 10/5/2020
2.0.0 440 10/5/2020
1.1.0 442 8/26/2020
1.0.0 448 8/25/2020