Get required parameters as object

@param string ...$requiredParameters

@return stdClass
@throws BadRequestException
@throws Exception
179397
public static function requireParamsObj(string ...$requiredParameters): stdClass
    {
        $class = new stdClass();

        foreach (static::requireParams(...$requiredParameters) as $param => $value) {
            $class->$param = $value;
        }

        return $class;
    }
19079
protected function _get($url, $parameters = null, $scopes = [], $class = null) {
        $client = new HttpClient($this->patrol, 'get', $url, $parameters);

        $client->setScopes($scopes);

        $data = $client->response();

        if (isset($data['error'])) {
            $this->_error($data);
        }

        $data = $data['data'];

        $callee = $class ? $class : get_called_class();
        return Util::parseResponseToPatrolObject($this->patrol, $data, $callee, $this->defaults);
    }
1120984
public function checkAuthorizeParams()
    {
        // Get required params
        $clientId = $this->server->getRequest()->query->get('client_id', null);
        if (is_null($clientId)) {
            throw new Exception\InvalidRequestException('client_id');
        }

        $redirectUri = $this->server->getRequest()->query->get('redirect_uri', null);
        if (is_null($redirectUri)) {
            throw new Exception\InvalidRequestException('redirect_uri');
        }

        // Validate client ID and redirect URI
        $client = $this->server->getClientStorage()->get(
            $clientId,
            null,
            $redirectUri,
            $this->getIdentifier()
        );

        if (($client instanceof ClientEntity) === false) {
            $this->server->getEventEmitter()->emit(new Event\ClientAuthenticationFailedEvent($this->server->getRequest()));
            throw new Exception\InvalidClientException();
        }

        $state = $this->server->getRequest()->query->get('state', null);
        if ($this->server->stateParamRequired() === true && is_null($state)) {
            throw new Exception\InvalidRequestException('state', $redirectUri);
        }

        $responseType = $this->server->getRequest()->query->get('response_type', null);
        if (is_null($responseType)) {
            throw new Exception\InvalidRequestException('response_type', $redirectUri);
        }

        // Ensure response type is one that is recognised
        if (!in_array($responseType, $this->server->getResponseTypes())) {
            throw new Exception\UnsupportedResponseTypeException($responseType, $redirectUri);
        }

        // Validate any scopes that are in the request
        $scopeParam = $this->server->getRequest()->query->get('scope', '');
        $scopes = $this->validateScopes($scopeParam, $client, $redirectUri);

        return [
            'client'        => $client,
            'redirect_uri'  => $redirectUri,
            'state'         => $state,
            'response_type' => $responseType,
            'scopes'        => $scopes
        ];
    }
11516
public function parameters(): array
    {
        return array_map(
                function($parameter)
                {
                    $param = new Parameter(
                            $parameter->getName(),
                            $parameter->getDescription(),
                            $parameter->getIn()
                    );

                    if ($parameter->hasValueByName('required') && $parameter->isRequired()) {
                        $param->markRequired();
                    }

                    return $param;
                },
                $this->annotations->named('Parameter')
        );
    }
607997
public function actionFetchPlans()
    {
        try {
            $this->requirePostRequest();
            $this->requireAcceptsJson();

            $request = Craft::$app->getRequest();
            $gatewayId = $request->getRequiredBodyParam('gatewayId');
            $gateway = Commerce::getInstance()->getGateways()->getGatewayById($gatewayId);

            if (!$gateway || !$gateway instanceof Gateway) {
                throw new BadRequestHttpException('That is not a valid gateway id.');
            }

            return $this->asJson($gateway->getSubscriptionPlans());
        } catch (\Throwable $e) {
            return $this->asErrorJson($e->getMessage());
        }
    }
761352
public function prepareRequestParameters(array $defaults, array $options)
    {
        $defaults['grant_type'] = $this->getName();

        $required = $this->getRequiredRequestParameters();
        $provided = array_merge($defaults, $options);

        $this->checkRequiredParameters($required, $provided);

        return $provided;
    }
1218170
public static function getInstance(...$constructorParams)
    {
        $class = get_called_class();
        if (isset(static::$instanceOfClass[$class])) {
            return static::$instanceOfClass[$class];
        }
        static::$instanceOfClass[$class] = $nstnc = new static(...$constructorParams);
        return $nstnc;
    }
549113
public function retrieveSmartFormHTML($requestParams)
    {
        $requiredParams = array("id");
        return $this->client->request($requestParams, $this->_mainFormEndpoint, "get", $requiredParams, $options = NULL);
    }
861440
protected function getMethodParams(\ReflectionMethod $reflectionMethod, $requestParams)
    {
        $actionParams = [];
        $methodParams = $reflectionMethod->getParameters();

        foreach ($methodParams as $param) {
            $paramName = $param->getName();
            if (!array_key_exists($paramName, $requestParams)) {
                throw new \yii\web\BadRequestHttpException("Not found JSON-RPC request parameter '{$paramName}'.");
            }

            $paramClass = $param->getClass();
            $actionParams[$paramName] = !empty($paramClass) ? $this->getParameterModel($paramName, $paramClass->name, $requestParams) : $requestParams[$paramName];
        }

        return $actionParams;
    }
