offsetExists('key') === true) { $mode = empty($command->offsetGet('auth')) === false ? $command->offsetGet('auth') : 'loco'; if ($mode !== 'query') { // else use Authorization header of various types if ($mode === 'loco') { $value = 'Loco '.$command->offsetGet('key'); $request = $request->withHeader('Authorization', $value); } elseif ($mode === 'basic') { $value = 'Basic '.base64_encode($command->offsetGet('key').':'); $request = $request->withHeader('Authorization', $value); } else { throw new \InvalidArgumentException("Invalid auth type: {$mode}"); } // avoid request sending key parameter in query string $command->offsetUnset('key'); } } // Remap legacy parameters to common `data` binding on request body static $remap = [ 'import' => ['src'=>'data'], 'translate' => ['translation'=>'data'], ]; $name = $command->getName(); if (isset($remap[$name])) { foreach ($remap[$name] as $old => $new) { if ($command->offsetExists($old)) { $command->offsetSet($new, $command->offsetGet($old)); $command->offsetUnset($old); } } } */ return parent::prepareRequest($command, $request); } }