tgshops-integrations 0.2__py3-none-any.whl → 0.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tgshops_integrations/middlewares/gateway.py +3 -3
- tgshops_integrations/models/products.py +0 -6
- tgshops_integrations-0.5.dist-info/METADATA +81 -0
- {tgshops_integrations-0.2.dist-info → tgshops_integrations-0.5.dist-info}/RECORD +6 -6
- tgshops_integrations-0.2.dist-info/METADATA +0 -75
- {tgshops_integrations-0.2.dist-info → tgshops_integrations-0.5.dist-info}/WHEEL +0 -0
- {tgshops_integrations-0.2.dist-info → tgshops_integrations-0.5.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,9 @@
|
|
1
1
|
from typing import List,Optional
|
2
2
|
|
3
3
|
from aiocache import cached
|
4
|
-
from models.products import ProductModel
|
5
|
-
from nocodb_connector.client import NocodbClient
|
6
|
-
from nocodb_connector.model_mapping import dump_product_data,dump_product_data_with_check, get_pagination_info, ID_FIELD, \
|
4
|
+
from tgshops_integrations.models.products import ProductModel
|
5
|
+
from tgshops_integrations.nocodb_connector.client import NocodbClient
|
6
|
+
from tgshops_integrations.nocodb_connector.model_mapping import dump_product_data,dump_product_data_with_check, get_pagination_info, ID_FIELD, \
|
7
7
|
parse_product_data, PRODUCT_CATEGORY_ID_LOOKUP_FIELD, PRODUCT_NAME_FIELD, PRODUCT_PRICE_FIELD, \
|
8
8
|
PRODUCT_STOCK_FIELD
|
9
9
|
|
@@ -29,7 +29,6 @@ class ExternalProductModel(BaseModel):
|
|
29
29
|
class ProductModel(BaseModel):
|
30
30
|
id: Optional[str]
|
31
31
|
external_id: Optional[str]
|
32
|
-
|
33
32
|
category: Optional[List[str]]
|
34
33
|
category_name: Optional[List[str]]
|
35
34
|
name: str
|
@@ -43,8 +42,3 @@ class ProductModel(BaseModel):
|
|
43
42
|
updated: datetime = Field(default=datetime.now, hidden_field=True)
|
44
43
|
preview_url: List[str] = []
|
45
44
|
extra_attributes: List[ExtraAttribute] = []
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
class ProductModel(ExternalProductModel):
|
50
|
-
id: str
|
@@ -0,0 +1,81 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: tgshops-integrations
|
3
|
+
Version: 0.5
|
4
|
+
Summary: 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.
|
5
|
+
Home-page: https://git.the-devs.com/virtual-shops/shop-system/shop-backend-integrations/integration-library/integration-library
|
6
|
+
Author: Dimi Latoff
|
7
|
+
Author-email: drpozd@gmail.com
|
8
|
+
License: MIT
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Operating System :: OS Independent
|
12
|
+
Requires-Python: >=3.10
|
13
|
+
Description-Content-Type: text/markdown
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
```python
|
21
|
+
|
22
|
+
from typing import List
|
23
|
+
import asyncio
|
24
|
+
|
25
|
+
from config import NocoDBConfig
|
26
|
+
from tgshops_integrations.middlewares.gateway import Gateway
|
27
|
+
from services.bitrix.client import BitrixClient
|
28
|
+
|
29
|
+
# Your credentials are here and source of the target table
|
30
|
+
NOCODB_HOST = NocoDBConfig.HOST
|
31
|
+
NOCODB_API_KEY = NocoDBConfig.API_KEY
|
32
|
+
SOURCE=NocoDBConfig.source_table
|
33
|
+
|
34
|
+
async def main():
|
35
|
+
|
36
|
+
# Here is your client to upload data from your service
|
37
|
+
bitrixService=BitrixClient()
|
38
|
+
|
39
|
+
# Products have to be in a according to the ProductModel
|
40
|
+
# class ProductModel(BaseModel):
|
41
|
+
# id: Optional[str]
|
42
|
+
# external_id: Optional[str]
|
43
|
+
# category: Optional[List[str]]
|
44
|
+
# category_name: Optional[List[str]]
|
45
|
+
# name: str
|
46
|
+
# description: Optional[str]
|
47
|
+
# price: Optional[float]
|
48
|
+
# final_price: Optional[float]
|
49
|
+
# currency: Optional[str]
|
50
|
+
# stock_qty: int
|
51
|
+
# orders_qty: int = Field(0, hidden_field=True)
|
52
|
+
# created: datetime = Field(default=datetime.now, hidden_field=True)
|
53
|
+
# updated: datetime = Field(default=datetime.now, hidden_field=True)
|
54
|
+
# preview_url: List[str] = []
|
55
|
+
# extra_attributes: List[ExtraAttribute] = []
|
56
|
+
|
57
|
+
bitrix_product_list=await bitrixService.get_crm_product_list()
|
58
|
+
|
59
|
+
NocoGateway = Gateway(NOCODB_HOST=NOCODB_HOST,NOCODB_API_KEY=NOCODB_API_KEY)
|
60
|
+
|
61
|
+
# Example how to clean your table
|
62
|
+
# await NocoGateway.load_data(SOURCE=SOURCE)
|
63
|
+
# await NocoGateway.delete_all_products()
|
64
|
+
|
65
|
+
|
66
|
+
# In order to obtain data from the table need to call load data, to obtain it for further comparation
|
67
|
+
await NocoGateway.load_data(SOURCE=SOURCE)
|
68
|
+
# Initializes any missing categories
|
69
|
+
await NocoGateway.category_manager.update_categories(external_products=bitrix_product_list)
|
70
|
+
|
71
|
+
# Creates or updates the products
|
72
|
+
await NocoGateway.update_products(external_products=bitrix_product_list)
|
73
|
+
|
74
|
+
|
75
|
+
asyncio.run(main())
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
```
|
@@ -1,16 +1,16 @@
|
|
1
1
|
tgshops_integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
tgshops_integrations/middlewares/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
tgshops_integrations/middlewares/gateway.py,sha256=
|
3
|
+
tgshops_integrations/middlewares/gateway.py,sha256=tZMJZJBRVmmIrlKmspm5KMbmNDCv4RgXFjydcayx56k,5042
|
4
4
|
tgshops_integrations/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
tgshops_integrations/models/categories.py,sha256=EG6C8g5dOfXB2MH-vtqH13aqB7_VyOobY2FHpDb-fsY,977
|
6
|
-
tgshops_integrations/models/products.py,sha256=
|
6
|
+
tgshops_integrations/models/products.py,sha256=i0vP_eJMVCB-W25BCoodIB0AhsMTqYiDO48N-B6Ueo0,1379
|
7
7
|
tgshops_integrations/nocodb_connector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
tgshops_integrations/nocodb_connector/categories.py,sha256=GHB7vEns9viK3NbgR4fY42UzMCUVnr4R1HKP1NORaHg,5900
|
9
9
|
tgshops_integrations/nocodb_connector/client.py,sha256=qq2UQDbRCOqcH0ng49l1xOihY2-Zc3tMm2yqQUMk_pk,8307
|
10
10
|
tgshops_integrations/nocodb_connector/model_mapping.py,sha256=9199eOz4ISqduDv5BkxWgPXt-QT6fd5dtCGVMZoOAN4,7471
|
11
11
|
tgshops_integrations/nocodb_connector/products.py,sha256=TZGBfEfH11NxOeeqZQoEiMi1WEuSMpmTJ7JDu8KtgNw,7548
|
12
12
|
tgshops_integrations/nocodb_connector/tables.py,sha256=ha_QXZXd93mht0fR5E1nM0wUpz1ePon-pIdO2HI67l8,356
|
13
|
-
tgshops_integrations-0.
|
14
|
-
tgshops_integrations-0.
|
15
|
-
tgshops_integrations-0.
|
16
|
-
tgshops_integrations-0.
|
13
|
+
tgshops_integrations-0.5.dist-info/METADATA,sha256=69nGOSfX2e1gdThBxwhPsqe-nvWPbgIZ6Lkv2h-K9EY,2774
|
14
|
+
tgshops_integrations-0.5.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
15
|
+
tgshops_integrations-0.5.dist-info/top_level.txt,sha256=HFNtxqDpzmlF4ZLnMiwhbU7pOa_YozxU2zBl0bnUmcY,21
|
16
|
+
tgshops_integrations-0.5.dist-info/RECORD,,
|
@@ -1,75 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: tgshops-integrations
|
3
|
-
Version: 0.2
|
4
|
-
Summary: 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.
|
5
|
-
Home-page: https://git.the-devs.com/virtual-shops/shop-system/shop-backend-integrations/integration-library/integration-library
|
6
|
-
Author: Dimi Latoff
|
7
|
-
Author-email: drpozd@gmail.com
|
8
|
-
License: MIT
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
11
|
-
Classifier: Operating System :: OS Independent
|
12
|
-
Requires-Python: >=3.10
|
13
|
-
Description-Content-Type: text/markdown
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
```python
|
21
|
-
|
22
|
-
import tgshops_integrations
|
23
|
-
import ExternalProductModel, ExternalCategoryModel from tgshops_integrations.models
|
24
|
-
|
25
|
-
# Load external data
|
26
|
-
external_categories = [ExternalCategoryModel(
|
27
|
-
name="Drinks",
|
28
|
-
image_url="https://example.com/image.jpg",
|
29
|
-
external_id="0"
|
30
|
-
), CategoryModel(
|
31
|
-
name="Coffee",
|
32
|
-
image_url="https://example.com/image.jpg",
|
33
|
-
external_id="1"
|
34
|
-
)]
|
35
|
-
external_products = [ExternalProductModel(
|
36
|
-
name="Coffee",
|
37
|
-
description="",
|
38
|
-
price=10.0,
|
39
|
-
currency="USD",
|
40
|
-
image_url="https://example.com/image.jpg",
|
41
|
-
category=List["0", "1"],
|
42
|
-
external_id="0"
|
43
|
-
)]
|
44
|
-
|
45
|
-
|
46
|
-
# Initialise
|
47
|
-
product_service = tgshops_integrations.ProductService(token="your_token_here")
|
48
|
-
|
49
|
-
await product_service.update_categories(
|
50
|
-
external_categories=external_categories
|
51
|
-
)
|
52
|
-
|
53
|
-
await product_service.update_products(
|
54
|
-
external_products=external_products
|
55
|
-
)
|
56
|
-
|
57
|
-
# Here is the the custom integration of your service, which has to return products according to the ExternalProductModel
|
58
|
-
bitrixService=BitrixClient()
|
59
|
-
bitrix_product_list=await bitrixService.get_crm_product_list()
|
60
|
-
|
61
|
-
# One gateway can work with several table / DBs
|
62
|
-
NocoGateway = Gateway(NOCODB_HOST=NOCODB_HOST,NOCODB_API_KEY=NOCODB_API_KEY)
|
63
|
-
|
64
|
-
# await NocoGateway.load_data()
|
65
|
-
# await NocoGateway.delete_all_products()
|
66
|
-
|
67
|
-
# Load data provides the access to the certain table and allows to obtain the data about the products or catergories
|
68
|
-
await NocoGateway.load_data(SOURCE=SOURCE)
|
69
|
-
await NocoGateway.category_manager.update_categories(external_products=bitrix_product_list)
|
70
|
-
await NocoGateway.update_products(external_products=bitrix_product_list)
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
```
|
File without changes
|
File without changes
|