AIOAlfacrm
aioalfacrm - is an asynchronous implementation for the AlfaCRM API
Package is in development
Installation using pip
$ pip install aioalfacrm
Example:
import asyncio
from aioalfacrm import AlfaClient
from aioalfacrm.entities import Location
HOSTNAME = 'demo.s20.online'
EMAIL = 'api-email@email.example'
API_KEY = 'user-api-token'
BRANCH_ID = 1
async def main():
alfa_client = AlfaClient(
hostname=HOSTNAME,
email=EMAIL,
api_key=API_KEY,
branch_id=BRANCH_ID,
)
try:
# Check auth (Optionaly)
if not await alfa_client.check_auth():
print('Authentification error')
return
# Get branches
branches = await alfa_client.branch.list(page=0, count=20)
# Edit branch
for branch in branches:
branch.name = f'{branch.name} - Edited'
# Save branch
await alfa_client.branch.save(branch)
# Create location
location = Location(
branch_id=1,
is_active=True,
name='New location',
)
await alfa_client.location.save(location)
finally:
# Close session
await alfa_client.close()
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # For Windows
asyncio.run(main())
Paginator
# Get all entities
for page in alfa_client. < object >.get_paginator():
objects = page.items
Custom fields
To work with custom fields, do the following
from aioalfacrm import entities
from aioalfacrm import fields
from typing import Optional
# Extend existing model
class CustomCustomer(entities.Customer):
custom_field: Optional[int] = fields.Integer()
# For IDE init support
def __init__(
self,
custom_field: Optional[int] = None,
*args,
**kwargs,
):
super(CustomCustomer, self).__init__(custom_field=custom_field, *args, **kwargs)
# Create custom alfa client with new model
from aioalfacrm import AlfaClient
from aioalfacrm import managers
class CustomAlfaClient(AlfaClient):
def __init__(self, *args, **kwargs):
super(CustomAlfaClient, self).__init__(*args, **kwargs)
self.customer = managers.Customer(
api_client=self.api_client,
entity_class=CustomCustomer,
)
# Create custom alfa client
import asyncio
HOSTNAME = 'demo.s20.online'
EMAIL = 'api-email@email.example'
API_KEY = 'user-api-token'
BRANCH_ID = 1
async def main():
alfa_client = CustomAlfaClient(hostname=HOSTNAME, email=EMAIL, api_key=API_KEY, branch_id=BRANCH_ID)
try:
customers = await alfa_client.customer.list()
for customer in customers:
print(customer.custom_field)
finally:
await alfa_client.close()
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # For Windows
asyncio.run(main())
Metadata
Release files for aioalfacrm 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aioalfacrm-0.3.2.tar.gz | 42.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aioalfacrm-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 80.7 kB
Release files / aioalfacrm-0.3.2.tar.gz
| Download URL | aioalfacrm-0.3.2.tar.gz |
|---|---|
| Size | 42.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5075c91d8020fb4c5dfa97929a4ad5af958555d35fcab0bdf5af112d595005e0
|
|
BLAKE2b-256 checksum How to use checksums |
8c9b94e8819f27a1cfd6eaf83d06ef960f5152e2da57cf8a2737e357c5c51ccb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.9.5 Linux/5.4.0-90-generic
|
Release files / aioalfacrm-0.3.2-py3-none-any.whl
| Download URL | aioalfacrm-0.3.2-py3-none-any.whl |
|---|---|
| Size | 38.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
985d49d3c09923cc2e018ff1d862d0ed5a9c8d460295909a80940684ad2aa0bb
|
|
BLAKE2b-256 checksum How to use checksums |
3d1a9113be592a6aa27082296301cef80abe61b260b2261780c295d650bb4171
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.9.5 Linux/5.4.0-90-generic
|
Security for aioalfacrm 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.