Skip to main content

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.

SarvCRM API Documents

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
  3. 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}')

    # Read List of items
    records = client.Accounts.read_list(order_by='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.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 file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_sarvcrm_api-1.2.4.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_sarvcrm_api-1.2.4-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file py_sarvcrm_api-1.2.4.tar.gz.

File metadata

  • Download URL: py_sarvcrm_api-1.2.4.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for py_sarvcrm_api-1.2.4.tar.gz
Algorithm Hash digest
SHA256 96ff3cfd7acdf79ef08062f16ee39243f8d5825ebcac7ab91dcd67703ee12d77
MD5 f79e9a39d06c435be225163e4c9f9220
BLAKE2b-256 dea43878353abcf994734e6769865a1a7cf53f33bb1e6298f8da901b9ccdc17b

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_sarvcrm_api-1.2.4.tar.gz:

Publisher: python-publish.yml on hmohammad2520-org/py-sarvcrm-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_sarvcrm_api-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: py_sarvcrm_api-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for py_sarvcrm_api-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a633aee662b690e3310cbb01757c1841fd916a3ca340c61eaa263b72f90e693d
MD5 55cf0fe4019c838efaa79ce1e1611bab
BLAKE2b-256 8c37e1d5e412dbb315472d2dbdd9f0cf910d98f70cd13c7aee7c414a47697811

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_sarvcrm_api-1.2.4-py3-none-any.whl:

Publisher: python-publish.yml on hmohammad2520-org/py-sarvcrm-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page