PYTHON-MOLONI
==============
Welcome to the Moloni API Client! This Python package provides a simple and flexible way to interact with the Moloni API. It supports a wide range of endpoints and allows you to manage your Moloni account programmatically.
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Documentation](#documentation)
- [Usage](#usage)
- [Full Configuration](#full-configuration)
- [Models as Entrypoints](#models-as-entrypoints)
- [Minimal Configuration](#minimal-configuration)
- [Credentials](#credentials)
- [API Response Handling](#api-response-handling)
- [Supported Endpoints](#supported-endpoints)
- [License](#license)
## Features
- **Comprehensive Coverage:** Supports all Moloni API endpoints.
- **Flexible Configuration:** Easily configure and authenticate your requests.
- **Built-in Models:** Utilize predefined Pydantic models for request validation.
## Installation
You can install the Moloni API Client using pip:
```bash
pip install python-moloni
```
## Documentation
[Documentation is available here](https://python-moloni.readthedocs.io/en/latest/index.html)
## Usage
### Full Configuration
You can set up a fully configured client with all necessary authentication details:
```python
from moloni.api.companies_client import CompaniesClient
from moloni.base import AuthConfig, MoloniBaseUrl
import logging
logger = logging.getLogger(__name__)
companies = CompaniesClient(
environment=MoloniBaseUrl.PROD,
auth_config=AuthConfig(
client_id="your_client_id",
client_secret="your_client_secret",
username="your_username", # Optional if refresh_token is set
password="your_password", # Optional if refresh_token is set
refresh_token="your_refresh_token", # Optional if username and password are set
),
log_level="INFO",
version="v1",
validate=True,
)
logger.info(companies.get_all())
```
### Models as Entrypoints
You can also use the predefined models as entrypoints to the API:
```python
from moloni.api import CustomersGetBySearchModel
from moloni.base import AuthConfig, MoloniBaseUrl
from pprint import pprint
auth_config = AuthConfig(
client_id="your_client_id",
client_secret="your_client_secret",
username="your_username", # Optional if refresh_token is set
password="your_password", # Optional if refresh_token is set
refresh_token="your_refresh_token", # Optional if username and password are set
)
with CustomersGetBySearchModel(company_id=5, search="cafe").connect(
auth_config=auth_config
) as api:
pprint(api.request().payload)
```
### Minimal Configuration
For a minimal setup, credentials can be passed via environment variables:
```python
from moloni.api.companies_client import CompaniesClient
from moloni.api.products_client import ProductsClient, ProductsGetAllModel
import logging
logger = logging.getLogger(__name__)
companies = CompaniesClient()
logger.info(companies.get_all())
products = ProductsClient()
logger.info(products.get_all(dict(company_id=5, category_id=8231525)))
product = products.insert(
dict(
company_id=5,
category_id=123456,
unit_id=134568,
has_stock="0",
name="Name",
reference="Reference",
price="10",
type="1",
taxes=[{"tax_id": 123455, "order": 0, "cumulative": 0}],
)
)
# or with a model
products_response = products.get_all(
ProductsGetAllModel(company_id=5, category_id=8231525)
)
```
## Credentials
### Passing Credentials
You can pass your credentials directly in the code or via environment variables:
```python
from moloni.base import AuthConfig
auth_config = AuthConfig(
client_id='your_client_id',
client_secret='your_client_secret',
username='your_username',
password='your_password',
refresh_token='your_refresh_token'
)
```
### Environment Variables
Alternatively, set the following environment variables:
```bash
export MOLONI_CLIENT_ID="your_client_id"
export MOLONI_CLIENT_SECRET="your_client_secret"
export MOLONI_REFRESH_TOKEN="your_refresh_token"
export MOLONI_USERNAME="your_username"
export MOLONI_PASSWORD="your_password"
```
## API Response Handling
The API responses are encapsulated in an ApiResponse object, which provides methods to access the response payload and handle pagination.
### Example:
```python
response = companies.get_all()
print(response.payload) # Access the JSON payload
print(response.status_code) # Check the HTTP status code
try:
next_page = response.next(qty=10)
print("Fetching next page with:", next_page)
except NoMoreRecords:
print("No more records to fetch.")
```
## Supported Endpoints
This client supports the full list of Moloni API endpoints, including:
• BankaccountsClient
• BillsofladingClient
• CompaniesClient
• CustomersClient
• InvoicesClient
• ProductsClient
• WarehousesClient
For a full list, please refer to the [documentation](https://python-moloni.readthedocs.io/en/latest/index.html).
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
-------
[](./coverage.svg)
-------
##### Disclaimer
We are not affiliated with Moloni, this is an unofficial wrapper to access their API. For more information, please visit their [official website](https://www.moloni.pt/).
Raw data
{
"_id": null,
"home_page": "https://github.com/saleweaver/python-moloni",
"name": "python-moloni",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Michael",
"author_email": "michael@datastic.co",
"download_url": "https://files.pythonhosted.org/packages/40/49/33916675eebb592898f047758b99ffa6621ea3cdc54664f9319fb541ae48/python-moloni-0.3.15.tar.gz",
"platform": null,
"description": "PYTHON-MOLONI\n==============\n\nWelcome to the Moloni API Client! This Python package provides a simple and flexible way to interact with the Moloni API. It supports a wide range of endpoints and allows you to manage your Moloni account programmatically.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Documentation](#documentation)\n- [Usage](#usage)\n - [Full Configuration](#full-configuration)\n - [Models as Entrypoints](#models-as-entrypoints)\n - [Minimal Configuration](#minimal-configuration)\n- [Credentials](#credentials)\n- [API Response Handling](#api-response-handling)\n- [Supported Endpoints](#supported-endpoints)\n- [License](#license)\n\n## Features\n\n- **Comprehensive Coverage:** Supports all Moloni API endpoints.\n- **Flexible Configuration:** Easily configure and authenticate your requests.\n- **Built-in Models:** Utilize predefined Pydantic models for request validation.\n\n\n## Installation\n\nYou can install the Moloni API Client using pip:\n\n```bash\npip install python-moloni\n```\n\n## Documentation\n\n[Documentation is available here](https://python-moloni.readthedocs.io/en/latest/index.html)\n\n## Usage\n\n### Full Configuration\n\nYou can set up a fully configured client with all necessary authentication details:\n\n```python\nfrom moloni.api.companies_client import CompaniesClient\nfrom moloni.base import AuthConfig, MoloniBaseUrl\nimport logging\n\nlogger = logging.getLogger(__name__)\n\ncompanies = CompaniesClient(\n environment=MoloniBaseUrl.PROD,\n auth_config=AuthConfig(\n client_id=\"your_client_id\",\n client_secret=\"your_client_secret\",\n username=\"your_username\", # Optional if refresh_token is set\n password=\"your_password\", # Optional if refresh_token is set\n refresh_token=\"your_refresh_token\", # Optional if username and password are set\n ),\n log_level=\"INFO\",\n version=\"v1\",\n validate=True,\n)\nlogger.info(companies.get_all())\n```\n\n### Models as Entrypoints\n\nYou can also use the predefined models as entrypoints to the API:\n\n```python\nfrom moloni.api import CustomersGetBySearchModel\nfrom moloni.base import AuthConfig, MoloniBaseUrl\nfrom pprint import pprint\n\nauth_config = AuthConfig(\n client_id=\"your_client_id\",\n client_secret=\"your_client_secret\",\n username=\"your_username\", # Optional if refresh_token is set\n password=\"your_password\", # Optional if refresh_token is set\n refresh_token=\"your_refresh_token\", # Optional if username and password are set\n)\n\nwith CustomersGetBySearchModel(company_id=5, search=\"cafe\").connect(\n auth_config=auth_config\n) as api:\n pprint(api.request().payload)\n \n```\n\n\n### Minimal Configuration\n\nFor a minimal setup, credentials can be passed via environment variables:\n\n```python\nfrom moloni.api.companies_client import CompaniesClient\nfrom moloni.api.products_client import ProductsClient, ProductsGetAllModel\nimport logging \n\nlogger = logging.getLogger(__name__)\n\ncompanies = CompaniesClient()\nlogger.info(companies.get_all())\nproducts = ProductsClient()\nlogger.info(products.get_all(dict(company_id=5, category_id=8231525)))\n\nproduct = products.insert(\n dict(\n company_id=5,\n category_id=123456,\n unit_id=134568,\n has_stock=\"0\",\n name=\"Name\",\n reference=\"Reference\",\n price=\"10\",\n type=\"1\",\n taxes=[{\"tax_id\": 123455, \"order\": 0, \"cumulative\": 0}],\n )\n)\n\n# or with a model\n\nproducts_response = products.get_all(\n ProductsGetAllModel(company_id=5, category_id=8231525)\n)\n```\n\n## Credentials\n\n### Passing Credentials\n\nYou can pass your credentials directly in the code or via environment variables:\n\n```python\nfrom moloni.base import AuthConfig\n\nauth_config = AuthConfig(\n client_id='your_client_id',\n client_secret='your_client_secret',\n username='your_username',\n password='your_password',\n refresh_token='your_refresh_token'\n)\n```\n\n### Environment Variables\n\nAlternatively, set the following environment variables:\n\n```bash\nexport MOLONI_CLIENT_ID=\"your_client_id\"\nexport MOLONI_CLIENT_SECRET=\"your_client_secret\"\nexport MOLONI_REFRESH_TOKEN=\"your_refresh_token\"\nexport MOLONI_USERNAME=\"your_username\"\nexport MOLONI_PASSWORD=\"your_password\"\n```\n\n## API Response Handling\n\nThe API responses are encapsulated in an ApiResponse object, which provides methods to access the response payload and handle pagination.\n\n### Example:\n\n```python\nresponse = companies.get_all()\nprint(response.payload) # Access the JSON payload\nprint(response.status_code) # Check the HTTP status code\n\ntry:\n next_page = response.next(qty=10)\n print(\"Fetching next page with:\", next_page)\nexcept NoMoreRecords:\n print(\"No more records to fetch.\")\n```\n\n## Supported Endpoints\n\nThis client supports the full list of Moloni API endpoints, including:\n\n\t\u2022\tBankaccountsClient\n\t\u2022\tBillsofladingClient\n\t\u2022\tCompaniesClient\n\t\u2022\tCustomersClient\n\t\u2022\tInvoicesClient\n\t\u2022\tProductsClient\n\t\u2022\tWarehousesClient\n\nFor a full list, please refer to the [documentation](https://python-moloni.readthedocs.io/en/latest/index.html).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n-------\n\n[](./coverage.svg)\n\n-------\n\n##### Disclaimer\n\nWe are not affiliated with Moloni, this is an unofficial wrapper to access their API. For more information, please visit their [official website](https://www.moloni.pt/).\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python wrapper for the Moloni API",
"version": "0.3.15",
"project_urls": {
"Homepage": "https://github.com/saleweaver/python-moloni"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4aa6ae0ca33a88ca98ecb8c673818495cabdbe60e864a9b0160e79d905ced319",
"md5": "1e0490d8c59ea7cbe0d9efc9eda8542b",
"sha256": "7f12ff2c3164c7e648e4cf3fc26a5eeebb0a3a3386868e94eb3c97ca1a42da9b"
},
"downloads": -1,
"filename": "python_moloni-0.3.15-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1e0490d8c59ea7cbe0d9efc9eda8542b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 91109,
"upload_time": "2024-11-04T09:59:31",
"upload_time_iso_8601": "2024-11-04T09:59:31.037019Z",
"url": "https://files.pythonhosted.org/packages/4a/a6/ae0ca33a88ca98ecb8c673818495cabdbe60e864a9b0160e79d905ced319/python_moloni-0.3.15-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "404933916675eebb592898f047758b99ffa6621ea3cdc54664f9319fb541ae48",
"md5": "5d629695f01404d8d28b58990b16c935",
"sha256": "e2cd150359d933909a82efd914d1fa52960c1c8c10ca696aa4c35456e9fe10d1"
},
"downloads": -1,
"filename": "python-moloni-0.3.15.tar.gz",
"has_sig": false,
"md5_digest": "5d629695f01404d8d28b58990b16c935",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 45362,
"upload_time": "2024-11-04T09:59:32",
"upload_time_iso_8601": "2024-11-04T09:59:32.579639Z",
"url": "https://files.pythonhosted.org/packages/40/49/33916675eebb592898f047758b99ffa6621ea3cdc54664f9319fb541ae48/python-moloni-0.3.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-04 09:59:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "saleweaver",
"github_project": "python-moloni",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": []
},
{
"name": "pydantic",
"specs": []
},
{
"name": "cachetools",
"specs": []
}
],
"lcname": "python-moloni"
}