Process request params

- type conversion
- set default value

@param  array $requestParams

@return array
769110
public function params($requestParams): array
    {
        // apply type and default value for request params
        $params = [];
        foreach ($this->params as $param => $type) {
            if (isset($requestParams[$param])) {
                switch ($type) {
                    case 'bool':
                    case 'boolean':
                        $params[] = (bool)$requestParams[$param];
                        break;
                    case 'int':
                    case 'integer':
                        $params[] = (int)$requestParams[$param];
                        break;
                    case 'float':
                        $params[] = (float)$requestParams[$param];
                        break;
                    case 'string':
                        $params[] = (string)$requestParams[$param];
                        break;
                    case 'array':
                        $params[] = (array)$requestParams[$param];
                        break;
                    default:
                        $params[] = $requestParams[$param];
                        break;
                }
            } elseif (isset($this->values[$param])) {
                $params[] = $this->values[$param];
            } else {
                $params[] = null;
            }
        }
        return $params;
    }
1141832
function _setParams( $params, $defaults=FALSE ) {
    if( !is_array( $params))
      $params = array();
    $input = array();
    foreach( $params as $paramKey => $paramValue ) {
      if( is_array( $paramValue )) {
        foreach( $paramValue as $pkey => $pValue ) {
          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
            $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
        }
      }
      elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
        $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
      if( 'VALUE' == strtoupper( $paramKey ))
        $input['VALUE']                 = strtoupper( $paramValue );
      else
        $input[strtoupper( $paramKey )] = $paramValue;
    }
    if( is_array( $defaults )) {
      foreach( $defaults as $paramKey => $paramValue ) {
        if( !isset( $input[$paramKey] ))
          $input[$paramKey] = $paramValue;
      }
    }
    return (0 < count( $input )) ? $input : null;
  }
226404
public function parseParams($allowedParams)
    {
        $this->allowedParams = $allowedParams;
        $this->setDefaultParams();

        foreach ($this->rawParams as $checkParam => $value) {
            if (! $paramOptions = $this->getParamOptions($checkParam)) {
                continue;
            }

            $param = $paramOptions['param'];
            $options = $paramOptions['options'];

            $paramValue = $this->getParamValue($param, $options, $value);
            if (isset($this->params[$param]) && is_array($this->params[$param])) {
                $this->params[$param] = array_merge($this->params[$param], $paramValue);
            } else {
                $this->params[$param] = $paramValue;
            }
        }
    }
1103719
public function prepareRequest($params = 'default')
    {
        if (is_string($params)) {
            // 载入请求模板
            $params = RequestTemplate::loadTemplate($this->getModule(), $this->getAction(), $params);
        } elseif ( ! is_array($params)) {
            $params = array();
        }

        $params['apiKey'] = isset($params['apiKey']) ? $params['apiKey'] : Config::get('API_KEY');
        $params['apiUser'] = isset($params['apiUser']) ? $params['apiUser'] : Config::get('API_USER');
        $this->data = $params;

        return $this;
    }
305396
protected function prepareParams(array $params)
	{
		$prepared = [];
		
		foreach($params as $k => $v)
		{
			if(is_array($v))
			{
				foreach(array_values($v) as $i => $val)
				{
					$prepared[sprintf('%s%u', $k, $i)] = $val;
				}
			}
			else
			{
				$prepared[(string)$k] = $v;
			}
		}
		
		return $prepared;
	}
1063606
public function complete($requestParams)
    {
        $options["headers"] = self::retrieveContentTypeHeader(self::CONTENT_TYPE_JSON);
        $requiredParams = array("object_type_id");
        return $this->client->request($requestParams, $this->_mainTaskEndpoint."/". self::TASK_COMPLETE, "post", $requiredParams, $options);
    }
688244
public function optionalParameters($params = null)
  {
    if (null === $params)
    {
      return $this->responseConfig['optionalParameters'];
    }

    if (false === is_array($params))
    {
      throw new InvalidArgumentException(sprintf(
        "%s is no valid parameter: Use an array with Key => Value Pairs", $params
      ));
    }

    $this->responseConfig['optionalParameters'] = $params;

    return $this;
  }
549113
public function retrieveSmartFormHTML($requestParams)
    {
        $requiredParams = array("id");
        return $this->client->request($requestParams, $this->_mainFormEndpoint, "get", $requiredParams, $options = NULL);
    }
434015
public function getValue($params = [], $processCallbacks = true)
    {
        foreach ($this->defaultParams as $i => $defaultValue) {
            if (!isset($params[$i])) {
                $params[$i] = $defaultValue;
            }
        }

        // In case the value of this dynamic attribute is stored to DB, we pass the stored value as the last parameter to the function
        $params[] = $this->storedValue;
        $value = call_user_func_array($this->callable, $params);

        return $this->processGetValue($value, [], $processCallbacks);
    }
