Skip to content

VincentVrijburg/moneybird-dotnet

Repository files navigation

Moneybird.Net

.NET Standard build codecov Nuget (with prereleases)

Moneybird client for .NET Framework and .NET (Core).

Table of Contents

Installation

Installation instructions will get updated as the project matures

Install Moneybird.Net through NuGet:

PM> Install-Package Moneybird.Net

Usage

Usage instructions will get updated as the project matures

Configuration

For both the authenticator and the client, an instance of the moneybird configuration is required.

Note: both options will create an instance with the default api url and default authentication url values assigned.

Option 1

In case you do not need to use the OAuth functionality, you can create the default config as follows.

var moneybirdConfig = new MoneybirdConfig();

Option 2

In case you do need to use the OAuth functionality, you can create a custom config as follows.

var moneybirdConfig = new MoneybirdConfig("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "YOUR_REDIRECT_URI");

Authenticator

In order to access the resources of foreign administrations, you first need to authenticate the user.

The main entry point to the authentication endpoint can be established as follows

using var authenticator = new MoneybirdAuthenticator(moneybirdConfig);

Request token uri

// An array of scopes you need access to.
var scopes = new[] {AuthScope.SalesInvoices, AuthScope.Bank};
var uri = authenticator.GetRequestTokenUri(scopes);

Redirect the user to this uri to get the actual request token.

Request access token

// Pass the request token to request the access token.
var accessToken = await authenticator.GetAccessTokenAsync(requestToken);

Refresh access token

// Pass the refresh token from the access token object to refresh the access token.
var accessToken = await authenticator.RefreshAccessTokenAsync(refreshToken);

Client

In order to access the API, an instance of the moneybird configuration is required.

Create singleton entry point

var client = MoneybirdClient.GetInstance(config);

Create disposable entry point

using var moneybirdClient = new MoneybirdClient(config);
using var moneybirdClient = new MoneybirdClient(config, httpClient);

Request data

See the example below to learn how to request a list of administrations.

try
{
  var administrations = await client.Administration.GetAdministrationsAsync("{ACCESS_TOKEN}");
  var id = administrations[0].Id;
  var name = administrations[0].Name;
  var language = administrations[0].Language;
  var currency = administrations[0].Currency;
}
catch (MoneybirdException ex)
{
  // Handle the exception however you want.
}

Supported endpoints

We're continuously working on expanding this library to include additional endpoints, giving you even more options and functionality.

To see the full list of currently supported endpoints, and get a glimpse of what's coming next, head over to our roadmap.

Roadmap

See our roadmap for an overview of what we are planning to work on and in what time frame.

Versioning

This project uses Semver v2.0 and is currently in initial development.

License

Copyright (c) 2021 Vincent Vrijburg
Licensed under the MIT license.

Disclaimer

This package is not an official library for the Moneybird API and doesn't reflect the views or opinions of Moneybird B.V. or anyone officially involved in producing or managing Moneybird.

Not all endpoints are implemented and/or tested. Use at your own risk.