@param string $project
@param array  $params

@throws \Http\Client\Exception

@return array
553301
public function show(string $project, array $params = [])
    {
        $path = $this->buildProjectsPath($project);

        return $this->get($path, $params);
    }
730174
protected function executePreparedStatement($query, $params)
        {
            $res = odbc_prepare($this->_lnk, $query);
            if(!$res) {
                $error = odbc_errormsg($this->_lnk);
                $this->log('Prepare failed: ' . $error);
                throw new Exception('Preparing query failed ' . $error, self::PREPARE_FAILED);
            }
            $res = odbc_execute($res, $params);
            if(!$res) {
                $error = odbc_errormsg($this->_lnk);
                $this->log('Prepared query execution failed: ' . $error);
                throw new Exception('Executing prepared query failed ' . $error, self::QUERY_FAILED);
            }
            return $res;
        }
1244851
public function request($method, $params = [])
    {
        $response = $this->client->post($this->getUrl($method), ['query' => $params]);

        if ($response->getStatusCode() === 200) {
            return (string)$response->getBody();
        } else {
            throw new Exception(sprintf('Sms.ru problem. Status code is %s', $response->getStatusCode()), $response->getStatusCode());
        }
    }
800920
public function call($method, $params = [])
    {
        if (null === $this->client) {
            $this->client = new Client([
                'base_uri' => static::API_URL,
                'content-type' => 'application/json',
            ]);
        }

        $requestParams = array_merge($this->defaultParams, [
            $method => [$params],
        ]);

        if ($this->sandbox) {
            $requestParams['apikey'] = self::SANDBOX_KEY;
        }

        $response = $this->client->post(null, ['body' => json_encode($requestParams)]);
        if ($response->getStatusCode() != 200) {
            throw new \Exception('Api http error: ' . $response->getStatusCode(), $response->getStatusCode());
        }

        $result = json_decode($response->getBody(), true);
        if (isset($result['error'])) {
            throw new \BadMethodCallException('Api error: ' . $result['error']['description'],
                $result['error']['code']);
        }

        return $result;
    }
33605
private function toArray($params) {
		if(is_array($params)) {
			return $params;
		}
		if(is_object($params)) {
			return ArrayHelper::toArray($params);
		}
		throw new InvalidMethodParameterException;
	}
1333799
public function query(string $query, array $params = []): bool
	{
		return $this->execute($this->prepare($query, $params));
	}
668601
public function request($params)
  {
    $query = array_merge($params, [
      'key' => $this->key
    ]);

    try {

      $response = $this->client->get(self::API_ENDPOINT, [
        'query' => $query
      ]);

    } catch (ClientException $exception) {

      return collect([]);

    }

    $results = json_decode($response->getBody(), true);

    $output = [];

    for($i = 0; $i < count($results['itemListElement']); $i++) {
      $output[] = new SearchResult($results['itemListElement'][$i]);
    }

    return collect($output);
  }
