# DocumentsApi

All URIs are relative to *http://localhost:8889/api*

|Method | HTTP request | Description|
|------------- | ------------- | -------------|
|[**createDocument**](#createdocument) | **POST** /documents | Create document|
|[**deleteDocumentById**](#deletedocumentbyid) | **DELETE** /documents/{documentId} | Delete document|
|[**downloadDocumentById**](#downloaddocumentbyid) | **GET** /documents/{documentId} | Download document|
|[**getDocumentsByEntityId**](#getdocumentsbyentityid) | **GET** /documents/documentsMetadata | Get all documents\&#39; metadata|

# **createDocument**
> Document createDocument()


### Example

```typescript
import {
    DocumentsApi,
    Configuration
} from './api';

const configuration = new Configuration();
const apiInstance = new DocumentsApi(configuration);

let file: File; //The file to be attached for a client. (default to undefined)
let idempotencyKey: string; //Key that can be used to support idempotency on this POST. Must be a valid UUID(version 4 is recommended) string and can only be used with the exact same request. Can be used in retry mechanisms to prevent double posting. (optional) (default to undefined)
let id: string; //The ID or encoded key of the entity that owns the document. The ID or encoded key must belong to the entity indicated by the `entity` parameter. Possible entity types are :`CLIENT`, `GROUP`, `LOAN_PRODUCT`, `SAVINGS_PRODUCT`, `CENTRE`, `BRANCH`, `USER`, `LOAN_ACCOUNT`, `DEPOSIT_ACCOUNT`, `ID_DOCUMENT`, `LINE_OF_CREDIT`, `GL_JOURNAL_ENTRY`. If the entity is `GL_JOURNAL_ENTRY`, the value can also represent the Journal Entry Transaction ID. (optional) (default to undefined)
let name: string; //The name (title) of the attached file. (optional) (default to undefined)
let notes: string; //The description of the attached file. (optional) (default to undefined)
let ownerType: string; //The type of the owner of the document. (optional) (default to undefined)

const { status, data } = await apiInstance.createDocument(
    file,
    idempotencyKey,
    id,
    name,
    notes,
    ownerType
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **file** | [**File**] | The file to be attached for a client. | defaults to undefined|
| **idempotencyKey** | [**string**] | Key that can be used to support idempotency on this POST. Must be a valid UUID(version 4 is recommended) string and can only be used with the exact same request. Can be used in retry mechanisms to prevent double posting. | (optional) defaults to undefined|
| **id** | [**string**] | The ID or encoded key of the entity that owns the document. The ID or encoded key must belong to the entity indicated by the &#x60;entity&#x60; parameter. Possible entity types are :&#x60;CLIENT&#x60;, &#x60;GROUP&#x60;, &#x60;LOAN_PRODUCT&#x60;, &#x60;SAVINGS_PRODUCT&#x60;, &#x60;CENTRE&#x60;, &#x60;BRANCH&#x60;, &#x60;USER&#x60;, &#x60;LOAN_ACCOUNT&#x60;, &#x60;DEPOSIT_ACCOUNT&#x60;, &#x60;ID_DOCUMENT&#x60;, &#x60;LINE_OF_CREDIT&#x60;, &#x60;GL_JOURNAL_ENTRY&#x60;. If the entity is &#x60;GL_JOURNAL_ENTRY&#x60;, the value can also represent the Journal Entry Transaction ID. | (optional) defaults to undefined|
| **name** | [**string**] | The name (title) of the attached file. | (optional) defaults to undefined|
| **notes** | [**string**] | The description of the attached file. | (optional) defaults to undefined|
| **ownerType** | [**string**] | The type of the owner of the document. | (optional) defaults to undefined|


### Return type

**Document**

### Authorization

[basic](../README.md#basic)

### HTTP request headers

 - **Content-Type**: multipart/form-data
 - **Accept**: application/vnd.mambu.v2+json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**102** | Your idempotent request was already submitted and is currently being processed, try again later. |  -  |
|**201** | Document created. |  -  |
|**400** | A validation error occurred |  -  |
|**401** | Unauthorized |  -  |
|**403** | Forbidden |  -  |
|**404** | Entity not found. |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **deleteDocumentById**
> deleteDocumentById()


### Example

```typescript
import {
    DocumentsApi,
    Configuration
} from './api';

const configuration = new Configuration();
const apiInstance = new DocumentsApi(configuration);

let documentId: string; //The ID or encoded key of the document to be deleted.<br>The ID or encoded key of the document can be found by using the GET /documents/documentsMetadata API. (default to undefined)

const { status, data } = await apiInstance.deleteDocumentById(
    documentId
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **documentId** | [**string**] | The ID or encoded key of the document to be deleted.&lt;br&gt;The ID or encoded key of the document can be found by using the GET /documents/documentsMetadata API. | defaults to undefined|


### Return type

void (empty response body)

### Authorization

[basic](../README.md#basic)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/vnd.mambu.v2+json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**204** | Successfully deleted the document. |  -  |
|**400** | A validation error occurred |  -  |
|**401** | Unauthorized |  -  |
|**403** | Forbidden |  -  |
|**404** | Document was not found. |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **downloadDocumentById**
> File downloadDocumentById()


### Example

```typescript
import {
    DocumentsApi,
    Configuration
} from './api';

const configuration = new Configuration();
const apiInstance = new DocumentsApi(configuration);

let documentId: string; //The ID or encoded key of the document to be returned.<br>The ID or encoded key of the document can be found by using the GET /documents/documentsMetadata API. (default to undefined)

const { status, data } = await apiInstance.downloadDocumentById(
    documentId
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **documentId** | [**string**] | The ID or encoded key of the document to be returned.&lt;br&gt;The ID or encoded key of the document can be found by using the GET /documents/documentsMetadata API. | defaults to undefined|


### Return type

**File**

### Authorization

[basic](../README.md#basic)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/vnd.mambu.v2+file


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**200** | Document downloaded. |  * Content-Disposition - \&quot;The format is - attachment; filename&#x3D;\\\&quot;{fileName}.extension\\\&quot;\&quot;; <br>  * Content-Length - The size of the file. <br>  |
|**400** | A validation error occurred |  -  |
|**401** | Unauthorized |  -  |
|**403** | Forbidden |  -  |
|**404** | Entity not found. |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **getDocumentsByEntityId**
> Array<Document> getDocumentsByEntityId()


### Example

```typescript
import {
    DocumentsApi,
    Configuration
} from './api';

const configuration = new Configuration();
const apiInstance = new DocumentsApi(configuration);

let entity: 'CLIENT' | 'GROUP' | 'LOAN_PRODUCT' | 'SAVINGS_PRODUCT' | 'CENTRE' | 'BRANCH' | 'USER' | 'LOAN_ACCOUNT' | 'DEPOSIT_ACCOUNT' | 'ID_DOCUMENT' | 'LINE_OF_CREDIT' | 'GL_JOURNAL_ENTRY'; //The type of the owner of the document. (default to undefined)
let ownerKey: string; //The ID or encoded key of the entity that owns the document. The ID or encoded key must belong to the entity indicated by the `entity` parameter. Possible entity types are :`CLIENT`, `GROUP`, `LOAN_PRODUCT`, `SAVINGS_PRODUCT`, `CENTRE`, `BRANCH`, `USER`, `LOAN_ACCOUNT`, `DEPOSIT_ACCOUNT`, `ID_DOCUMENT`, `LINE_OF_CREDIT`, `GL_JOURNAL_ENTRY`. If the entity is `GL_JOURNAL_ENTRY`, the value can also represent the Journal Entry Transaction ID. (default to undefined)
let offset: number; //Pagination, index to start searching at when retrieving elements, used in combination with limit to paginate results (optional) (default to undefined)
let limit: number; //Pagination, the number of elements to retrieve, used in combination with offset to paginate results (optional) (default to undefined)
let paginationDetails: 'ON' | 'OFF'; //Flag specifying whether the pagination  details should be provided in response headers. Please note that by default it is disabled (OFF), in order to improve the performance of the APIs (optional) (default to 'OFF')

const { status, data } = await apiInstance.getDocumentsByEntityId(
    entity,
    ownerKey,
    offset,
    limit,
    paginationDetails
);
```

### Parameters

|Name | Type | Description  | Notes|
|------------- | ------------- | ------------- | -------------|
| **entity** | [**&#39;CLIENT&#39; | &#39;GROUP&#39; | &#39;LOAN_PRODUCT&#39; | &#39;SAVINGS_PRODUCT&#39; | &#39;CENTRE&#39; | &#39;BRANCH&#39; | &#39;USER&#39; | &#39;LOAN_ACCOUNT&#39; | &#39;DEPOSIT_ACCOUNT&#39; | &#39;ID_DOCUMENT&#39; | &#39;LINE_OF_CREDIT&#39; | &#39;GL_JOURNAL_ENTRY&#39;**]**Array<&#39;CLIENT&#39; &#124; &#39;GROUP&#39; &#124; &#39;LOAN_PRODUCT&#39; &#124; &#39;SAVINGS_PRODUCT&#39; &#124; &#39;CENTRE&#39; &#124; &#39;BRANCH&#39; &#124; &#39;USER&#39; &#124; &#39;LOAN_ACCOUNT&#39; &#124; &#39;DEPOSIT_ACCOUNT&#39; &#124; &#39;ID_DOCUMENT&#39; &#124; &#39;LINE_OF_CREDIT&#39; &#124; &#39;GL_JOURNAL_ENTRY&#39;>** | The type of the owner of the document. | defaults to undefined|
| **ownerKey** | [**string**] | The ID or encoded key of the entity that owns the document. The ID or encoded key must belong to the entity indicated by the &#x60;entity&#x60; parameter. Possible entity types are :&#x60;CLIENT&#x60;, &#x60;GROUP&#x60;, &#x60;LOAN_PRODUCT&#x60;, &#x60;SAVINGS_PRODUCT&#x60;, &#x60;CENTRE&#x60;, &#x60;BRANCH&#x60;, &#x60;USER&#x60;, &#x60;LOAN_ACCOUNT&#x60;, &#x60;DEPOSIT_ACCOUNT&#x60;, &#x60;ID_DOCUMENT&#x60;, &#x60;LINE_OF_CREDIT&#x60;, &#x60;GL_JOURNAL_ENTRY&#x60;. If the entity is &#x60;GL_JOURNAL_ENTRY&#x60;, the value can also represent the Journal Entry Transaction ID. | defaults to undefined|
| **offset** | [**number**] | Pagination, index to start searching at when retrieving elements, used in combination with limit to paginate results | (optional) defaults to undefined|
| **limit** | [**number**] | Pagination, the number of elements to retrieve, used in combination with offset to paginate results | (optional) defaults to undefined|
| **paginationDetails** | [**&#39;ON&#39; | &#39;OFF&#39;**]**Array<&#39;ON&#39; &#124; &#39;OFF&#39;>** | Flag specifying whether the pagination  details should be provided in response headers. Please note that by default it is disabled (OFF), in order to improve the performance of the APIs | (optional) defaults to 'OFF'|


### Return type

**Array<Document>**

### Authorization

[basic](../README.md#basic)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/vnd.mambu.v2+json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
|**200** | Successfully returned the list of all documents metadata. |  * Items-Limit - Pagination details, the requested page size <br>  * Items-Offset - Pagination details, the index of the first returned item <br>  * Items-Total - Pagination details, the total available items <br>  |
|**400** | A validation error occurred |  -  |
|**401** | Unauthorized |  -  |
|**403** | Forbidden |  -  |
|**404** | Entity not found. |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

