0.0.24 • Published 5 months ago

twinfield v0.0.24

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Twinfield Node.js SDK

Project Status

Alpha: This project is currently in the alpha phase of development. It's actively being developed, tested, and improved. Please note that it may contain bugs or incomplete features.

Introduction

Welcome to the Twinfield Node.js SDK, a community-driven project aimed at providing a Node.js SDK for Twinfield, a leading accounting software. Twinfield primarily supports SOAP XML API requests for most of its functionalities, while its OAuth authentication supports RESTful requests. This package facilitates the conversion of XML data to JSON and vice versa, making it easier for Node.js developers to interact with Twinfield's SOAP API.

As of now, there is no official Twinfield SDK for Node.js, and we wanted to give something back to the community by starting this project. Below, you'll find a table indicating the supported actions and their status.

Twinfield API Documentation

Supported Actions

ActionAPIStatus
Authentication
OpenID Connect AuthenticationMaster DataTesting
Master Data
CustomersMaster DataTesting
SuppliersMaster DataNot Yet Developed
General LedgerMaster DataNot Yet Developed
Cost CentersMaster DataNot Yet Developed
Fixed AssetsMaster DataNot Yet Developed
ProjectsMaster DataNot Yet Developed
ActivitiesMaster DataNot Yet Developed
Dimension GroupsMaster DataNot Yet Developed
Dimension TypesMaster DataNot Yet Developed
Asset MethodsMaster DataNot Yet Developed
OfficesMaster DataNot Yet Developed
UsersMaster DataNot Yet Developed
ArticlesMaster DataNot Yet Developed
CurrenciesMaster DataNot Yet Developed
RatesMaster DataNot Yet Developed
BudgetMaster DataNot Yet Developed
Bank BookMaster DataNot Yet Developed
Cash BookMaster DataNot Yet Developed
VATMaster DataNot Yet Developed
Transaction Data
Bank TransactionsTransaction DataNot Yet Developed
Cash TransactionsTransaction DataNot Yet Developed
Electronic Bank StatementsTransaction DataNot Yet Developed
Journal TransactionsTransaction DataNot Yet Developed
Purchase TransactionsTransaction DataNot Yet Developed
Sales InvoicesTransaction DataNot Yet Developed
Sales TransactionsTransaction DataNot Yet Developed
Reversal TransactionsTransaction DataNot Yet Developed
Spread TransactionsTransaction DataNot Yet Developed
Time
Deleted TransactionsTimeNot Yet Developed
Transaction Blocked ValueTimeNot Yet Developed
Request Data
Electronic Bank StatementsRequest DataNot Yet Developed
Browse DataRequest DataNot Yet Developed
Miscellaneous
DeclarationsMiscellaneousNot Yet Developed
FinderMiscellaneousNot Yet Developed
HierarchiesMiscellaneousNot Yet Developed
MatchingMiscellaneousNot Yet Developed
Undo MatchMiscellaneousNot Yet Developed
Pay & CollectMiscellaneousNot Yet Developed
PeriodsMiscellaneousNot Yet Developed

Getting Started

To get started with the Twinfield Node.js SDK, follow these steps:

Installation: Install the SDK in your Node.js project using either npm or yarn:

npm install twinfield

Import Twinfield: Import the Twinfield module into your code:

import Twinfield from "twinfield"

Obtaining a Twinfield Access Token:

To obtain a Twinfield Access Token, start by referring to the Twinfield API documentation. There, you'll find instructions on acquiring a clientId and clientSecret, as well as guidance on configuring the redirect API. You can access the documentation here.

Initialize the Twinfield client:

    const clientId = 'xxxxxxxxxxxxxxxxxxxxxxxx'
    const clientSecret= 'xxxxxxxxxxxxxxxxxxxxxxxx'
    const redirectUrl = 'http://localhost/redirect'


    const twf = new Twinfield(clientId, clientSecret, redirectUrl)

Retrieve the login URL to direct the user to log in. Implement the logic to redirect the end-user to the login URL.

    //get the login url to get the user to login to
    const loginUrl = twf.twinfieldLogin()
example output: "https://login.twinfield.com/auth/authentication/connect/authorize
?client_id=clientId
&redirect_uri=http://localhost/redirect
&response_type=code&scope=openid+twf.organisationUser+twf.user+twf.organisation+offline_access
&state=48fe85e4-41b0-447c-8e5c-3a23a7e835a4&nonce=6d4b4f16-8069-4ad0-88ee-49952043e68d"

Exchange the code for an access token.

    //exchange the code for a accessToken
    twf.exchangeCode('code')

You shouled now be authenticated with Twinfield via oAuth.

console.log(twf.accessToken)
console.log(twf.refreshToken)

Example: Reading a Dimension:

Here's an example of how to read a dimension using the SDK:

//In case you had stored the accessToken or refreshToken somehwere, then you can initialise by passing through the refreshtoken and the accessToken

const twf = new Twinfield(clientId, clientSecret, redirectUrl, refreshToken, accessToken)

const office = 'NLA001234'
const dimensionCode = '1001'
const dimType = 'DEB'

const dimension = await twf.readDimension(office, dimensionCode, dimTyp)

Contact

If you encounter any issues or have questions, please open an issue on our GitHub repository.

License

MIT

0.0.24

5 months ago

0.0.23

5 months ago

0.0.22

5 months ago

0.0.20

5 months ago

0.0.21

5 months ago

0.0.14

6 months ago

0.0.15

6 months ago

0.0.16

6 months ago

0.0.17

6 months ago

0.0.18

6 months ago

0.0.19

5 months ago

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago