# idcloud-python

API Client communicating with THALES IdCloud REST API.

## Installation

```shell
# pip
pip install idcloud-python

# pipenv
pipenv install idcloud-python

# poetry
poetry add idcloud-python
```

## Example

### 1. Create Environment object

```python
from idcloud.configuration import Environment

environment = Environment(name='test-api', api_url='http://127.0.0.1:8000/')
```

---

### 2. Create Configuration object

```python
from idcloud.configuration import Configuration

configuration = Configuration(
    environment=environment,
    api_key='0e5e171f-1163-4277-9b48-68c3ba5816be',
    tenant_id='tenant-tenant-123',
    jti='tenant-jti',
    aud='tenant-aud',
    iss='tenant-iss',
    jwt_key_file='path-to-jwt-secret-key',
    mtls=(
        'path-to-mtls-cert',
        'path-to-mtls-key'
    ),
    roles=["scs:executeScenario"]
)
```

### 3. Create ApiClient object

```python
from idcloud.api_client import ApiClient

api_client = ApiClient(configuration=configuration)
```

### 4. Example Connect Verify Document

```python
from idcloud.enums.capture_method import CaptureMethod
from idcloud.enums.document_type import DocumentType
from idcloud.enums.status import Status


scenario = api_client.connect_verify_document.initiate_document_verification(
    front_white_image=image_data['front'],
    capture_method=CaptureMethod.MOBILE,
    document_type=DocumentType.ID
)

result = api_client.connect_verify_document.verify_results(scenario.id)

if result.status == Status.FINISHED:
    print('Process finished.')
elif result.status in [Status.WAITING, Status.RUNNING]:
    print('Verify results later, when finished.')
elif result.status in [Status.FAILURE, Status.ERROR]:
    print('Handle error or failure.')
```

## Tests

To run tests, you need to run command: `pytest`

Tests require access data to the api. For security reasons, access data is stored in environment variables. To set
environment variables, you need to create an `.env` file from the example in the `.env.example` file.

---
Developed by [BACKBONE s.r.o.](https://www.backbone.sk/) with ❤️ and ☕️, 2021 (C)
