Skip to content

Commit fedc6a6

Browse files
julienbourdeauaseure
authored andcommitted
fix(keys): allow all params to be passed in obj
1 parent 3fdac21 commit fedc6a6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

algoliasearch/client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,13 @@ def add_api_key(self, obj,
451451
if not isinstance(obj, dict):
452452
obj = {'acl': obj}
453453

454-
obj.update({
455-
'validity': validity,
456-
'maxQueriesPerIPPerHour': max_queries_per_ip_per_hour,
457-
'maxHitsPerQuery': max_hits_per_query
458-
})
454+
# Check with `is not None`, because 0 is evaluated to False
455+
if validity is not None:
456+
obj['validity'] = validity
457+
if max_queries_per_ip_per_hour is not None:
458+
obj['maxQueriesPerIPPerHour'] = max_queries_per_ip_per_hour
459+
if max_hits_per_query is not None:
460+
obj['maxHitsPerQuery'] = max_hits_per_query
459461

460462
if indexes:
461463
obj['indexes'] = indexes

0 commit comments

Comments
 (0)