public function serializeOptions(Operation $operation, array $userValues = []) : array { $options = ['headers' => []]; foreach ($userValues as $paramName => $paramValue) { if (null === ($schema = $operation->getParam($paramName))) { continue; } $this->callStockingMethod($schema, $paramValue, $options); } if (!empty($options['json'])) { if ($key = $operation->getJsonKey()) { $options['json'] = [$key => $options['json']]; } if (strpos(json_encode($options['json']), '\\/') !== false) { $options['body'] = json_encode($options['json'], JSON_UNESCAPED_SLASHES); $options['headers']['Content-Type'] = 'application/json'; unset($options['json']); } } return $options; }
/** * @param Operation $operation * @param array $userValues * @param bool $async * * @return mixed * @throws \Exception */ protected function sendRequest(Operation $operation, array $userValues = [], bool $async = false) { $operation->validate($userValues); $options = (new RequestSerializer())->serializeOptions($operation, $userValues); $method = $async ? 'requestAsync' : 'request'; $uri = uri_template($operation->getPath(), $userValues); return $this->client->{$method}($operation->getMethod(), $uri, $options); }