Metadata-Version: 2.4
Name: masstack-python-client
Version: 0.0.2
Summary: This Python API client provides access to masmovil core API domains
Author-email: Borja Gimeno <borja.gimeno@somconnexio.coop>
License: GPL-3.0-only
Project-URL: Homepage, https://git.coopdevs.org/coopdevs/som-connexio/masmovil/masstack-python-client
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: POSIX :: Linux
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: joserfc
Dynamic: license-file

[![Latest Release](https://git.coopdevs.org/coopdevs/som-connexio/masmovil/masstack-python-client/-/badges/release.svg)](https://git.coopdevs.org/coopdevs/som-connexio/masmovil/masstack-python-client/-/releases)
[![pipeline status](https://git.coopdevs.org/coopdevs/som-connexio/masmovil/masstack-python-client/badges/main/pipeline.svg)](https://git.coopdevs.org/coopdevs/som-connexio/masmovil/masstack-python-client/-/commits/main)
[![coverage report](https://git.coopdevs.org/coopdevs/som-connexio/masmovil/masstack-python-client/badges/main/coverage.svg)](https://git.coopdevs.org/coopdevs/som-connexio/masmovil/masstack-python-client/-/commits/main)

:warning: WORK IN PROGRESS :warning:

This Python API client provides access to masmovil core API domains.

## Resources

* Feasibility
    - Coverage - find an address
        - Streets:
            - search: returns a list of street by text
            - get_building_info_by_street: returns a list of building info by street id
        - Buildings:
            - search: returns a list of buildings by text
            - multi_search: returns a list of buildings by request body
            - get: returns a building by id with a list of units
        - Units:
            - get: returns a unit by id with a list of coverages
            - get_coverage: returns coverage info for a unit id and territory_owner

## Installation

```commandline
$ pip install masstack-python-client
```

## Configuration Environment

You need define the Masstack CLIENT_EMAIL, PRIVATE_KEY_ID TOKEN_URI, MASSTACK_DOMAIN and PRIVATE_KEY in BASE64 as environment variables to request access toekn. You need define:

```
MASSTACK_CLIENT_EMAIL=<YOUR CLIENT EMAIL>
MASSTACK_PRIVATE_KEY_ID=<YOUR PRIVATE KEY ID>
MASSTACK_TOKEN_URI=<MASSTACK TOKEN URI>
MASSTACK_PRIVATE_KEY_BASE64=<YOUR PRIVATE KEY in BASE64>
MASSTACK_DOMAIN=<MASSTACK DOMAIN>

```

If this envvars are not defined, a exception will be raised with the name of the envvar not defined.

Optional TOKEN_STORE_PATH environment variable to store token, if is not defined by defect is /tmp/masstack.token

```
MASSTACK_TOKEN_STORE_PATH=<YOUR PATH>

```

To all resources need define ORG_ID

```
MASSTACK_ORG_ID=<MASSTACK ORG ID>

```

For coverage resources need define COVERAGE_SEGMENT and COVERAGE_CHANNEL

```
MASSTACK_COVERAGE_SEGMENT=<SF SEGMENT>
MASSTACK_COVERAGE_CHANNEL=<SF CHANNEL>

```

## Development

### Setup environment

1. Install `pyenv`
```sh
curl https://pyenv.run | bash
```
2. Build the Python version
```sh
pyenv install 3.11.9
```
3. Create a virtualenv
```sh
pyenv virtualenv 3.11.9 masstack-python-client
```
4. Activate virtualenv
```sh
pyenv activate masstack-python-client
```
5. Install dependencies
```sh
pyenv exec pip install -r requirements-dev.txt
```
6. Install pre-commit hooks
```sh
pyenv exec pre-commit install
