Skip to content

Commit d693a30

Browse files
authored
Merge pull request #29 from JigsawStack/feat/async
Feat/async
2 parents 6d5e98c + f6e5be7 commit d693a30

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

jigsawstack/search.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,21 @@ def search(self, params: SearchParams) -> SearchResponse:
7878
ai_overview = params.get("ai_overview", "True")
7979
safe_search = params.get("safe_search", "moderate")
8080
spell_check = params.get("spell_check", "True")
81-
path = f"/web/search?query={query}&ai_overview={ai_overview}&safe_search={safe_search}&spell_check={spell_check}"
81+
82+
body = {
83+
"byo_urls": params.get("byo_urls", []),
84+
"query": query,
85+
"ai_overview": ai_overview,
86+
"safe_search": safe_search,
87+
"spell_check": spell_check,
88+
}
89+
90+
path = f"/web/search"
8291
resp = Request(
8392
config=self.config,
8493
path=path,
85-
params=cast(Dict[Any, Any], params),
86-
verb="GET",
94+
params=cast(Dict[Any, Any], body),
95+
verb="POST",
8796
).perform_with_content()
8897

8998
return resp
@@ -117,18 +126,25 @@ def __init__(
117126
)
118127

119128
async def search(self, params: SearchParams) -> SearchResponse:
129+
path = f"/web/search"
120130
query = params["query"]
121131
ai_overview = params.get("ai_overview", "True")
122132
safe_search = params.get("safe_search", "moderate")
123133
spell_check = params.get("spell_check", "True")
124-
path = f"/web/search?query={query}&ai_overview={ai_overview}&safe_search={safe_search}&spell_check={spell_check}"
134+
135+
body = {
136+
"byo_urls": params.get("byo_urls", []),
137+
"query": query,
138+
"ai_overview": ai_overview,
139+
"safe_search": safe_search,
140+
"spell_check": spell_check,
141+
}
125142
resp = await AsyncRequest(
126143
config=self.config,
127144
path=path,
128-
params=cast(Dict[Any, Any], params),
129-
verb="GET",
145+
params=cast(Dict[Any, Any], body),
146+
verb="POST",
130147
).perform_with_content()
131-
132148
return resp
133149

134150
async def suggestion(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="jigsawstack",
9-
version="0.1.22",
9+
version="0.1.23",
1010
description="JigsawStack Python SDK",
1111
long_description=open("README.md", encoding="utf8").read(),
1212
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)