Skip to main content

Library is intended to provide the integration of the external service or CRM system with the TelegramShops/It allows to configure the relationship between NocoDB list of the products used further to display in the shop/As a resultss the products can be synchronized and updated uppon the request.

Project description

from typing import List
import asyncio

from config import NocoDBConfig
from tgshops_integrations.middlewares.gateway import Gateway
from services.bitrix.client import BitrixClient

# Your credentials are here and source of the target table
NOCODB_HOST = NocoDBConfig.HOST
NOCODB_API_KEY = NocoDBConfig.API_KEY
SOURCE=NocoDBConfig.source_table

async def main():

    # Here is your client to upload data from your service
    bitrixService=BitrixClient()

    # Products have to be in a according to the ProductModel
        # class ProductModel(BaseModel):
            # id: Optional[str]
            # external_id: Optional[str]
            # category: Optional[List[str]]
            # category_name: Optional[List[str]]
            # name: str
            # description: Optional[str]
            # price: Optional[float]
            # final_price: Optional[float]
            # currency: Optional[str]
            # stock_qty: int
            # orders_qty: int = Field(0, hidden_field=True)
            # created: datetime = Field(default=datetime.now, hidden_field=True)
            # updated: datetime = Field(default=datetime.now, hidden_field=True)
            # preview_url: List[str] = []
            # extra_attributes: List[ExtraAttribute] = []

    bitrix_product_list=await bitrixService.get_crm_product_list()

    NocoGateway = Gateway(NOCODB_HOST=NOCODB_HOST,NOCODB_API_KEY=NOCODB_API_KEY)
    
    # Example how to clean your table
    # await NocoGateway.load_data(SOURCE=SOURCE)
    # await NocoGateway.delete_all_products()


    # In order to obtain data from the table need to call load data, to obtain it for further comparation
    await NocoGateway.load_data(SOURCE=SOURCE)
    # Initializes any missing categories
    await NocoGateway.category_manager.update_categories(external_products=bitrix_product_list)

    # Creates or updates the products
    await NocoGateway.update_products(external_products=bitrix_product_list)


asyncio.run(main())

# python3 setup.py sdist bdist_wheel
# twine upload dist/* --verbose

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

tgshops_integrations-4.2.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

tgshops_integrations-4.2-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file tgshops_integrations-4.2.tar.gz.

File metadata

  • Download URL: tgshops_integrations-4.2.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for tgshops_integrations-4.2.tar.gz
Algorithm Hash digest
SHA256 c644a58dbf2d6f770fc5876d0b914c27f14b7b5c851116197441e206cfbf0a12
MD5 182c728deb36066ea760152794211b01
BLAKE2b-256 854eca269f3bbe52237bb1b714625e32f108988620e4f1f43a7ceb522a7963ad

See more details on using hashes here.

File details

Details for the file tgshops_integrations-4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tgshops_integrations-4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf4da1ca404b429db7162bffd7320eaed85be2b8e9173c0220a6f51b6a49d5c
MD5 0c921b4ca2ea6275932ea1d225f9e9e5
BLAKE2b-256 2786ae322c0d66d144964ef2f9a7e2e4bc4cef290334b812c48af1c6728ba319

See more details on using hashes here.

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