Update cloudinary==1.28.0

This commit is contained in:
JonnyWong16 2021-11-28 14:12:44 -08:00
parent 0325e9327f
commit dcfd8abddd
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
7 changed files with 196 additions and 21 deletions

View file

@ -1,10 +1,16 @@
import json
from copy import deepcopy
from cloudinary.api_client.call_api import call_json_api
from cloudinary.utils import unique
class Search:
_KEYS_WITH_UNIQUE_VALUES = {
'sort_by': lambda x: next(iter(x)),
'aggregate': None,
'with_field': None,
}
"""Build and execute a search query."""
def __init__(self):
self.query = {}
@ -42,7 +48,7 @@ class Search:
return self
def to_json(self):
return json.dumps(self.query)
return json.dumps(self.as_dict())
def execute(self, **options):
"""Execute the search and return results."""
@ -57,4 +63,12 @@ class Search:
return self
def as_dict(self):
return deepcopy(self.query)
to_return = {}
for key, value in self.query.items():
if key in self._KEYS_WITH_UNIQUE_VALUES:
value = unique(value, self._KEYS_WITH_UNIQUE_VALUES[key])
to_return[key] = value
return to_return