Name | py-sarvcrm-api JSON |
Version |
1.4.0
JSON |
| download |
home_page | https://github.com/Radin-System/py-sarvcrm-api |
Summary | Simple sarvcrm api module |
upload_time | 2025-08-13 20:47:54 |
maintainer | None |
docs_url | None |
author | hmohammad |
requires_python | >=3.9 |
license | MIT License
Copyright (c) 2025 Radin-System
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "py-sarvcrm-api"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
keywords |
python
library
sarvcrm
hamkaransystem
api
|
VCS |
 |
bugtrack_url |
|
requirements |
requests
requests_cache
classmods
python-dotenv
setuptools
pytest
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# SarvClient API Interaction Module
## Overview
The **SarvClient** module provides a Python interface for interacting with the SarvCRM API. It simplifies authentication, CRUD operations, and module-specific functionalities for seamless integration with SarvCRM.
[SarvCRM API Documents](https://app.sarvcrm.com/webservice/)
## Features
- **Authentication**: Log in and manage sessions with the SarvCRM API.
- **CRUD Operations**: Perform Create, Read, Update, and Delete transactions via simple methods.
- **Context Manager Support**: Automatically handle login and logout within `with` statements.
- **Localization**: Supports specifying the desired language for API interactions.
- **Utility Methods**: Format dates, times, and other helper functionalities compliant with SarvCRM standards.
- **ENVMod Support**: You can use the SarvClient with the ENVMod module for more rubost and flexible env management.
---
## Installation
1. Ensure you have `Python 3.9+` installed.
2. Make sure `pip` is installed
4. Install the package
```bash
pip install py-sarvcrm-api
```
---
## Quick Start
#### **CRUD**
```python
from sarvcrm_api import SarvClient
# Initialize the client
client = SarvClient(
utype="your_utype",
username="your_username",
password="your_password",
language="en_US",
is_password_md5=True, # if your password is already md5
#url=https://example.com/API.php # if you use local server
#frontend_url=https://example.com/ # if you use local server
)
# Use as a context manager for clean execution
with client:
# Create new item in Accounts
uid = client.Accounts.create(type='Corporate', name='RadinSystem', numbers=['02145885000'])
print(f'New Account Created: {uid}')
# Read one item record
record = clinet.Accounts.read_record(uid)
print(f'Single Account record: {record}')
# Use query and selected_fields to read item
opportunity = client.Opportunities.read_list(query="opportunities.id='<UID>'", selected_fields=['fullname'])
print(f'Opportunity: {opportunity}')
# Read List of items
records = client.Accounts.read_list(order_by='accounts.name')
print('Accounts list:')
for account in Accounts:
print(f' - {account}')
# Update an item
updated_item = client.Accounts.update(uid, name='Radin-System')
print(f'Updated item id: {updated_item}')
# Search for data by phone number
result = client.search_by_number(number="02145885000", module=client.Accounts) # module is optional
print(f'Search by number result: {result}')
# Delete Item
deleted_item = client.Accounts.delete(uid)
print(f'Deleted item: {deleted_item}')
```
#### **Get me**
This method on `Users` module will give the logged in user details.
```python
my_user = client.Users.get_me()
```
Also you can use `user_id` property of client to get current users `id`
```pyton
print(client.user_id)
```
#### **Get current user items**
Use `read_user_created` or `read_user_assigned` to get items created or assigned to the current user.
```python
created_items = client.Leads.read_user_created(limit=10)
assigned_items = client.Tasks.read_user_assigned(limit=2)
```
### Initiate client with `ENVMod`
You can load the client with environment variables using `ENVMod` class. This is useful for development
and testing purposes.
```python
from classmods import ENVMod
from sarvcrm_api import SarvClient
sarv_client = SarvClient(**ENVMod.load_args(SarvClient.__init__))
```
If you have environment variables set up, you can use them directly in your code. For example, read
example file [env example](.env_example)
## Additional Features
- **Error Handling**: This module raises `requests.HTTPError` and `SarvException` for API errors.
- **Secure Defaults**: Passwords are hashed with `MD5` unless explicitly provided as pre-hashed.
- **Easy Intraction**: Added all modules and methods for easy intraction.
---
## Developers
- **Contribute**: Feel free to fork this repo and send pull request.
### Testing
- **Pytest Support**: create the `.env` file from `.env_example` and use pytest to start testing.
- **Test Cases**: For now simple test methods are used and more test cases will be added soon.
## License
This module is licensed for Radin System. For details, see the [LICENSE](LICENSE) file.
Raw data
{
"_id": null,
"home_page": "https://github.com/Radin-System/py-sarvcrm-api",
"name": "py-sarvcrm-api",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "python, library, sarvcrm, hamkaransystem, api",
"author": "hmohammad",
"author_email": "hmohammad <hmohammad2520@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/70/94/0f7315aff516781d1503d894ac22d39d2451fe88046a914e819427fb1ce1/py_sarvcrm_api-1.4.0.tar.gz",
"platform": null,
"description": "# SarvClient API Interaction Module\n\n## Overview\n\nThe **SarvClient** module provides a Python interface for interacting with the SarvCRM API. It simplifies authentication, CRUD operations, and module-specific functionalities for seamless integration with SarvCRM.\n\n[SarvCRM API Documents](https://app.sarvcrm.com/webservice/)\n\n## Features\n- **Authentication**: Log in and manage sessions with the SarvCRM API.\n- **CRUD Operations**: Perform Create, Read, Update, and Delete transactions via simple methods.\n- **Context Manager Support**: Automatically handle login and logout within `with` statements.\n- **Localization**: Supports specifying the desired language for API interactions.\n- **Utility Methods**: Format dates, times, and other helper functionalities compliant with SarvCRM standards.\n- **ENVMod Support**: You can use the SarvClient with the ENVMod module for more rubost and flexible env management.\n---\n\n## Installation\n\n1. Ensure you have `Python 3.9+` installed.\n2. Make sure `pip` is installed\n4. Install the package\n ```bash\n pip install py-sarvcrm-api\n ```\n---\n\n## Quick Start\n\n#### **CRUD**\n\n```python\nfrom sarvcrm_api import SarvClient\n\n# Initialize the client\nclient = SarvClient(\n utype=\"your_utype\",\n username=\"your_username\",\n password=\"your_password\",\n language=\"en_US\",\n is_password_md5=True, # if your password is already md5\n #url=https://example.com/API.php # if you use local server\n #frontend_url=https://example.com/ # if you use local server\n)\n\n\n# Use as a context manager for clean execution\nwith client:\n # Create new item in Accounts\n uid = client.Accounts.create(type='Corporate', name='RadinSystem', numbers=['02145885000'])\n print(f'New Account Created: {uid}')\n \n # Read one item record\n record = clinet.Accounts.read_record(uid)\n print(f'Single Account record: {record}')\n\n # Use query and selected_fields to read item\n opportunity = client.Opportunities.read_list(query=\"opportunities.id='<UID>'\", selected_fields=['fullname'])\n print(f'Opportunity: {opportunity}')\n\n # Read List of items\n records = client.Accounts.read_list(order_by='accounts.name')\n print('Accounts list:')\n for account in Accounts:\n print(f' - {account}')\n\n # Update an item\n updated_item = client.Accounts.update(uid, name='Radin-System')\n print(f'Updated item id: {updated_item}')\n\n # Search for data by phone number\n result = client.search_by_number(number=\"02145885000\", module=client.Accounts) # module is optional\n print(f'Search by number result: {result}')\n\n # Delete Item\n deleted_item = client.Accounts.delete(uid)\n print(f'Deleted item: {deleted_item}')\n```\n\n#### **Get me**\n\nThis method on `Users` module will give the logged in user details.\n\n```python\nmy_user = client.Users.get_me()\n```\n\nAlso you can use `user_id` property of client to get current users `id`\n\n```pyton\nprint(client.user_id)\n```\n\n#### **Get current user items**\n\nUse `read_user_created` or `read_user_assigned` to get items created or assigned to the current user.\n\n```python\ncreated_items = client.Leads.read_user_created(limit=10)\nassigned_items = client.Tasks.read_user_assigned(limit=2)\n```\n\n### Initiate client with `ENVMod`\nYou can load the client with environment variables using `ENVMod` class. This is useful for development\nand testing purposes.\n\n```python\nfrom classmods import ENVMod\nfrom sarvcrm_api import SarvClient\n\nsarv_client = SarvClient(**ENVMod.load_args(SarvClient.__init__))\n```\n\nIf you have environment variables set up, you can use them directly in your code. For example, read\nexample file [env example](.env_example)\n\n## Additional Features\n\n- **Error Handling**: This module raises `requests.HTTPError` and `SarvException` for API errors.\n- **Secure Defaults**: Passwords are hashed with `MD5` unless explicitly provided as pre-hashed.\n- **Easy Intraction**: Added all modules and methods for easy intraction.\n\n---\n\n## Developers\n - **Contribute**: Feel free to fork this repo and send pull request.\n\n### Testing\n - **Pytest Support**: create the `.env` file from `.env_example` and use pytest to start testing.\n - **Test Cases**: For now simple test methods are used and more test cases will be added soon.\n\n## License\n\nThis module is licensed for Radin System. For details, see the [LICENSE](LICENSE) file.\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 Radin-System\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"py-sarvcrm-api\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n ",
"summary": "Simple sarvcrm api module",
"version": "1.4.0",
"project_urls": {
"BugTracker": "https://github.com/hmohammad2520-org/py-sarvcrm-api/issues",
"Homepage": "https://github.com/hmohammad2520-org/py-sarvcrm-api"
},
"split_keywords": [
"python",
" library",
" sarvcrm",
" hamkaransystem",
" api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "72fa33eebe4fe600d44e52f2190a4adc8aa21aab7fc3ad35dc4b24fc98d5837e",
"md5": "7cb7821b452e47c503d66350374004b8",
"sha256": "767fbbe03da9418f22ad0babdc7de4b2a6c4cacafca9f221c814a6408a2e84eb"
},
"downloads": -1,
"filename": "py_sarvcrm_api-1.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7cb7821b452e47c503d66350374004b8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 30460,
"upload_time": "2025-08-13T20:47:53",
"upload_time_iso_8601": "2025-08-13T20:47:53.094768Z",
"url": "https://files.pythonhosted.org/packages/72/fa/33eebe4fe600d44e52f2190a4adc8aa21aab7fc3ad35dc4b24fc98d5837e/py_sarvcrm_api-1.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "70940f7315aff516781d1503d894ac22d39d2451fe88046a914e819427fb1ce1",
"md5": "dc46095372866e851356de03136b350f",
"sha256": "218af3c08a7a0caef58b7642aabc7d3f58d1fd1de962b121ea06bbaae51636e4"
},
"downloads": -1,
"filename": "py_sarvcrm_api-1.4.0.tar.gz",
"has_sig": false,
"md5_digest": "dc46095372866e851356de03136b350f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 16118,
"upload_time": "2025-08-13T20:47:54",
"upload_time_iso_8601": "2025-08-13T20:47:54.400089Z",
"url": "https://files.pythonhosted.org/packages/70/94/0f7315aff516781d1503d894ac22d39d2451fe88046a914e819427fb1ce1/py_sarvcrm_api-1.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-13 20:47:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Radin-System",
"github_project": "py-sarvcrm-api",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": [
[
"==",
"2.32.4"
]
]
},
{
"name": "requests_cache",
"specs": [
[
"==",
"1.2.1"
]
]
},
{
"name": "classmods",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "python-dotenv",
"specs": []
},
{
"name": "setuptools",
"specs": []
},
{
"name": "pytest",
"specs": []
}
],
"lcname": "py-sarvcrm-api"
}