# Documentation

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [BalancesService](#balancesservice)
    -   [createNewDocument](#createnewdocument)
    -   [getLinkAmazonS3Uploader](#getlinkamazons3uploader)
    -   [requestTaxpayerDocument](#requesttaxpayerdocument)
    -   [createTaxpayerDocument](#createtaxpayerdocument)
    -   [checkBalanceByUserId](#checkbalancebyuserid)
    -   [requestTaxpayerInfo](#requesttaxpayerinfo)
    -   [requestTransactionInfo](#requesttransactioninfo)
    -   [requestTransactionList](#requesttransactionlist)
    -   [requestBalances](#requestbalances)
    -   [createPaymentMethod](#createpaymentmethod)
    -   [createPaymentMethod](#createpaymentmethod-1)
    -   [createWithdrawRequest](#createwithdrawrequest)
    -   [requestUserPaymentMethods](#requestuserpaymentmethods)
    -   [requestUserWithdrawInformation](#requestuserwithdrawinformation)
    -   [getBalanceByOrderId](#getbalancebyorderid)

## BalancesService

-   **See: <https://jsonplaceholder.typicode.com/>**

Balances Micro Service API

**Parameters**

-   `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** service url
-   `token` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** user access tocken if available (optional, default `null`)

### createNewDocument

Creates new document based on your user_id ("transactions" scope is needed)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.createNewDocument();
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response

### getLinkAmazonS3Uploader

Return link to upload your file ("transactions" scope is needed)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.getLinkAmazonS3Uploader();
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response

### requestTaxpayerDocument

Returns taxpayer own document by his access_token ("transactions" scope is required)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.requestTaxpayerDocument();
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response

### createTaxpayerDocument

Create taxpayer info or update existent one

**Parameters**

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object with arguments
    -   `args.type` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** taxpayer info type (required)
    -   `args.countryId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Char code of "Country or Country Residence" (required)
    -   `args.countryId2` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Char code of "Country citizenship or Country incorporation"
    -   `args.stateId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Char code of "State / Province ID"
    -   `args.city` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** City
    -   `args.zip` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** ZIP-code
    -   `args.address` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Street & apt. or suite no.
    -   `args.address2` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Permanent residence address
    -   `args.personNumberType` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Tax Number for individual (e.g. "Foreign Tax ID Number")
    -   `args.companyNumberType` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Tax Number for Corporation (e.g. "Employer Identification Number(EIN)")
    -   `args.taxIdNumber` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Tax ID number (XXX-XX-XXXX)
    -   `args.taxClassification` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Tax classification
    -   `args.name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Name (shown on your income tax return)
    -   `args.businessName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Business name
    -   `args.organizationName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Name of organization
    -   `args.disregardedEntity` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Name of disregarded entity
    -   `args.chapter3Status` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Chapter 3 status
    -   `args.signature` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Signature
    -   `args.residenceNumbers` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Residence numbers (optional) (not implemented yet)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.createTaxpayerDocument({});
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response

### checkBalanceByUserId

Check balance of the specified user

**Parameters**

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** user id

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.checkBalanceByUserId();
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array with balances info

### requestTaxpayerInfo

Returns taxpayer own information by his access_token

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.requestTaxpayerInfo();
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array with balances info

### requestTransactionInfo

Returns taxpayer own information by his access_token

**Parameters**

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Transaction unique ID

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.requestTransactionInfo('1');
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array with balances info

### requestTransactionList

Request Transactions list of authenticated user by balance type

**Parameters**

-   `args` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** object of params
    -   `args.balanceType` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Balance type
    -   `args.types` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** filter by transactions types divided by comma (e.g. types: 'sale,refund')
    -   `args.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Balance type filter by transactions type (e.g. type: 'sale')

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.requestTransactionInfo('1');
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array with balances info

### requestBalances

Request balance of authenticated user by type or default

**Parameters**

-   `balanceType` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** type of balance needed (vendor|bonus)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.requestBalances();
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array with balances info

### createPaymentMethod

Creates new payment method ("transactions" scope is needed)

**Parameters**

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object with arguments
    -   `args.paymentMethod` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Payment method (paypal, wire, skrill, payoneer) (required)
    -   `args.email` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** E-mail (required for paypal & skrill)
    -   `args.fullName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** First & last name (required for wire)
    -   `args.address` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Address (required for wire)
    -   `args.country` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Country char code (required for wire)
    -   `args.swiftCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** SWIFT-code (required for wire)
    -   `args.bankAccountId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Bank account number (required for wire)
    -   `args.bankName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Bank name (required for wire)
    -   `args.bankAddress` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Bank address (required for wire)
    -   `args.payonnerId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** (required for payoneer)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.createPaymentMethod({});
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response

### createPaymentMethod

Updates existed payment method ("transactions" scope is needed)

**Parameters**

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object with arguments
    -   `args.paymentMethod` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Payment method (paypal, wire, skrill, payoneer) (required)
    -   `args.email` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** E-mail (required for paypal & skrill)
    -   `args.fullName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** First & last name (required for wire)
    -   `args.address` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Address (required for wire)
    -   `args.country` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Country char code (required for wire)
    -   `args.swiftCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** SWIFT-code (required for wire)
    -   `args.bankAccountId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Bank account number (required for wire)
    -   `args.bankName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Bank name (required for wire)
    -   `args.bankAddress` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Bank address (required for wire)
    -   `args.payonnerId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** (required for payoneer)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.createPaymentMethod({});
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response

### createWithdrawRequest

Creates new withdraw request ("transactions" scope is needed)

**Parameters**

-   `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object with arguments
    -   `args.amount` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** amount to withdraw (must be greater than balance) (required)
    -   `args.paymentMethod` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Payment method (paypal, wire, skrill, payoneer) (required)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.createWithdrawRequest({});
})();
```

Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response

### requestUserPaymentMethods

Get all user payment methods ("transactions" scope is needed)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.requestUserPaymentMethods();
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array with balances info

### requestUserWithdrawInformation

Return user own last withdraw request ("transactions" scope is needed)

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
  const balances = await balancesService.requestUserPaymentMethods();
})();
```

Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array with balances info

### getBalanceByOrderId

Transaction - Request balance of order for balance_type

**Parameters**

-   `params` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.orderId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Order id (required).
    -   `params.balanceType` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Balance type.

**Examples**

```javascript
(async () => {
  const balancesService = new BalancesService('http://service-balances.dev/api/v2/');
  const request = await balancesService.getBalanceByOrderId(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;any>** 
