@@ -57,17 +57,17 @@ abstract class AbstractEndpoint
57
57
/**
58
58
* @return string[]
59
59
*/
60
- abstract public function getParamWhitelist ();
60
+ abstract public function getParamWhitelist (): array ;
61
61
62
62
/**
63
63
* @return string
64
64
*/
65
- abstract public function getURI ();
65
+ abstract public function getURI (): string ;
66
66
67
67
/**
68
68
* @return string
69
69
*/
70
- abstract public function getMethod ();
70
+ abstract public function getMethod (): string ;
71
71
72
72
73
73
/**
@@ -82,9 +82,9 @@ public function setParams($params)
82
82
$ params = (array ) $ params ;
83
83
}
84
84
85
+ $ this ->extractOptions ($ params );
85
86
$ this ->checkUserParams ($ params );
86
87
$ params = $ this ->convertCustom ($ params );
87
- $ this ->extractOptions ($ params );
88
88
$ this ->params = $ this ->convertArraysToStrings ($ params );
89
89
90
90
return $ this ;
@@ -243,7 +243,7 @@ private function checkUserParams($params)
243
243
return ; //no params, just return.
244
244
}
245
245
246
- $ whitelist = array_merge ($ this ->getParamWhitelist (), array ('client ' , 'custom ' , 'filter_path ' , 'human ' ));
246
+ $ whitelist = array_merge ($ this ->getParamWhitelist (), array ('client ' , 'custom ' , 'filter_path ' , 'human ' , ' opaqueId ' ));
247
247
248
248
$ invalid = array_diff (array_keys ($ params ), $ whitelist );
249
249
if (count ($ invalid ) > 0 ) {
@@ -264,6 +264,15 @@ private function extractOptions(&$params)
264
264
{
265
265
// Extract out client options, then start transforming
266
266
if (isset ($ params ['client ' ]) === true ) {
267
+ // Check if the opaqueId is populated and add the header
268
+ if (isset ($ params ['client ' ]['opaqueId ' ]) === true ) {
269
+ if (isset ($ params ['client ' ]['headers ' ]) === false ) {
270
+ $ params ['client ' ]['headers ' ] = [];
271
+ }
272
+ $ params ['client ' ]['headers ' ]['x-opaque-id ' ] = [trim ($ params ['client ' ]['opaqueId ' ])];
273
+ unset($ params ['client ' ]['opaqueId ' ]);
274
+ }
275
+
267
276
$ this ->options ['client ' ] = $ params ['client ' ];
268
277
unset($ params ['client ' ]);
269
278
}
0 commit comments