Simple sarvcrm api module
Project description
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.
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
withstatements. - 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
- Ensure you have
Python 3.9+installed. - Make sure
pipis installed - Install the package
pip install py-sarvcrm-api
Quick Start
Example Usage
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}')
Initiate client with ENVMod
You can load the client with environment variables using ENVMod class. This is useful for development
and testing purposes.
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
Additional Features
- Error Handling: This module raises
requests.HTTPErrorandSarvExceptionfor API errors. - Secure Defaults: Passwords are hashed with
MD5unless 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
.envfile from.env_exampleand 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 file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_sarvcrm_api-1.3.1.tar.gz.
File metadata
- Download URL: py_sarvcrm_api-1.3.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66db51f351aef913d5e346ef012c68ef472435731ebadb9c97b875d4030a33b2
|
|
| MD5 |
b910ea83bb9d400dcfe0c3e27a01f099
|
|
| BLAKE2b-256 |
041e889d217a97cb6d784578dfd6bd78a36a919b3b380bcc812a6cf3473d8f17
|
Provenance
The following attestation bundles were made for py_sarvcrm_api-1.3.1.tar.gz:
Publisher:
python-publish.yml on hmohammad2520-org/py-sarvcrm-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_sarvcrm_api-1.3.1.tar.gz -
Subject digest:
66db51f351aef913d5e346ef012c68ef472435731ebadb9c97b875d4030a33b2 - Sigstore transparency entry: 346321374
- Sigstore integration time:
-
Permalink:
hmohammad2520-org/py-sarvcrm-api@6951fedcb0a1eceea68ee1a9d53e4a662e5e43ad -
Branch / Tag:
refs/tags/1.3.1 - Owner: https://github.com/hmohammad2520-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6951fedcb0a1eceea68ee1a9d53e4a662e5e43ad -
Trigger Event:
release
-
Statement type:
File details
Details for the file py_sarvcrm_api-1.3.1-py3-none-any.whl.
File metadata
- Download URL: py_sarvcrm_api-1.3.1-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ddd9674c5143554c2814f20ec5504614b05bdcc6cd4041eebc874fc8eb3dfe6
|
|
| MD5 |
2cb19325b40e2564b4ce4bb2251226bd
|
|
| BLAKE2b-256 |
183f8e9ccace5c492ebb9afadf06293378b68437af2066fce9207bf950d425e1
|
Provenance
The following attestation bundles were made for py_sarvcrm_api-1.3.1-py3-none-any.whl:
Publisher:
python-publish.yml on hmohammad2520-org/py-sarvcrm-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_sarvcrm_api-1.3.1-py3-none-any.whl -
Subject digest:
5ddd9674c5143554c2814f20ec5504614b05bdcc6cd4041eebc874fc8eb3dfe6 - Sigstore transparency entry: 346321375
- Sigstore integration time:
-
Permalink:
hmohammad2520-org/py-sarvcrm-api@6951fedcb0a1eceea68ee1a9d53e4a662e5e43ad -
Branch / Tag:
refs/tags/1.3.1 - Owner: https://github.com/hmohammad2520-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6951fedcb0a1eceea68ee1a9d53e4a662e5e43ad -
Trigger Event:
release
-
Statement type: