npm package: @leantechnologies/node-sdk
Description: Lean NodeJS server side library
Author: Amr Essam
Latest version: 0.3.2

## Lean Tecnhologies NodeJS SDK

NodeJS SDK to interact with the Lean API.

More information [leantech.me](https://leantech.me)

## Installation

Install from NPM Registry

```javascript
npm install -S @leantechnologies/node-sdk
```

## Requirements

> Make sure you have your App Token, Certificates and Webhook secret set.

To get your App Token and Certificates, please register [dev.leantech.me](https://dev.leantech.me) and create and account.

Keep your certificates (certificate, private key, certificate chain) in a secure location. 

## Getting started

Import Lean package, as well as Environment type

```javascript
import Lean from '@leantechnologies/node-sdk'
import { Environment } from '@leantechnologies/node-sdk/dist/types/LeanSettings'
```

Create the Lean object, referencing the requirements above (App Token, Certificates and Webhook secret)

```javascript
this._lean = new Lean(LEAN_APP_TOKEN, Environment.PRODUCTION, { 
        ca: "static/certs/cachain.crt", 
        cert: "static/certs/cert.crt",
        key: "static/certs/key.pem"
      }, WEBHOOK_SECRET)
    }
```

You're ready to call Lean API using the NodeJS SDK. 
Example:

```javascript
async _getSupportedBanks(): Promise<any>{
  return await this._lean.getSupportedBanks()
}
```

You should get a list of supported banks in the response.

## Reference

<a name="createCustomer"></a>

## createCustomer(appUserId)


| Param | Type |
| --- | --- |
| appUserId | <code>string</code> |

<a name="getIdentity"></a>

## getIdentity(customerId)


| Param | Type |
| --- | --- |
| customerId | <code>string</code> | 

<a name="getAccounts"></a>

## getAccounts(customerId)


| Param | Type |
| --- | --- |
| customerId | <code>string</code> | 

<a name="getBalance"></a>

## getBalance(customerId, accountId)


| Param | Type |
| --- | --- |
| customerId | <code>string</code> | 
| accountId | <code>string</code> | 

<a name="getTransactions"></a>

## getTransactions(customerId, accountId, startDate, endDate, insights)


| Param | Type |
| --- | --- |
| customerId | <code>string</code> | 
| accountId | <code>string</code> | 
| startDate | <code>string</code> | 
| endDate | <code>string</code> | 
| insights | <code>boolean</code> | 

<a name="getSupportedBanks"></a>

## getSupportedBanks()

<a name="getAppPaymentDestinations"></a>

## getAppPaymentDestinations()

<a name="getCustomerPaymentDestinations"></a>

## getCustomerPaymentDestinations(customerId)


| Param | Type |
| --- | --- |
| customerId | <code>string</code> | 

<a name="createAppPaymentDestination"></a>

## createAppPaymentDestination(displayName, name, bankIdentifier, address, city, country, accountNumber, iban, swiftCode)


| Param | Type |
| --- | --- |
| displayName | <code>string</code> | 
| name | <code>string</code> | 
| bankIdentifier | <code>LeanBankIdentifiers</code> \| <code>string</code> | 
| address | <code>string</code> | 
| city | <code>string</code> | 
| country | <code>LeanCountries</code> \| <code>string</code> | 
| accountNumber | <code>string</code> | 
| iban | <code>string</code> | 
| swiftCode | <code>string</code> | 

<a name="createCustomerPaymentDestination"></a>

## createCustomerPaymentDestination(customerId, displayName, name, bankIdentifier, address, city, country, accountNumber, iban, swiftCode)


| Param | Type |
| --- | --- |
| customerId | <code>string</code> | 
| displayName | <code>string</code> | 
| name | <code>string</code> | 
| bankIdentifier | <code>LeanBankIdentifiers</code> \| <code>string</code> | 
| address | <code>string</code> | 
| city | <code>string</code> | 
| country | <code>LeanCountries</code> \| <code>string</code> | 
| accountNumber | <code>string</code> | 
| iban | <code>string</code> | 
| swiftCode | <code>string</code> | 

<a name="getCustomerPaymentSources"></a>

## getCustomerPaymentSources(customerId)


| Param | Type |
| --- | --- |
| customerId | <code>string</code> | 

<a name="createPaymentIntent"></a>

## createPaymentIntent(amount, currency, description, paymentDestinationId, customerId)


| Param | Type |
| --- | --- |
| amount | <code>number</code> | 
| currency | <code>string</code> | 
| description | <code>string</code> | 
| paymentDestinationId | <code>string</code> | 
| customerId | <code>string</code> | 

<a name="getPaymentIntent"></a>

## getPaymentIntent(paymentIntentId)


| Param | Type |
| --- | --- |
| paymentIntentId | <code>string</code> | 

<a name="verifyWebhook"></a>

## verifyWebhook(webhookData, webhookSignature)


| Param | Type |
| --- | --- |
| webhookData | <code>string</code> | 
| webhookSignature | <code>string</code> | 


##### Last Updated: December 10, 2021