Metadata-Version: 2.1
Name: a360-python-libraries
Version: 0.8.1
Summary: A collection of Python libraries for A360
License: Proprietary
Author: A360
Requires-Python: >=3.11,<4.0
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: boto3 (>=1.35.0,<2.0.0)
Requires-Dist: fastapi (==0.111.0)
Requires-Dist: pydantic (==2.8.2)
Requires-Dist: pydantic-settings (>=2.3.4,<3.0.0)
Requires-Dist: python-jose (>=3.3.0,<4.0.0)
Description-Content-Type: text/markdown

# a360-python-libraries

Python shared libraries for a360 applications

## License
This software is proprietary and is intended solely for use by Aesthetics-360 Inc.. Unauthorized use, distribution, or modification of this software outside of Aesthetics-360 Inc. is strictly prohibited.

## Add package into your project

```bash
poetry add a360-python-libraries
```

## Usage

### Role based access control

```python
from fastapi import APIRouter, Depends

from a360_security.depends import require_role
from a360_security.enums import Role

router = APIRouter()

@router.get(
    ...,
    dependencies=[Depends(require_role(Role.ADMIN))]
)
def get() -> dict:
    ...
```

You can provide multiple roles to the `require_role` dependency, and they will be checked in OR fashion.

```python
from fastapi import APIRouter, Depends

from a360_security.depends import require_role
from a360_security.enums import Role

router = APIRouter()

@router.get(
    ...,
    dependencies=[Depends(require_role(Role.ADMIN, Role.SERVICE))]
)
def get() -> dict:
    ...
```


### User dependency

```python
from fastapi import APIRouter, Depends

from a360_security.depends import require_user
from a360_security.dto import UserDTO

router = APIRouter()

@router.get(
    ...,
)
def get(user: UserDTO = Depends(require_user)) -> dict:
    ...
```


### Client platform

```python
from fastapi import APIRouter, Depends

from a360_security.depends import require_client_platform
from a360_security.enums import ClientPlatform

router = APIRouter()

@router.get(
    ...,
)
def get(client_platform: ClientPlatform = Depends(require_client_platform)) -> dict:
    ...
```

### Internal services

```python
from fastapi import APIRouter, Depends

from a360_services import get_dictionary_service
from a360_services.services import DictionaryService

router = APIRouter()

@router.get(
    ...,
)
def get(dict_service: DictionaryService = Depends(get_dictionary_service)) -> dict:
    medical_conditions = dict_service.get_medical_conditions()
```

### Email notification

```python
from fastapi import APIRouter, Depends

from a360_notification import get_mail_service
from a360_notification.services import AWSSesService

router = APIRouter()

@router.post(
    ...,
)
def create(mail_service: AWSSesService = Depends(get_mail_service)):
    mail_service.send_email(
        recipient_name='John Doe',
        recipient_address='john.doe@example.com',
        subject='Test email',
        html_content='<h1>Test email</h1>',
    )
```
