@@ -9,6 +9,7 @@ use reqwest::Client;
99use crate :: push_config_compat:: {
1010 deserialize_list_task_push_notification_configs_response,
1111 deserialize_task_push_notification_config,
12+ serialize_create_task_push_notification_config_request,
1213} ;
1314use crate :: transport:: { ServiceParams , Transport , TransportFactory } ;
1415
@@ -26,19 +27,13 @@ impl JsonRpcTransport {
2627 JsonRpcTransport { client, endpoint }
2728 }
2829
29- async fn call_value < Req > (
30+ async fn call_value_with_payload (
3031 & self ,
3132 params : & ServiceParams ,
3233 method : & str ,
33- request_params : & Req ,
34- ) -> Result < serde_json:: Value , A2AError >
35- where
36- Req : ProtoJsonPayload ,
37- {
34+ payload : serde_json:: Value ,
35+ ) -> Result < serde_json:: Value , A2AError > {
3836 let id = JsonRpcId :: String ( uuid:: Uuid :: now_v7 ( ) . to_string ( ) ) ;
39- let payload = protojson_conv:: to_value ( request_params) . map_err ( |e| {
40- A2AError :: internal ( format ! ( "failed to serialize request as ProtoJSON: {e}" ) )
41- } ) ?;
4237 let rpc_request = JsonRpcRequest :: new ( id, method, Some ( payload) ) ;
4338
4439 let mut builder = self . client . post ( & self . endpoint ) ;
@@ -63,11 +58,25 @@ impl JsonRpcTransport {
6358 return Err ( A2AError :: new ( err. code , err. message ) ) ;
6459 }
6560
66- let result = rpc_response
61+ rpc_response
6762 . result
68- . ok_or_else ( || A2AError :: internal ( "JSON-RPC response missing result" ) ) ?;
63+ . ok_or_else ( || A2AError :: internal ( "JSON-RPC response missing result" ) )
64+ }
65+
66+ async fn call_value < Req > (
67+ & self ,
68+ params : & ServiceParams ,
69+ method : & str ,
70+ request_params : & Req ,
71+ ) -> Result < serde_json:: Value , A2AError >
72+ where
73+ Req : ProtoJsonPayload ,
74+ {
75+ let payload = protojson_conv:: to_value ( request_params) . map_err ( |e| {
76+ A2AError :: internal ( format ! ( "failed to serialize request as ProtoJSON: {e}" ) )
77+ } ) ?;
6978
70- Ok ( result )
79+ self . call_value_with_payload ( params , method , payload ) . await
7180 }
7281
7382 async fn call < Req , Resp > (
@@ -341,8 +350,9 @@ impl Transport for JsonRpcTransport {
341350 params : & ServiceParams ,
342351 req : & CreateTaskPushNotificationConfigRequest ,
343352 ) -> Result < TaskPushNotificationConfig , A2AError > {
353+ let payload = serialize_create_task_push_notification_config_request ( req) ?;
344354 let result = self
345- . call_value ( params, methods:: CREATE_PUSH_CONFIG , req )
355+ . call_value_with_payload ( params, methods:: CREATE_PUSH_CONFIG , payload )
346356 . await ?;
347357 deserialize_task_push_notification_config ( result)
348358 }
0 commit comments