File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/apify_client/clients/resource_clients Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
3
import json
4
+ import random
5
+ import string
4
6
import time
5
7
from typing import Any
6
8
@@ -491,11 +493,15 @@ async def charge(
491
493
if not event_name :
492
494
raise ValueError ('event_name is required for charging an event' )
493
495
496
+ idempotency_key = idempotency_key or (
497
+ f'{ self .resource_id } -{ event_name } -{ int (time .time () * 1000 )} -{ '' .join (random .choices (string .ascii_letters + string .digits , k = 6 ))} '
498
+ )
499
+
494
500
response = await self .http_client .call (
495
501
url = self ._url ('charge' ),
496
502
method = 'POST' ,
497
503
headers = {
498
- 'idempotency-key' : idempotency_key or f' { self . resource_id } - { event_name } - { int ( time . time () * 1000 ) } ' ,
504
+ 'idempotency-key' : idempotency_key ,
499
505
'content-type' : 'application/json' ,
500
506
},
501
507
data = json .dumps (
You can’t perform that action at this time.
0 commit comments