@@ -158,27 +158,14 @@ impl DigitalTwinGraphImpl {
158
158
/// * `client` - The client to use to send the ask.
159
159
/// * `respond_uri` - The respond uri.
160
160
/// * `ask_id` - The ask id.
161
- /// * `instance_id` - The instance id.
162
- /// * `member_path` - The member path.
163
- /// * `operation` - The operation.
164
- /// * `payload` - The payload.
161
+ /// * `targeted_payload` - The targeted payload.
165
162
pub async fn send_ask (
166
163
& self ,
167
164
mut client : RequestClient < tonic:: transport:: Channel > ,
168
165
respond_uri : & str ,
169
166
ask_id : & str ,
170
- instance_id : & str ,
171
- member_path : & str ,
172
- operation : & str ,
173
- payload : & str ,
167
+ targeted_payload : & TargetedPayload ,
174
168
) -> Result < ( ) , tonic:: Status > {
175
- let targeted_payload = TargetedPayload {
176
- instance_id : instance_id. to_string ( ) ,
177
- member_path : member_path. to_string ( ) ,
178
- operation : operation. to_string ( ) ,
179
- payload : payload. to_string ( ) ,
180
- } ;
181
-
182
169
// Serialize the targeted payload.
183
170
let targeted_payload_json = serde_json:: to_string_pretty ( & targeted_payload) . unwrap ( ) ;
184
171
@@ -304,17 +291,16 @@ impl DigitalTwinGraph for DigitalTwinGraphImpl {
304
291
// Note: The ask id must be a universally unique value.
305
292
let ask_id = Uuid :: new_v4 ( ) . to_string ( ) ;
306
293
294
+ // Create the targeted payload.
295
+ let targeted_payload = TargetedPayload {
296
+ instance_id : instance_id. to_string ( ) ,
297
+ member_path : "" . to_string ( ) ,
298
+ operation : digital_twin_operation:: GET . to_string ( ) ,
299
+ payload : "" . to_string ( ) ,
300
+ } ;
301
+
307
302
// Send the ask.
308
- self . send_ask (
309
- client,
310
- & self . respond_uri ,
311
- & ask_id,
312
- & instance_id,
313
- "" ,
314
- digital_twin_operation:: GET ,
315
- "" ,
316
- )
317
- . await ?;
303
+ self . send_ask ( client, & self . respond_uri , & ask_id, & targeted_payload) . await ?;
318
304
319
305
// Wait for the answer.
320
306
let answer_request = self . wait_for_answer ( ask_id, & mut rx) . await ?;
@@ -378,17 +364,16 @@ impl DigitalTwinGraph for DigitalTwinGraphImpl {
378
364
// Note: The ask id must be a universally unique value.
379
365
let ask_id = Uuid :: new_v4 ( ) . to_string ( ) ;
380
366
367
+ // Create the targeted payload.
368
+ let targeted_payload = TargetedPayload {
369
+ instance_id : instance_id. to_string ( ) ,
370
+ member_path : member_path. to_string ( ) ,
371
+ operation : digital_twin_operation:: GET . to_string ( ) ,
372
+ payload : "" . to_string ( ) ,
373
+ } ;
374
+
381
375
// Send the ask.
382
- self . send_ask (
383
- client,
384
- & self . respond_uri ,
385
- & ask_id,
386
- & instance_id,
387
- & member_path,
388
- digital_twin_operation:: GET ,
389
- "" ,
390
- )
391
- . await ?;
376
+ self . send_ask ( client, & self . respond_uri , & ask_id, & targeted_payload) . await ?;
392
377
393
378
// Wait for the answer.
394
379
let answer_request = self . wait_for_answer ( ask_id, & mut rx) . await ?;
@@ -460,17 +445,16 @@ impl DigitalTwinGraph for DigitalTwinGraphImpl {
460
445
// Note: The ask id must be a universally unique value.
461
446
let ask_id = Uuid :: new_v4 ( ) . to_string ( ) ;
462
447
448
+ // Create the targeted payload.
449
+ let targeted_payload = TargetedPayload {
450
+ instance_id : instance_id. to_string ( ) ,
451
+ member_path : member_path. to_string ( ) ,
452
+ operation : digital_twin_operation:: INVOKE . to_string ( ) ,
453
+ payload : request_payload. to_string ( ) ,
454
+ } ;
455
+
463
456
// Send the ask.
464
- self . send_ask (
465
- client,
466
- & self . respond_uri ,
467
- & ask_id,
468
- & instance_id,
469
- & member_path,
470
- digital_twin_operation:: INVOKE ,
471
- & request_payload,
472
- )
473
- . await ?;
457
+ self . send_ask ( client, & self . respond_uri , & ask_id, & targeted_payload) . await ?;
474
458
475
459
// Wait for the answer.
476
460
let answer_request = self . wait_for_answer ( ask_id, & mut rx) . await ?;
0 commit comments