616242
protected function processRequest( array $reqparams )
	{
		try
		{
			if( !isset( $reqparams['params'] ) || ( $params = json_decode( $reqparams['params'] ) ) === null ) {
				throw new \Aimeos\Controller\ExtJS\Exception( 'Required parameters are missing or not JSON encoded' );
			}

			if( ( $result = $this->callMethod( $reqparams['method'], $params ) ) !== null ) {
				return json_encode( $result );
			}
		}
		catch( \Exception $e )
		{
			$response = array(
				'error' => array(
					'code' => ( $e->getCode() != 0 ? $e->getCode() : -1 ),
					'message' => $e->getMessage(),
				),
				'status' => 'failure'
			);

			return json_encode( $response );
		}

		return null;
	}
264770
public function submit(RequestParameters $params)
    {
        $handle = $this->curl->init($this->siteVerifyUrl);

        $options = array(
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => $params->toQueryString(),
            CURLOPT_HTTPHEADER => array(
                'Content-Type: application/x-www-form-urlencoded'
            ),
            CURLINFO_HEADER_OUT => false,
            CURLOPT_HEADER => false,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => true
        );
        $this->curl->setoptArray($handle, $options);

        $response = $this->curl->exec($handle);
        $this->curl->close($handle);

        if ($response !== false) {
            return $response;
        }

        return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}';
    }
178311
public function updateDefault(array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::PUT,
            ResourceMethodEnum::UPDATE_DEFAULT,
            $params,
            null
        );
    }
263093
protected function params(Request $request, array $params, $default = null)
    {
        $data = [];
        foreach ($params as $param) {
            $data[$param] = $request->getParam($param, $default);
        }

        return $data;
    }
1165568
public function normalizeParams(array $params): array
    {
        foreach ($params as $key => $value) {
            if (false === \is_string($value) && false === \is_resource($value)) {
                $params[$key] = json_encode($value);
            }
        }

        return $params;
    }
210761
private static function getSelfUrlParams($requestParams, $paramsNew, $opts)
    {
        $params = $requestParams;
        $paramsQuery = Str::parse($_SERVER['QUERY_STRING']);    // params from QUERY_STRING
        // compare $_GET with QUERY_STRING & REQUEST_URI to see what's been added/removed/changed
        //  if a param has changed between QUERY_STRING & $_GET, it will be added as a default
        //  if in QUERY_STRING, but not in REQUEST_URI, it will NOT be added as a default
        $cor = array_diff_assoc($paramsQuery, $_GET);   // Changed Or Removed params
        $coa = array_diff_assoc($_GET, $paramsQuery);   // Changed Or Added params
        foreach ($cor as $k => $v) {
            if (!isset($coa[$k])) {
                unset($params[$k]); // it's a remove
            } elseif (isset($coa[$k]) && $coa[$k] != $v) {
                continue;   // $_GET[param] has changed in code
            } elseif (!isset($requestParams[$k])) {
                // $k is in QUERY_STRING, but not REQUEST_URI (mod_rewrite created)
                unset($coa[$k]);
            }
        }
        foreach ($coa as $k => $v) {
            $params[$k] = $v;       // it's a change or add
        }
        if (!empty($opts['getLock'])) {
            foreach ($opts['getLock'] as $k) {
                if (isset($params[$k])) {
                    $params[$k] = isset($requestParams[$k])
                        ? $requestParams[$k]    // use REQUEST_URI val
                        : null;                         // not in REQUEST_URI
                }
            }
        }
        if (!$opts['keepParams']) {
            // keep default params only if in getProp
            foreach ($params as $k => $v) {
                if (!in_array($k, $opts['getProp'])) {
                    unset($params[$k]);
                }
            }
        }
        foreach ($paramsNew as $k => $v) {
            $params[$k] = $v;
        }
        return $params;
    }
1337221
public function loadFromArray($params)
    {
        if (!isset($params['requestTimestamp']) || !is_int($params['requestTimestamp'])) {
            throw new ValidationException('The "requestTimestamp" value is missing or invalid.');
        }

        if (!isset($params['signature']) || !is_string($params['signature'])) {
            throw new ValidationException('The "signature" parameter is missing.');
        }

        if (!isset($params['queryParameters']) || !is_array($params['queryParameters'])) {
            throw new ValidationException('The "queryParameters" parameter is missing or invalid.');
        }

        if (!isset($params['body']) || !is_string($params['body'])) {
            throw new ValidationException('The "body" parameter is missing.');
        }

        return parent::loadFromArray($params);
    }
979913
protected function getQueryParams(array $params = []): string
    {
        if (empty($params)) {
            return '';
        }
        $query = $params['query'] ?? [];
        if (is_string($query)) {
            return $query;
        }
        return empty($query) ? '' : http_build_query($query);
    }