File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from .document import Document
66from .logger import logger
77from .validation import validate_search
8+ from .preprocess import stringify_search_params
89from collections .abc import Iterable
910
1011class Documents (object ):
@@ -95,8 +96,9 @@ def export(self, params=None):
9596 return api_response
9697
9798 def search (self , search_parameters ):
98- validate_search (search_parameters )
99- return self .api_call .get (self ._endpoint_path ('search' ), search_parameters )
99+ stringified_search_params = stringify_search_params (search_parameters )
100+ validate_search (stringified_search_params )
101+ return self .api_call .get (self ._endpoint_path ('search' ), stringified_search_params )
100102
101103 def delete (self , params = None ):
102104 return self .api_call .delete (self ._endpoint_path (), params )
Original file line number Diff line number Diff line change 1+ def stringify_search_params (params ):
2+ return {key :stringify (val ) for key , val in params .items ()}
3+
4+ def stringify (val ):
5+ if isinstance (val , bool ) or isinstance (val , int ):
6+ return str (val ).lower ()
7+ else :
8+ return val
Original file line number Diff line number Diff line change 33
44def validate_search (params ):
55 for key in params :
6- if type (params [key ]) is not str :
6+ if not isinstance (params [key ], str ) :
77 raise InvalidParameter (f"'{ key } ' field expected a string but was given { type (params [key ]).__name__ } " )
You can’t perform that action at this time.
0 commit comments