24234
public function createConfigFiles($project)
    {
        $contentM4 = $this->backend->getTemplateFileContents('config.m4');
        if (empty($contentM4)) {
            throw new Exception("Template config.m4 doesn't exist");
        }

        $contentW32 = $this->backend->getTemplateFileContents('config.w32');
        if (empty($contentW32)) {
            throw new Exception("Template config.w32 doesn't exist");
        }

        if ('zend' == $project) {
            $safeProject = 'zend_';
        } else {
            $safeProject = $project;
        }

        $compiledFiles = array_map(function ($file) {
            return str_replace('.c', '.zep.c', $file);
        }, $this->compiledFiles);

        /**
         * If export-classes is enabled all headers are copied to include/php/ext.
         */
        $exportClasses = $this->config->get('export-classes', 'extra');
        if ($exportClasses) {
            $compiledHeaders = array_map(function ($file) {
                return str_replace('.c', '.zep.h', $file);
            }, $this->compiledFiles);
        } else {
            $compiledHeaders = ['php_'.strtoupper($project).'.h'];
        }

        /*
         * Check extra-libs, extra-cflags, package-dependencies exists
         */
        $extraLibs = $this->config->get('extra-libs');
        $extraCflags = $this->config->get('extra-cflags');
        $contentM4 = $this->generatePackageDependenciesM4($contentM4);

        /**
         * Generate config.m4.
         */
        $toReplace = [
            '%PROJECT_LOWER_SAFE%' => strtolower($safeProject),
            '%PROJECT_LOWER%' => strtolower($project),
            '%PROJECT_UPPER%' => strtoupper($project),
            '%PROJECT_CAMELIZE%' => ucfirst($project),
            '%FILES_COMPILED%' => implode("\n\t", $compiledFiles),
            '%HEADERS_COMPILED%' => implode(' ', $compiledHeaders),
            '%EXTRA_FILES_COMPILED%' => implode("\n\t", $this->extraFiles),
            '%PROJECT_EXTRA_LIBS%' => $extraLibs,
            '%PROJECT_EXTRA_CFLAGS%' => $extraCflags,
        ];

        foreach ($toReplace as $mark => $replace) {
            $contentM4 = str_replace($mark, $replace, $contentM4);
        }

        file_put_contents_ex($contentM4, 'ext/config.m4');

        /**
         * Generate config.w32.
         */
        $toReplace = [
            '%PROJECT_LOWER_SAFE%' => strtolower($safeProject),
            '%PROJECT_LOWER%' => strtolower($project),
            '%PROJECT_UPPER%' => strtoupper($project),
            '%FILES_COMPILED%' => implode(
                "\r\n\t",
                $this->processAddSources($compiledFiles, strtolower($project))
            ),
            '%EXTRA_FILES_COMPILED%' => implode(
                "\r\n\t",
                $this->processAddSources($this->extraFiles, strtolower($project))
            ),
        ];

        foreach ($toReplace as $mark => $replace) {
            $contentW32 = str_replace($mark, $replace, $contentW32);
        }

        $needConfigure = file_put_contents_ex($contentW32, 'ext/config.w32');

        /**
         * php_ext.h.
         */
        $content = $this->backend->getTemplateFileContents('php_ext.h');
        if (empty($content)) {
            throw new Exception("Template php_ext.h doesn't exist");
        }

        $toReplace = [
            '%PROJECT_LOWER_SAFE%' => strtolower($safeProject),
        ];

        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        file_put_contents_ex($content, 'ext/php_ext.h');

        /**
         * ext.h.
         */
        $content = $this->backend->getTemplateFileContents('ext.h');
        if (empty($content)) {
            throw new Exception("Template ext.h doesn't exist");
        }

        $toReplace = [
            '%PROJECT_LOWER_SAFE%' => strtolower($safeProject),
        ];

        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        file_put_contents_ex($content, 'ext/ext.h');

        /**
         * ext_config.h.
         */
        $content = $this->backend->getTemplateFileContents('ext_config.h');
        if (empty($content)) {
            throw new Exception("Template ext_config.h doesn't exist");
        }

        $toReplace = [
            '%PROJECT_LOWER%' => strtolower($project),
        ];

        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        file_put_contents_ex($content, 'ext/ext_config.h');

        /**
         * ext_clean.
         */
        $content = $this->backend->getTemplateFileContents('clean');
        if (empty($content)) {
            throw new Exception("Clean file doesn't exist");
        }

        if (file_put_contents_ex($content, 'ext/clean')) {
            chmod('ext/clean', 0755);
        }

        /**
         * ext_install.
         */
        $content = $this->backend->getTemplateFileContents('install');
        if (empty($content)) {
            throw new Exception("Install file doesn't exist");
        }

        $toReplace = [
            '%PROJECT_LOWER%' => strtolower($project),
        ];

        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        if (file_put_contents_ex($content, 'ext/install')) {
            chmod('ext/install', 0755);
        }

        return (bool) $needConfigure;
    }
867948
public function create(array $params = [])
    {
        $defaults = [
            'issue_id' => null,
            'project_id' => null,
            'spent_on' => null,
            'hours' => null,
            'activity_id' => null,
            'comments' => null,
        ];
        $params = $this->sanitizeParams($defaults, $params);

        if (
            (!isset($params['issue_id']) && !isset($params['project_id']))
         || !isset($params['hours'])
        ) {
            throw new \Exception('Missing mandatory parameters');
        }

        $xml = new \SimpleXMLElement('<?xml version="1.0"?><time_entry></time_entry>');
        foreach ($params as $k => $v) {
            if ('custom_fields' === $k && is_array($v)) {
                $this->attachCustomFieldXML($xml, $v);
            } else {
                $xml->addChild($k, $v);
            }
        }

        return $this->post('/time_entries.xml', $xml->asXML());
    }
