v1.0
This commit is contained in:
@@ -16,6 +16,8 @@ class YandexmarketMarketplaceApi(BaseMarketplaceApi):
|
||||
auth_data = json.loads(marketplace.auth_data)
|
||||
access_token = auth_data.get('accessToken')
|
||||
|
||||
self.limiter_key = str(marketplace.company_id) + str(access_token) + str(self.marketplace.campaign_id)
|
||||
|
||||
self.headers = {
|
||||
'Authorization': f'OAuth oauth_token="{access_token}", oauth_client_id="{YANDEX_CLIENT_ID}"'
|
||||
}
|
||||
@@ -33,20 +35,17 @@ class YandexmarketMarketplaceApi(BaseMarketplaceApi):
|
||||
campaign_id = self.marketplace.campaign_id
|
||||
max_stocks = 2000
|
||||
chunks = chunk_list(data, max_stocks)
|
||||
limiter = BatchLimiter(max_requests=50, period=60)
|
||||
limiter = BatchLimiter()
|
||||
|
||||
async def send_stock_chunk(chunk):
|
||||
try:
|
||||
await limiter.acquire()
|
||||
await limiter.acquire_yandexmarket(self.limiter_key)
|
||||
request_data = {
|
||||
'skus': chunk
|
||||
}
|
||||
response = await self._method('PUT',
|
||||
f'/campaigns/{campaign_id}/offers/stocks',
|
||||
data=request_data)
|
||||
print(request_data)
|
||||
rsp = await response.json()
|
||||
print(rsp)
|
||||
if response.status != 200:
|
||||
logging.warning(
|
||||
f'Error occurred when sending stocks to [{self.marketplace.id}]')
|
||||
|
||||
Reference in New Issue
Block a user