tgshops-integrations 1.4__py3-none-any.whl → 1.6__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.
@@ -78,7 +78,7 @@ class Gateway(NocodbClient):
78
78
  products_table = self.tables_list[self.config.NOCODB_PRODUCTS]
79
79
  await self.product_manager.update_attributes(products=external_products)
80
80
  # Updates categories if there were a new ones created
81
- external_products=await self.category_manager.map_categories(external_products=external_products)
81
+ # external_products=await self.category_manager.map_categories(external_products=external_products)
82
82
  self.product_manager.actual_products=await self.get_all_products()
83
83
  # self.product_manager.actual_products = await self.product_manager.get_products_v2(offset=0,limit=200)
84
84
 
@@ -94,26 +94,26 @@ class CategoryManager(NocodbClient):
94
94
 
95
95
  for product in external_products:
96
96
  # Check for new categories
97
- # IF some category number exists on external side
98
- if product.category:
99
- for external_category_id,category_name in zip(product.category,product.category_name):
100
- if category_name not in [*self.categories.keys()]:
101
- new_category= await self.create_product_category(table_id=self.categories_table,category_name=category_name,category_id=external_category_id,table_name=PRODUCT_NAME_FIELD)
102
- if self.logging:
103
- logger.info(f"New Category {new_category}")
104
- self.external_categories[new_category["Id"]]=external_category_id
105
- self.categories=await self.get_product_categories(table_id=self.categories_table, table_name=PRODUCT_NAME_FIELD)
97
+ # DEPRECATED IF some category number exists on external side
98
+ # if product.category:
99
+ # for external_category_id,category_name in zip(product.category,product.category_name):
100
+ # if category_name not in [*self.categories.keys()]:
101
+ # new_category= await self.create_product_category(table_id=self.categories_table,category_name=category_name,category_id=external_category_id,table_name=PRODUCT_NAME_FIELD)
102
+ # if self.logging:
103
+ # logger.info(f"New Category {new_category}")
104
+ # self.external_categories[new_category["Id"]]=external_category_id
105
+ # self.categories=await self.get_product_categories(table_id=self.categories_table, table_name=PRODUCT_NAME_FIELD)
106
106
  #Else if there is just the name, create the category with new id
107
- else:
107
+ # else:
108
108
  #Needs the buttons to be initialized, can connect items to buttons , which allows filtered acces through the menu
109
- for num,category_name in enumerate(product.category_name):
110
- if category_name not in categories_list:
111
- if self.filter_buttons:
112
- parent_id=self.categories[self.filter_buttons[num]]
113
- else:
114
- parent_id=self.categories[product.category_II_name[0]]
115
- categories_to_create.append([category_name,parent_id])
116
- categories_list.append(category_name)
109
+ for num,category_name in enumerate(product.category_name):
110
+ if category_name not in categories_list:
111
+ if self.filter_buttons:
112
+ parent_id=self.categories[self.filter_buttons[num]]
113
+ else:
114
+ parent_id=self.categories[product.category_II_name[0]]
115
+ categories_to_create.append([category_name,parent_id])
116
+ categories_list.append(category_name)
117
117
 
118
118
  if categories_to_create:
119
119
  categories_to_create.sort(key=lambda x: x[0])
@@ -253,8 +253,12 @@ class NocodbClient:
253
253
  source_column_id -ID of source column
254
254
  linked_record_id - ID of linked record
