diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 07:41:07 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 07:41:07 +0000 |
commit | 397136148eb203c97fa1b9d20c43637eafcc112c (patch) | |
tree | 0993ec712d8edeb06ecc199c4f8f86fdf306b117 | |
parent | 86f2d862a6ab922520da8d8a178f207d44b04627 (diff) |
automatic import of python-aioalfacrmopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-aioalfacrm.spec | 496 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 498 insertions, 0 deletions
@@ -0,0 +1 @@ +/aioalfacrm-0.3.2.tar.gz diff --git a/python-aioalfacrm.spec b/python-aioalfacrm.spec new file mode 100644 index 0000000..5bd9b4c --- /dev/null +++ b/python-aioalfacrm.spec @@ -0,0 +1,496 @@ +%global _empty_manifest_terminate_build 0 +Name: python-aioalfacrm +Version: 0.3.2 +Release: 1 +Summary: Is an asynchronous implementation for AlfaCRM API +License: MIT +URL: https://github.com/stas12312/aioalfacrm +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/8c/9b/94e8819f27a1cfd6eaf83d06ef960f5152e2da57cf8a2737e357c5c51ccb/aioalfacrm-0.3.2.tar.gz +BuildArch: noarch + +Requires: python3-aiohttp + +%description +# AIOAlfacrm + +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://opensource.org/licenses/MIT) +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://app.codecov.io/gh/stas12312/aioalfacrm) +[]( https://github.com/stas12312/aioalfacrm/actions) + +**aioalfacrm** - is an asynchronous implementation for the [AlfaCRM API](https://alfacrm.pro/rest-api) + +## Package is in development + +## Installation using pip + +``` +$ pip install aioalfacrm +``` + +*Example:* + +```python +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 + +```python +# Get all entities +for page in alfa_client. < object >.get_paginator(): + objects = page.items +``` + +## Custom fields + +To work with custom fields, do the following + +```python +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()) +``` + +%package -n python3-aioalfacrm +Summary: Is an asynchronous implementation for AlfaCRM API +Provides: python-aioalfacrm +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-aioalfacrm +# AIOAlfacrm + +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://opensource.org/licenses/MIT) +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://app.codecov.io/gh/stas12312/aioalfacrm) +[]( https://github.com/stas12312/aioalfacrm/actions) + +**aioalfacrm** - is an asynchronous implementation for the [AlfaCRM API](https://alfacrm.pro/rest-api) + +## Package is in development + +## Installation using pip + +``` +$ pip install aioalfacrm +``` + +*Example:* + +```python +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 + +```python +# Get all entities +for page in alfa_client. < object >.get_paginator(): + objects = page.items +``` + +## Custom fields + +To work with custom fields, do the following + +```python +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()) +``` + +%package help +Summary: Development documents and examples for aioalfacrm +Provides: python3-aioalfacrm-doc +%description help +# AIOAlfacrm + +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://opensource.org/licenses/MIT) +[](https://pypi.python.org/pypi/aioalfacrm) +[](https://app.codecov.io/gh/stas12312/aioalfacrm) +[]( https://github.com/stas12312/aioalfacrm/actions) + +**aioalfacrm** - is an asynchronous implementation for the [AlfaCRM API](https://alfacrm.pro/rest-api) + +## Package is in development + +## Installation using pip + +``` +$ pip install aioalfacrm +``` + +*Example:* + +```python +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 + +```python +# Get all entities +for page in alfa_client. < object >.get_paginator(): + objects = page.items +``` + +## Custom fields + +To work with custom fields, do the following + +```python +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()) +``` + +%prep +%autosetup -n aioalfacrm-0.3.2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-aioalfacrm -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.3.2-1 +- Package Spec generated @@ -0,0 +1 @@ +9d672416b3a92fe8aaa31fa8922d238a aioalfacrm-0.3.2.tar.gz |