v1.0
This commit is contained in:
@@ -13,7 +13,13 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
|
||||
|
||||
def __init__(self, marketplace: Marketplace):
|
||||
self.marketplace = marketplace
|
||||
auth_data = json.loads(marketplace.auth_data)
|
||||
self.is_valid = True
|
||||
try:
|
||||
auth_data = json.loads(marketplace.auth_data)
|
||||
except Exception:
|
||||
logging.error(f"Couldn't load auth data for marketplace [{self.marketplace.id}]")
|
||||
self.is_valid = False
|
||||
return
|
||||
client_id = auth_data.get('clientId')
|
||||
|
||||
self.limiter_key = str(marketplace.company_id) + str(client_id)
|
||||
@@ -32,6 +38,8 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
|
||||
async def update_stocks(self, data: Union[list, dict]):
|
||||
if type(data) is not list:
|
||||
return
|
||||
if not self.is_valid:
|
||||
return
|
||||
max_stocks = 100
|
||||
chunks = utils.chunk_list(data, max_stocks)
|
||||
limiter = BatchLimiter()
|
||||
@@ -49,7 +57,7 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
|
||||
f'Error occurred when sending stocks to [{self.marketplace.id}]: {error_message} ({error_code})')
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
f'Exception occurred while sending stocks to marketplace ID [{self.marketplace.id}]: {str(e)}')
|
||||
f'Exception occurred while sending stocks to marketplace ID [{self.marketplace.id}]: {str(e)}')
|
||||
|
||||
tasks = [send_stock_chunk(chunk) for chunk in chunks]
|
||||
await asyncio.gather(*tasks)
|
||||
|
||||
@@ -13,7 +13,13 @@ from utils import chunk_list
|
||||
class YandexmarketMarketplaceApi(BaseMarketplaceApi):
|
||||
def __init__(self, marketplace: Marketplace):
|
||||
self.marketplace = marketplace
|
||||
auth_data = json.loads(marketplace.auth_data)
|
||||
self.is_valid = True
|
||||
try:
|
||||
auth_data = json.loads(marketplace.auth_data)
|
||||
except Exception:
|
||||
logging.error(f"Couldn't load auth data for marketplace [{self.marketplace.id}]")
|
||||
self.is_valid = False
|
||||
return
|
||||
access_token = auth_data.get('accessToken')
|
||||
|
||||
self.limiter_key = str(marketplace.company_id) + str(access_token) + str(self.marketplace.campaign_id)
|
||||
@@ -32,6 +38,8 @@ class YandexmarketMarketplaceApi(BaseMarketplaceApi):
|
||||
async def update_stocks(self, data: Union[list, dict]):
|
||||
if type(data) is not list:
|
||||
return
|
||||
if not self.is_valid:
|
||||
return
|
||||
campaign_id = self.marketplace.campaign_id
|
||||
max_stocks = 2000
|
||||
chunks = chunk_list(data, max_stocks)
|
||||
|
||||
Reference in New Issue
Block a user