255
255
  """
256
-
257
- response = requests.get(image_url)
256
+ try:
257
+ response = requests.get(image_url)
258
+ except:
259
+ logger.info(f"Error with loading image via url - {image_url}")
260
+ return ""
261
+
258
262
  if response.status_code == 200:
259
263
  file = io.BytesIO(response.content)
260
264
  else:
@@ -263,26 +267,12 @@ class NocodbClient:
263
267
  file_size = file.getbuffer().nbytes
264
268
 
265
269
  if file_size:
266
-
267
270
  files = {'file': (image_name, file, 'image/jpeg')}
268
-
269
271
  url = f"{self.NOCODB_HOST.replace('/api/v2', '/api/v1')}/db/storage/upload?path=noco/{source_column_id}/{product_table_name}/{images_column_id}"
270
- timeout = httpx.Timeout(200.0)
271
- try:
272
- # First attempt
273
- response = await self.httpx_client.post(url, files=files, headers=self.httpx_client.headers, timeout=timeout)
274
- if response.status_code == 200:
275
- return response.json()[0]['url']
276
-
277
- # If first attempt fails, retry once
278
- response = await self.httpx_client.post(url, files=files, headers=self.httpx_client.headers, timeout=timeout)
279
- if response.status_code == 200:
280
- return response.json()[0]['url']
281
-
282
- except httpx.HTTPStatusError as e:
283
- raise Exception(f"HTTP error occurred: {e}")
284
- except Exception as e:
285
- raise Exception(f"Request failed: {str(e)}")
286
-
272
+ timeout = httpx.Timeout(100.0)
273
+ response = await self.httpx_client.post(url,files=files,headers=self.httpx_client.headers,timeout=timeout)
274
+ if response.status_code == 200:
275
+ return response.json()[0]['url']
276
+ raise Exception(response.text)
287
277
  else:
288
278
  return ""
@@ -135,7 +135,7 @@ def dump_product_data_with_check(data: ProductModel, data_check: dict) -> dict:
135
135
  PRODUCT_CURRENCY_FIELD: data.currency,
136
136
  PRODUCT_STOCK_FIELD: data.stock_qty,
137
137
  PRODUCT_CATEGORY_NAME_FIELD:[data.category_name] if data.category_name else None,
138
- PRODUCT_CATEGORY_ID_FIELD: [{'Id': data_check[item]} for item in data.category_name] if data.category else None,
138
+ PRODUCT_CATEGORY_ID_FIELD: [{'Id': data_check[item]} for item in data.category_name] if data.category_name else None,
139
139
  PRODUCT_IMAGE_FIELD: preview_url,
140
140
  PRODUCT_CHECKOUT_MODE: NOCODB_CHECKOUT_MODES,
141
141
  PRODUCT_DISCOUNT_PRICE_FIELD: data.final_price,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tgshops-integrations
3
- Version: 1.4
3
+ Version: 1.6
4
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
5
  Home-page: https://git.the-devs.com/virtual-shops/shop-system/shop-backend-integrations/integration-library/integration-library
6
6
  Author: Dimi Latoff
@@ -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=TLHASMEJMky-hYTqU5Q2Dh3C4hIjfAN-l6HoP6PzQpQ,6325
3
+ tgshops_integrations/middlewares/gateway.py,sha256=yyFHGH0MaBk3MMKREe9PxZBmBcFT9MErwavfnmrf1RE,6327
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
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
- tgshops_integrations/nocodb_connector/categories.py,sha256=YfQQ8UAkOonNZKO-oTH36vODu0eE-ElG-Me2bH5LdEM,9072
9
- tgshops_integrations/nocodb_connector/client.py,sha256=tBFvF7-vRY4w4sNQhbX-qKuxRYUoqQub8A3qze9qJUU,12012
10
- tgshops_integrations/nocodb_connector/model_mapping.py,sha256=CeGAwEZLK_NlK_eBTtsH6oRsjo6Z-QxWdC9KnwEhtPw,8770
8
+ tgshops_integrations/nocodb_connector/categories.py,sha256=x9mtXYEEIt6jV1Qzh_hYwKYJjqyuWyopmyeV0V4myUQ,9069
9
+ tgshops_integrations/nocodb_connector/client.py,sha256=qHv14rwad3P9SCH6h3Rj9UhOMGU6qq39jFJX_Ylxb3I,11640
10
+ tgshops_integrations/nocodb_connector/model_mapping.py,sha256=Sk3AzJCThH97dQIlNuQ7HKqycek_6Tq9UCsWR-9N4_4,8775
11
11
  tgshops_integrations/nocodb_connector/products.py,sha256=23uXnmznJN6fZw3tZ3a7dJg06LkI2QaNfVhSKochPn4,8677
12
12
  tgshops_integrations/nocodb_connector/tables.py,sha256=ha_QXZXd93mht0fR5E1nM0wUpz1ePon-pIdO2HI67l8,356
13
- tgshops_integrations-1.4.dist-info/METADATA,sha256=Y_zYUtcAbFdeacZOJQEv68te7NT_PWLrNt4ud_YQB0c,2774
14
- tgshops_integrations-1.4.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
15
- tgshops_integrations-1.4.dist-info/top_level.txt,sha256=HFNtxqDpzmlF4ZLnMiwhbU7pOa_YozxU2zBl0bnUmcY,21
16
- tgshops_integrations-1.4.dist-info/RECORD,,
13
+ tgshops_integrations-1.6.dist-info/METADATA,sha256=LTzbKnfZ99RXRkxr8ydi0Arl5-UEXIyAvJS5LzMplD4,2774
14
+ tgshops_integrations-1.6.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
15
+ tgshops_integrations-1.6.dist-info/top_level.txt,sha256=HFNtxqDpzmlF4ZLnMiwhbU7pOa_YozxU2zBl0bnUmcY,21
16
+ tgshops_integrations-1.6.dist-info/RECORD,,