# abacus-common-data

This library holds references to slow moving data to be used by ABACUS:
* countries
* currencies
* orchard countries
* stores
* transaction types

This library is designed to provide domain specific standardized
data objects with currencies and countries data,
compatible with iso-3166 standard.

Installation
------------

```bash
pip install -i https://pypi.theorchard.io/pypi/ abacus-common-data
```

Local installation
------------

If you make any changes to the library and want test it locally before publishing to the Orchard's pypi,
you can do that by navigating to the root of the package and running following command:
```bash
make local_install
```

If you want to include this library package to your project locally, then run either of the following commands to the root of the package:

```bash
make generate_whl
```
or
```bash
make generate_tar_gz
```

The above commands will create .whl or .tar.gz file in the /dist folder.  Just copy this .whl or .tar.gz file to root of the project and in requirements.txt of the project include library package as below:

```bash
file:Package-Name.whl or file:Package-Name.tar.gz
```


Usage
-----

#### Currencies

```python

from abacus_common_data.currency import get_currency_object_from_code


print(get_currency_object_from_code('UDS'))
# {'currency_id': 840, 'currency_code': 'USD', 'currency_name': 'US Dollar'}

```

#### Countries

Country can be initialized either via alpha2 or alpha3 or numeric codes.

```python

from abacus_common_data.country import Country


usa = Country('USA')
# or
usa = Country('US')
# or
usa = Country('840')

print(usa.to_dict())
# {
#   'alpha2': 'US',
#   'alpha3': 'USA',
#   'numeric': '840',
#   'name': 'United States of America',
#   'region': 'Americas'
# }
```

#### Stores

```python

from abacus_common_data.store import Store

Store(1)
Store._get_data(1)
# {'store_id': 1, 'store_name': 'iTunes/Apple'}

Store.list_all_stores()
```

#### Transaction Types

```python

from abacus_common_data.transaction_type import TransactionType

TransactionType('RB')
TransactionType._get_data('RB')
# {'txn_type_id': 5, 'txn_type_code': 'RB', 'txn_type_desc': 'Ringbacks'}

TransactionType.list_all_txn_types()
```
