@@ -260,15 +260,22 @@ def generate_method_body(
260260 )
261261 path_expr = f'f"{ path_formatted } "'
262262
263+ # Determine if we need query params based on HTTP method
264+ # GET and DELETE use query params; POST/PUT/PATCH typically use body
265+ use_query_params = http_method .upper () in ("GET" , "DELETE" ) and query_params
266+ use_body_params = http_method .upper () in ("POST" , "PUT" , "PATCH" ) and body_params
267+ # POST can also have query params in URL
268+ use_query_on_post = http_method .upper () in ("POST" , "PUT" , "PATCH" ) and query_params and not body_params
269+
263270 # Build params dict if needed
264- if query_params :
271+ if use_query_params or use_query_on_post :
265272 lines .append (" params = self._build_params(" )
266273 for p in query_params :
267274 lines .append (f" { p ['name' ]} ={ p ['name' ]} ," )
268275 lines .append (" )" )
269276
270277 # Build payload dict if needed
271- if body_params :
278+ if use_body_params :
272279 lines .append (" payload = self._build_payload(" )
273280 for p in body_params :
274281 lines .append (f" { p ['name' ]} ={ p ['name' ]} ," )
@@ -288,6 +295,8 @@ def generate_method_body(
288295 else : # POST, PUT, PATCH
289296 if body_params :
290297 lines .append (f" return { await_prefix } self._client.{ client_method } ({ path_expr } , data=payload)" )
298+ elif query_params :
299+ lines .append (f" return { await_prefix } self._client.{ client_method } ({ path_expr } , params=params)" )
291300 else :
292301 lines .append (f" return { await_prefix } self._client.{ client_method } ({ path_expr } )" )
293302
@@ -302,6 +311,13 @@ def generate_resource_class(
302311 class_name = "" .join (word .title () for word in resource_name .split ("_" )) + "Resource"
303312 description = RESOURCE_DESCRIPTIONS .get (resource_name , f"{ resource_name } operations" )
304313
314+ # Check if any operation uses datetime type
315+ uses_datetime = any (
316+ "datetime" in p .get ("type" , "" )
317+ for op in operations
318+ for p in op .get ("params" , [])
319+ )
320+
305321 lines = [
306322 '"""' ,
307323 f"Auto-generated { resource_name } resource." ,
@@ -315,7 +331,17 @@ def generate_resource_class(
315331 "from typing import TYPE_CHECKING, Any" ,
316332 "" ,
317333 "if TYPE_CHECKING:" ,
318- " from ..client.base import BaseClient" ,
334+ ]
335+
336+ # Add datetime import inside TYPE_CHECKING block if needed
337+ if uses_datetime :
338+ lines .append (" from datetime import datetime" )
339+ lines .append ("" )
340+ lines .append (" from ..client.base import BaseClient" )
341+ else :
342+ lines .append (" from ..client.base import BaseClient" )
343+
344+ lines .extend ([
319345 "" ,
320346 "" ,
321347 f"class { class_name } :" ,
@@ -348,7 +374,7 @@ def generate_resource_class(
348374 " else:" ,
349375 " result[to_camel(k)] = v" ,
350376 " return result" ,
351- ]
377+ ])
352378
353379 # Generate sync methods
354380 for op in operations :
0 commit comments