Merge and remap params

@param       $method
@param array $params

@return mixed
770708
public function mergeParams($method, Array $params = [])
    {
        $result = parent::mergeParams($method, $params);

        foreach ($this->map as $oldKey => $newKey)
        {
            if (array_key_exists($oldKey, $result[$method])) {
                $result[$method][$newKey] = $result[$method][$oldKey];
                $result[$method][$oldKey] = null;
                unset($result[$method][$oldKey]);
            }
        }

        return $result;
    }
1235684
public function request($method, array $params = [])
    {
        return new Request($this->endpoint, $this->secret, $method, $params);
    }
949169
def with_params(self, params):
        
        return self.replace(params=_merge_maps(self.params, params))
153521
public function resolve(array $params)
    {
        $merged = $this->merge($params);
        $resolved = $this->read($merged);

        return $resolved;
    }
727786
private function getUrlToOldApi($method, array $params, $format)
    {
        $queryString = sprintf(
            '?apikey=%s&format=%s&method=%s%s',
            $this->getApiKey(),
            $format,
            $method,
            $this->paramsQueryStringBuilder($params)
        );

        return sprintf(
            $this::API_URL,
            $this->getDc(),
            $this->getApiVersion(),
            $queryString
        );
    }
649802
public function parameterize($method)
    {
        $parameterArray = array();
        switch ($method) {
            case 'create':
                $parameterArray['token'] = $this->getToken();
                $parameterArray['client'] = $this->getClient();
                break;
            case 'delete':
                break;
            case 'getOne':
                $parameterArray['count'] = 1;
                $parameterArray['offset'] = 0;
                break;
            case 'getAll':
                $parameterArray = $this->getFilter();
                break;
        }

        return $parameterArray;
    }
798721
public function mergeParams($params)
    {
        foreach ($params as $k => $v) {
            if (is_int($k)) {
                $this->positionParams[] = $v;
            } else {
                $this->params[$k] = $v;
            }
        }

        return $this;
    }
792742
public function api($method, $params = array())
    {
        if (!in_array($method, $this->supportedUnitpayMethods)) {
            throw new UnexpectedValueException('Method is not supported');
        }

        if (isset($this->requiredUnitpayMethodsParams[$method])) {
            foreach ($this->requiredUnitpayMethodsParams[$method] as $rParam) {
                if (!isset($params[$rParam])) {
                    throw new InvalidArgumentException('Param '.$rParam.' is null');
                }
            }
        }

        $params['secretKey'] = $this->secretKey;
        if (empty($params['secretKey'])) {
            throw new InvalidArgumentException('SecretKey is null');
        }

        $requestUrl = self::API_URL . '?' . http_build_query([
            'method' => $method,
            'params' => $params
        ], null, '&', PHP_QUERY_RFC3986);

        $response = json_decode(file_get_contents($requestUrl));
        if (!is_object($response)) {
            throw new InvalidArgumentException('Temporary server error. Please try again later.');
        }

        return $response;
    }
1204990
public function prepareRequest($method, array $params = [])
    {
        $request = [
            'jsonrpc' => '2.0',
            'method'  => $method,
            'id'      => mt_rand()
        ];

        $request['params'] = $params ? $params : [];

        /*$request['params'] = array_merge($request['params'], $this->params);*/
        return $request;
    }
883063
private function _parseUrl(string $method, array $params = [])
    {
        $params = [
                'module' => 'API',
                'method' => $method,
                'token_auth' => $this->_token,
                'idSite' => $this->_siteId,
                'period' => $this->_period,
                'format' => $this->_format,
                'language' => $this->_language,
                'filter_limit' => $this->_filter_limit
            ] + $params;

        foreach ($params as $key => $value) {
            $params[$key] = urlencode($value);
        }

        if (!empty($this->_rangeStart) && !empty($this->_rangeEnd)) {
            $params = $params + [
                    'date' => $this->_rangeStart . ',' . $this->_rangeEnd,
                ];
        } elseif (!empty($this->_date)) {
            $params = $params + [
                    'date' => $this->_date,
                ];
        } else {
            throw new InvalidArgumentException('Specify a date or a date range!');
        }

        $url = $this->_site;

        $i = 0;
        foreach ($params as $param => $val) {
            if (!empty($val)) {
                $i++;
                if ($i > 1) {
                    $url .= '&';
                } else {
                    $url .= '?';
                }

                if (is_array($val)) {
                    $val = implode(',', $val);
                }
                $url .= $param . '=' . $val;
            }
        }

        return $url;
    }
821745
private function checkParametersResolving($method, array $params = [])
    {
        if (!$this->resolveMethods) {
            return $params;
        }

        return app()->make(ServiceShortCuts::RESOLVER_SERVICE)->resolveMethodParameters($this, $method, $params);
    }
924184
public static function map(array $array, $method)
    {
        //used to make sure the method is valid
        if (gettype($method)==='object') {
            foreach ($array as $key=>$value) {
                //assign return values to value of the array
                $array[$key] = call_user_func_array($method, [$key,$value]);
            }
            //return the modified array
            return $array;
        } else {
            //send error messages if the method is not valid
            system::add_error('ary::map()', 'missing_function', 'second parameter must be a function object');
        }
    }
1200026
public function call($method, Array $params = [])
    {
        $params = $this->mergeParams($method, $params);
        try {
            $result = $this->soapClient->__soapCall($method, $params);
        } catch (SoapFault $fault) {
            // @todo log
            throw $fault;
        }

        return $result;
    }
970151
public function call($method, Array $params = [])
    {
        $rawResult = parent::call($method, $params);

        switch ($method) {
            case 'GetCarBrandAndModel':
                $result = $rawResult->GetCarBrandAndModelReturn->MakeModelBean;
            break;

            case 'GetCarBrand':
                $result = $rawResult->GetCarBrandReturn->x_car_brand->string;
        }

        return $result;
    }
961210
public function mergeParams($method, Array $params = [])
    {
        $newParams = [];
        $preparedParams = $this->defaultParams;
        $preparedParams['bean'] = $params;

        $newParams[$method] = $preparedParams;

        return $newParams;
    }
707582
public function assemble(array $params = [], array $options = [])
    {
        $elements              = [];
        $mergedParams          = array_replace($this->defaults, $params);
        $this->assembledParams = [];

        foreach ($this->exclude as $key) {
            unset($mergedParams[$key]);
        }

        if ($mergedParams) {
            foreach ($mergedParams as $key => $value) {
                if (is_array($value)) {
                    foreach ($value as $ivalue) {
                        $elements[] = rawurlencode($key) . $this->keyValueDelimiter . rawurlencode($ivalue);
                    }
                } else {
                    $elements[] = rawurlencode($key) . $this->keyValueDelimiter . rawurlencode($value);
                }
                $this->assembledParams[] = $key;
            }

            return $this->paramDelimiter . implode($this->paramDelimiter, $elements);
        }

        return '';
    }
1120136
public function get($method, array $params, array $options = array())
    {
        $this->parseOptions($options);

        $params = array_merge($params, $this->apiKeys);

        $response = $this->httpAdapter->getContent(
            sprintf(self::API_ENDPOINT, $this->scheme, $this->outputFormat, $method .'?'. http_build_query($params)),
            $this->headers
        );

        return $this->responseHandler($response);
    }