Skip to content

Commit fff5766

Browse files
committed
fix(clients): support dict in helpers
1 parent 880dc38 commit fff5766

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

playground/python/app/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main():
2020
print("client initialized", client)
2121

2222
try:
23-
resp = client.search_synonyms("foo")
23+
resp = client.browse_objects(index_name="qigbuery-RECORDS", aggregator=lambda resp: print(resp), browse_params={})
2424
print(resp)
2525
client.browse_synonyms("foo", lambda _resp: print(_resp))
2626
finally:

playground/python/poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/ruby/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ../../clients/algoliasearch-client-ruby
33
specs:
4-
algolia (3.10.0)
4+
algolia (3.10.1)
55
base64 (>= 0.2.0, < 1)
66
faraday (>= 1.0.1, < 3.0)
77
faraday-net_http_persistent (>= 0.15, < 3)

playground/ruby/search.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
client = Algolia::SearchClient.create(ENV['ALGOLIA_APPLICATION_ID'], ENV['ALGOLIA_ADMIN_KEY'])
77
# set a custom user agent
88
client.add_user_agent_segment('Algolia for rails', "test")
9-
res = client.search_single_index('contacts', Algolia::Search::SearchParamsObject.new(query: 'Jimmie'))
9+
res = client.browse_objects('qigbuery-RECORDS', {})
1010
puts res
1111

1212
=begin

templates/python/search_helpers.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@
128128
"""
129129
Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
130130
"""
131+
if isinstance(browse_params, dict):
132+
browse_params = BrowseParamsObject().from_dict(browse_params)
133+
131134
if browse_params is None:
132135
browse_params = BrowseParamsObject(hits_per_page=1000)
133136

@@ -159,6 +162,9 @@
159162
"""
160163
Helper: Iterate on the `search_rules` method of the client to allow aggregating rules of an index.
161164
"""
165+
if isinstance(search_rules_params, dict):
166+
search_rules_params = SearchRulesParams().from_dict(search_rules_params)
167+
162168
if search_rules_params is None:
163169
search_rules_params = SearchRulesParams(hits_per_page=1000)
164170

@@ -191,6 +197,9 @@
191197
"""
192198
Helper: Iterate on the `search_synonyms` method of the client to allow aggregating synonyms of an index.
193199
"""
200+
if isinstance(search_synonyms_params, dict):
201+
search_synonyms_params = SearchSynonymsParams().from_dict(search_synonyms_params)
202+
194203
if search_synonyms_params is None:
195204
search_synonyms_params = SearchSynonymsParams(
196205
hits_per_page=1000,
@@ -226,6 +235,7 @@
226235
"""
227236
if restrictions is None:
228237
restrictions = SecuredApiKeyRestrictions()
238+
229239
restrictions_dict = {}
230240
if isinstance(restrictions, SecuredApiKeyRestrictions):
231241
restrictions_dict = restrictions.to_dict()

0 commit comments

Comments
 (0)