1274378
public function query($query, $params = array())
  {
    $results = $this->api->get($query, $params);
    if(!isset($results->errors)) {
      return $results;
    } else {
      return $this->debug_mode ? $results->errors[0]->message : null;
    }
  }
1072048
public function getByProject($project_id, $maxItems = null)
    {
        $project_id = (int) $project_id;
        if ($project_id <= 0) {
            throw new Exception('Invalid param project_id');
        }
        $params      = [];
        $maxItems    = (int) $maxItems;
        if ($maxItems) {
            $params['maxItems'] = $maxItems;
        }

        return $this->rest->get("projects/$project_id/$this->action", $params);
    }
255116
public function create($project, Dns_ManagedZone $postBody, $optParams = array())
  {
    $params = array('project' => $project, 'postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('create', array($params), "Dns_ManagedZone");
  }
888606
public function findByProject($projectId, $params = array(), $options = array())
    {
        $path = sprintf("/projects/%s/tasks", $projectId);
        return $this->client->getCollection($path, $params, $options);
    }
1130669
public function createProjectFiles($project)
    {
        $needConfigure = $this->checkKernelFiles();

        /**
         * project.c.
         */
        $content = $this->backend->getTemplateFileContents('project.c');
        if (empty($content)) {
            throw new Exception("Template project.c doesn't exist");
        }

        $includes = '';
        $reqInitializers = '';
        $reqDestructors = '';
        $prqDestructors = '';
        $modInitializers = '';
        $modDestructors = '';
        $glbInitializers = '';
        $glbDestructors = '';
        $files = array_merge($this->files, $this->anonymousFiles);

        /*
         * Round 1. Calculate the dependency rank
         */
        $this->calculateDependencies($files);

        $classEntries = [];
        $classInits = [];

        $interfaceEntries = [];
        $interfaceInits = [];

        /*
         * Round 2. Generate the ZEPHIR_INIT calls according to the dependency rank
         */
        foreach ($files as $file) {
            /** @var \Zephir\Compiler\FileInterface $file */
            if (!$file->isExternal()) {
                $classDefinition = $file->getClassDefinition();
                if ($classDefinition) {
                    $dependencyRank = $classDefinition->getDependencyRank();
                    if ('class' == $classDefinition->getType()) {
                        if (!isset($classInits[$dependencyRank])) {
                            $classEntries[$dependencyRank] = [];
                            $classInits[$dependencyRank] = [];
                        }
                        $classEntries[$dependencyRank][] =
                            'zend_class_entry *'.$classDefinition->getClassEntry().';';
                        $classInits[$dependencyRank][] =
                            'ZEPHIR_INIT('.$classDefinition->getCNamespace().'_'.
                             $classDefinition->getName().');';
                    } else {
                        if (!isset($interfaceInits[$dependencyRank])) {
                            $interfaceEntries[$dependencyRank] = [];
                            $interfaceInits[$dependencyRank] = [];
                        }
                        $interfaceEntries[$dependencyRank][] =
                            'zend_class_entry *'.$classDefinition->getClassEntry().';';
                        $interfaceInits[$dependencyRank][] =
                            'ZEPHIR_INIT('.$classDefinition->getCNamespace().'_'.
                            $classDefinition->getName().');';
                    }
                }
            }
        }

        krsort($classInits);
        krsort($classEntries);
        krsort($interfaceInits);
        krsort($interfaceEntries);

        $completeInterfaceInits = [];
        foreach ($interfaceInits as $rankInterfaceInits) {
            asort($rankInterfaceInits, SORT_STRING);
            $completeInterfaceInits = array_merge($completeInterfaceInits, $rankInterfaceInits);
        }

        $completeInterfaceEntries = [];
        foreach ($interfaceEntries as $rankInterfaceEntries) {
            asort($rankInterfaceEntries, SORT_STRING);
            $completeInterfaceEntries = array_merge($completeInterfaceEntries, $rankInterfaceEntries);
        }

        $completeClassInits = [];
        foreach ($classInits as $rankClassInits) {
            asort($rankClassInits, SORT_STRING);
            $completeClassInits = array_merge($completeClassInits, $rankClassInits);
        }

        $completeClassEntries = [];
        foreach ($classEntries as $rankClassEntries) {
            asort($rankClassEntries, SORT_STRING);
            $completeClassEntries = array_merge($completeClassEntries, $rankClassEntries);
        }

        /*
         * Round 3. Process extension globals
         */
        list($globalCode, $globalStruct, $globalsDefault, $initEntries) = $this->processExtensionGlobals($project);
        if ('zend' == $project) {
            $safeProject = 'zend_';
        } else {
            $safeProject = $project;
        }

        /**
         * Round 4. Process extension info.
         */
        $phpInfo = $this->processExtensionInfo();

        /*
         * Round 5. Generate Function entries (FE)
         */
        list($feHeader, $feEntries) = $this->generateFunctionInformation();

        /**
         * Check if there are module/request/global destructors.
         */
        $destructors = $this->config->get('destructors');
        if (\is_array($destructors)) {
            $invokeRequestDestructors = $this->processCodeInjection($destructors, 'request');
            $includes .= PHP_EOL.$invokeRequestDestructors[0];
            $reqDestructors = $invokeRequestDestructors[1];

            $invokePostRequestDestructors = $this->processCodeInjection($destructors, 'post-request');
            $includes .= PHP_EOL.$invokePostRequestDestructors[0];
            $prqDestructors = $invokePostRequestDestructors[1];

            $invokeModuleDestructors = $this->processCodeInjection($destructors, 'module');
            $includes .= PHP_EOL.$invokeModuleDestructors[0];
            $modDestructors = $invokeModuleDestructors[1];

            $invokeGlobalsDestructors = $this->processCodeInjection($destructors, 'globals');
            $includes .= PHP_EOL.$invokeGlobalsDestructors[0];
            $glbDestructors = $invokeGlobalsDestructors[1];
        }

        /**
         * Check if there are module/request/global initializers.
         */
        $initializers = $this->config->get('initializers');
        if (\is_array($initializers)) {
            $invokeRequestInitializers = $this->processCodeInjection($initializers, 'request');
            $includes .= PHP_EOL.$invokeRequestInitializers[0];
            $reqInitializers = $invokeRequestInitializers[1];

            $invokeModuleInitializers = $this->processCodeInjection($initializers, 'module');
            $includes .= PHP_EOL.$invokeModuleInitializers[0];
            $modInitializers = $invokeModuleInitializers[1];

            $invokeGlobalsInitializers = $this->processCodeInjection($initializers, 'globals');
            $includes .= PHP_EOL.$invokeGlobalsInitializers[0];
            $glbInitializers = $invokeGlobalsInitializers[1];
        }

        /**
         * Append extra details.
         */
        $extraClasses = $this->config->get('extra-classes');
        if (\is_array($extraClasses)) {
            foreach ($extraClasses as $value) {
                if (isset($value['init'])) {
                    $completeClassInits[] = 'ZEPHIR_INIT('.$value['init'].')';
                }

                if (isset($value['entry'])) {
                    $completeClassEntries[] = 'zend_class_entry *'.$value['entry'].';';
                }
            }
        }

        $toReplace = [
            '%PROJECT_LOWER_SAFE%' => strtolower($safeProject),
            '%PROJECT_LOWER%' => strtolower($project),
            '%PROJECT_UPPER%' => strtoupper($project),
            '%PROJECT_CAMELIZE%' => ucfirst($project),
            '%CLASS_ENTRIES%' => implode(
                PHP_EOL,
                array_merge($completeInterfaceEntries, $completeClassEntries)
            ),
            '%CLASS_INITS%' => implode(
                PHP_EOL."\t",
                array_merge($completeInterfaceInits, $completeClassInits)
            ),
            '%INIT_GLOBALS%' => implode(
                PHP_EOL."\t",
                array_merge((array) $globalsDefault[0], [$glbInitializers])
            ),
            '%INIT_MODULE_GLOBALS%' => $globalsDefault[1],
            '%DESTROY_GLOBALS%' => $glbDestructors,
            '%EXTENSION_INFO%' => $phpInfo,
            '%EXTRA_INCLUDES%' => implode(
                PHP_EOL,
                array_unique(explode(PHP_EOL, $includes))
            ),
            '%MOD_INITIALIZERS%' => $modInitializers,
            '%MOD_DESTRUCTORS%' => $modDestructors,
            '%REQ_INITIALIZERS%' => implode(
                PHP_EOL."\t",
                array_merge($this->internalInitializers, [$reqInitializers])
            ),
            '%REQ_DESTRUCTORS%' => $reqDestructors,
            '%POSTREQ_DESTRUCTORS%' => empty($prqDestructors) ? '' : implode(
                PHP_EOL,
                [
                    '#define ZEPHIR_POST_REQUEST 1',
                    'static PHP_PRSHUTDOWN_FUNCTION('.strtolower($project).')',
                    '{',
                    "\t".implode(
                        PHP_EOL."\t",
                        explode(PHP_EOL, $prqDestructors)
                    ),
                    '}',
                ]
            ),
            '%FE_HEADER%' => $feHeader,
            '%FE_ENTRIES%' => $feEntries,
            '%PROJECT_INI_ENTRIES%' => implode(PHP_EOL."\t", $initEntries),
        ];
        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        /*
         * Round 5. Generate and place the entry point of the project
         */
        file_put_contents_ex($content, 'ext/'.$safeProject.'.c');
        unset($content);

        /**
         * Round 6. Generate the project main header.
         */
        $content = $this->backend->getTemplateFileContents('project.h');
        if (empty($content)) {
            throw new Exception("Template project.h doesn't exists");
        }

        $includeHeaders = [];
        foreach ($this->compiledFiles as $file) {
            if ($file) {
                $fileH = str_replace('.c', '.zep.h', $file);
                $include = '#include "'.$fileH.'"';
                $includeHeaders[] = $include;
            }
        }

        /**
         * Append extra headers.
         */
        $extraClasses = $this->config->get('extra-classes');
        if (\is_array($extraClasses)) {
            foreach ($extraClasses as $value) {
                if (isset($value['header'])) {
                    $include = '#include "'.$value['header'].'"';
                    $includeHeaders[] = $include;
                }
            }
        }

        $toReplace = [
            '%INCLUDE_HEADERS%' => implode(PHP_EOL, $includeHeaders),
        ];

        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        file_put_contents_ex($content, 'ext/'.$safeProject.'.h');
        unset($content);

        /**
         * Round 7. Create php_project.h.
         */
        $content = $this->backend->getTemplateFileContents('php_project.h');
        if (empty($content)) {
            throw new Exception("Template php_project.h doesn't exist");
        }

        $toReplace = [
            '%PROJECT_LOWER_SAFE%' => strtolower($safeProject),
            '%PROJECT_LOWER%' => strtolower($project),
            '%PROJECT_UPPER%' => strtoupper($project),
            '%PROJECT_EXTNAME%' => strtolower($project),
            '%PROJECT_NAME%' => utf8_decode($this->config->get('name')),
            '%PROJECT_AUTHOR%' => utf8_decode($this->config->get('author')),
            '%PROJECT_VERSION%' => utf8_decode($this->config->get('version')),
            '%PROJECT_DESCRIPTION%' => utf8_decode($this->config->get('description')),
            '%PROJECT_ZEPVERSION%' => Zephir::VERSION,
            '%EXTENSION_GLOBALS%' => $globalCode,
            '%EXTENSION_STRUCT_GLOBALS%' => $globalStruct,
        ];

        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        file_put_contents_ex($content, 'ext/php_'.$safeProject.'.h');
        unset($content);

        return $needConfigure;
    }
1002333
protected function handleApiException(ClientException $e, Project $project)
    {
        $response = $e->getResponse();
        if ($response !== null && $response->getStatusCode() === 403) {
            $project->ensureFull();
            $data = $project->getData();
            if (!$project->hasLink('#manage-domains')
                && !empty($data['subscription']['plan'])
                && $data['subscription']['plan'] === 'development') {
                $this->stdErr->writeln('This project is on a Development plan. Upgrade the plan to add domains.');
            }
        } else {
            throw $e;
        }
    }
843267
protected function request($method, $params)
    {
        Log::debug('RpcClient call', ['method'=>$method, 'params'=>$params, 'config'=>$this->config]);

        return call_user_func_array(
                [$this->connection(), 'execute'],
                [$method,$params]
            );
    }
1003521
public function getSubmitParams($params) {

    $submitParams = array();
    foreach ($this->paramFields as $k => $mandatory) {
      if (isset($params[$k]) && strlen($params[$k]) > 0) {
        $submitParams[$k] = $params[$k];
      }
      elseif ((!isset($params[$k]) || strlen($params[$k]) == 0) && $mandatory) {
        throw new \Exception('mandatory field ' . $k . ' is unset or empty');
      }
    }

    return $submitParams;
  }