794982
protected static function getRequestData($parameters)
    {
        //work with objects
        if (!is_object($parameters) && is_array($parameters)) {
            $parameters = (object) $parameters;
        }

        //Require data
        Request::requireParameters($parameters, ['data']);

        return $parameters->data;
    }
505029
protected function doRequest($reqParams)
    {
        Log::debug('RPC json inner request params', $reqParams);

        if ($this->method == 'GET') {
            $res = (new Client())->get($this->url, ['params' => json_encode($reqParams)]);
        } else {
            $res = (new Client())->post($this->url, [], ['params' => json_encode($reqParams)]);
        }

        Log::debug('RPC json inner request result', ['result' => $res]);

        if ($res->code() != 200) {
            Log::warning('RPC error', ['url' => $this->url, 'params' => $reqParams, 'result' => $res]);

            throw new \Exception('RPC request failed');
        }

        return json_decode($res, true);
    }
855862
public function get(string $name, ...$params) {
        if ($this->created->containsKey($name)) return $this->created->getNodeByKey($name)->getValue();
        if ($this->instances->containsKey($name)) return $this->fromInstances($name, $params);

        try {
            $reflectionClass = new ReflectionClass($name);
            $constructor = $reflectionClass->getConstructor();
            $parameters = [];

            if (null !== $constructor) {
                /** @var ReflectionParameter $parameter */
                foreach ($constructor->getParameters() as $parameter) {
                    $className = $parameter->getClass()->getName();
                    $class = $this->get($className);
                    if (null === $class) throw new ClassNotFoundException();
                    $parameters[] = $class;
                }
            }
            $clazz = $reflectionClass->newInstanceArgs($parameters + $params);
            $this->created->add($name, $clazz);
            return $clazz;
        } catch (Exception $exception) {
            return null;
        }
    }
511136
public function get(array $params) {
        $this->_requireDataType($params);

        if (array_get($params, 'datatype') === self::METHOD_DICTIONARY) {
            return $this->getDictionary();
        } elseif (array_get($params, 'relatedType') && array_get($params, 'id')) {
            list($response, $httpCode) = $this->_getRelatedResults($params);
        } elseif (array_get($params, 'id')) {
            list($response, $httpCode) = $this->_getSingleResult($params);
        } else {
            list($response, $httpCode) = $this->_getIndex($params);
        }

        return $this->_formatResponse($response, $httpCode);
    }
901601
public function create($params, $optParams = [])
    {
        if (!$params instanceof Firewall) {
            throw new InvalidParamException(Firewall::class.' is required!');
        }

        return $this->sendRequest([], [
            'restAction' => 'create',
            'postParams' => $params->toArray(),
            'getParams' => $optParams,
        ], function ($response) {
            return isset($response->data) ? new Firewall($response->data) : $response;
        });
    }
1305948
public function getRequiredOptions()
    {
        if (! $this->required) {
            return null;
        }

        if ($this->required instanceof ConfigInterface) {
            return $this->required->getArrayCopy();
        }

        return (array)$this->required;
    }
1247206
protected function cleanParamWithRequirements(ParamInterface $param, $paramValue, $strict, $default)
    {
        $this->checkNotIncompatibleParams($param);
        if (null !== $default && $default === $paramValue) {
            return $paramValue;
        }

        if (null === $this->validator) {
            throw new \RuntimeException(
                'The ParamFetcher requirements feature requires the symfony/validator component.'
            );
        }

        $constraints = $param->getConstraints();
        $this->resolveConstraints($constraints);
        if (empty($constraints)) {
            return $paramValue;
        }

        try {
            $errors = $this->validator->validate($paramValue, $constraints);
        } catch (ValidatorException $e) {
            $violation = new ConstraintViolation(
                $e->getMessage(),
                $e->getMessage(),
                array(),
                $paramValue,
                '',
                null,
                null,
                $e->getCode()
            );
            $errors = new ConstraintViolationList(array($violation));
        }

        if (0 < count($errors)) {
            if ($strict) {
                throw InvalidParameterException::withViolations($param, $errors);
            }

            return null === $default ? '' : $default;
        }

        return $paramValue;
    }
1238009
public function update($params, $optParams = [])
    {
        if (!$params instanceof AccessToken) {
            throw new InvalidParamException(AccessToken::class . ' is required!');
        }
        $class = get_class($params);

        return $this->sendRequest([], [
            'restAction' => 'update',
            'restId' => $params->id,
            'postParams' => $params->toArray(),
            'getParams' => $optParams,
        ], function ($response) use ($class) {
            return isset($response->data) ? new $class($response->data) : $response;
        });
    }