Skip to content

Soneritics/Twinfield.API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Introduction

This project contains an API for Twinfield.

The API is based on the Twinfield API specification.

NuGet

The package is available via NuGet.org: Twinfield.API.TwinfieldAPI

Remarks

  • For now it's used primarily to get the data to show a balance sheet and profit & loss overview.
  • Not all Twinfield API functionality is provided by this API. Only the functionalities that I need for my projects.
  • BankBookService API is not included at all.

How to use

There is a complete documentation in the code (Demo project).

An quick example of how to use below.

// Create the TwinfieldApi
twinfieldApi = new TwinfieldApi(oauthClientSettings);

// First get the authorization URL
Console.WriteLine("Send the user to the following URL:");
Console.WriteLine(twinfieldApi.GetAuthorizationUrl(redirectUrl));

// Catch the authorization code in your own program, and paste it here
Console.Write("\n\nEnter the code: ");
var authenticationCode = Console.ReadLine();

// Get the access token
await twinfieldApi
    .SetAccessTokenByAuthorizationCodeAsync(authenticationCode, redirectUrl);

accessToken = twinfieldApi.Token;

if (twinfieldApi.Token.IsExpired())
{
    Console.WriteLine("Token expired, refreshing..");
}
else
{
    Console.WriteLine("Token is not expired. Still refreshing :-)");
    await Task.Delay(2000);
}

await twinfieldApi.RefreshTokenAsync();
accessToken = twinfieldApi.Token;
// You should save the refreshed token, so you
// can use it to call the Twinfield API the next time

// Office list
var officeList = await twinfieldApi.ServiceFactory.ProcessXmlDataService.GetOfficeList();

// Balance sheet fields
var balanceSheetFields = await twinfieldApi
    .ServiceFactory
    .FinderDataService
    .GetBalanceSheetFields(company);

// General ledger data
var data = GeneralLedgerRequestOptionsHelper
    .GetRequestList(
        list,
        fromYear,
        fromMonth,
        toYear,
        toMonth,
        GeneralLedgerRequestOptionsLists.MinimalList
    );

// More examples in PRogram.cs :-)

Contribute

Feel free to contribute to the project.

About

.NET Core API for Twinfield

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages