@param ApiClientInterface $apiClient
@param array              $params

@return FacadeInterface

@throws TransformerParameterTypeException
322046
public function transform($apiClient, array $params = array())
    {
        if (!$apiClient instanceof ApiClientInterface) {
            throw new TransformerParameterTypeException();
        }

        $facade = $this->newFacade();
        $facade->id = $apiClient->getId();
        $facade->name = $apiClient->getName();
        $facade->trusted = $apiClient->isTrusted();
        $facade->key = $apiClient->getKey();
        $facade->secret = $apiClient->getSecret();
        $facade->roles = implode(',', $apiClient->getRoles());

        return $facade;
    }
864256
public function transform($folder, array $params = array())
    {
        if (!$folder instanceof FolderInterface) {
            throw new TransformerParameterTypeException();
        }
        $facade = $this->newFacade();
        $facade->folderId = $folder->getId();
        $facade->name = $this->multiLanguageChoiceManager->choose($folder->getNames());
        $facade->createdAt = $folder->getCreatedAt();
        $facade->updatedAt = $folder->getUpdatedAt();
        if ($folder->getParent() instanceof FolderInterface) {
            $facade->parentId = $folder->getParent()->getId();
        } else {
            $facade->parentId = FolderInterface::ROOT_PARENT_ID;
        }
        $facade->siteId = $folder->getSiteId();

        return $facade;
    }
1035599
public static function all($params = null, $apiKey = null)
    {
        return self::_all(get_class(), $params, $apiKey);
    }
143006
public function transform($block, array $params = array())
    {
        if (!$block instanceof BlockInterface) {
            throw new TransformerParameterTypeException();
        }
        $facade = $this->newFacade();

        $facade->component = $block->getComponent();
        $facade->name = $this->blockConfigurationManager->getBlockComponentName($block->getComponent());
        $facade->label = $block->getLabel();
        $facade->style = $block->getStyle();
        $facade->id = $block->getId();
        $facade->language = $block->getLanguage();
        $facade->transverse = $block->isTransverse();
        $facade->updatedAt = $block->getUpdatedAt();
        $categoryKey = $this->blockConfigurationManager->getBlockCategory($block->getComponent());
        $facade->category = array(
            'label' => $this->translator->trans($categoryKey),
            'key' => $categoryKey
        );

        foreach ($block->getAttributes() as $key => $attribute) {
            if (is_array($attribute)) {
                $attribute = json_encode($attribute);
            }
            $facade->addAttribute($key, $attribute);
        }

        $facade->previewContent = $this->displayBlockManager->show($block);

        if ($this->hasGroup(CMSGroupContext::BLOCKS_NUMBER_USE)) {
            $facade->numberUse = $this->nodeRepository->countBlockUsed($block->getId());
        }

        if ($this->hasGroup(CMSGroupContext::BLOCK_REQUIRED_URI_PARAMETERS)) {
            $facade->requiredUriParameters = $this->generateFormManager->getRequiredUriParameter($block);
        }


        return $facade;
    }
175847
public static function all(array $data = [], ClientInterface $client = null)
    {

        return (new RequestService($client))
            ->setResourceClass(static::class)
            ->all($data);
    }
930100
public IClient newClient(Object[] params) throws ClientNotFoundException, ClientRejectedException {
        // derive client id from the connection params or use next
        String id = nextId();
        IClient client = new Client(id, this);
        addClient(id, client);
        return client;
    }
1353963
public function await(QueueClientInterface $queue, ReceiveParametersInterface $params = null)
    {
        $worker = $this;
        $this->await = true;
        $lastResult = [];

        $callback = function(QueueEvent $event) use($worker, $queue, &$lastResult) {

            $messages = $event->getMessages();

            foreach ($messages as $message) {
                $lastResult = $worker->process($message);

                if ($queue->canDeleteMessage()) {
                    $queue->delete($message);
                }
            }

            if ($worker->isAwaitingStopped()) {
                $event->stopAwait(true);
            }

            return !$worker->isAwaitingStopped();
        };


        $callbackHandler = $queue->getEventManager()->attach(QueueEvent::EVENT_RECEIVE, $callback);

        $queue->await($params);

        $queue->getEventManager()->detach($callbackHandler);


        return $lastResult;
    }
67075
protected function call(array $params)
    {
        $defaultParams = [
            'key'        => $this->apiKey,
            'format'     => 'json',
            'apiVersion' => self::VERSION,
        ];

        $params = array_merge($defaultParams, $params);

        $url = sprintf('%s?%s', self::ENDPOINT, http_build_query($params));

        $response = $this->adapter->get($url);

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

        if ($result['result'] == 'ERR') {
            throw new ApiException($result['message'], $result['code']);
        }

        return $result;
    }
1325226
protected function codeAskResourceOwnerForApproval(
        array $parameters,
        ClientInterface $client,
        string $redirectUri = null,
        int $maxStateLength = null
    ): ResponseInterface {
        $state = $this->codeGetState($parameters);
        if ($maxStateLength !== null && strlen($state) > $maxStateLength) {
            throw new OAuthCodeRedirectException(
                OAuthCodeRedirectException::ERROR_INVALID_REQUEST,
                $redirectUri,
                $state
            );
        }

        if ($client->isCodeGrantEnabled() === false) {
            throw new OAuthCodeRedirectException(
                OAuthCodeRedirectException::ERROR_UNAUTHORIZED_CLIENT,
                $redirectUri,
                $state
            );
        }

        $scope = $this->codeGetScope($parameters);
        list ($isScopeValid, $scopeList, $isScopeModified) =
            $this->codeGetIntegration()->codeValidateScope($client, $scope);
        if ($isScopeValid === false) {
            throw new OAuthCodeRedirectException(
                OAuthCodeRedirectException::ERROR_INVALID_SCOPE,
                $redirectUri,
                $state
            );
        }

        $response = $this->codeGetIntegration()->codeCreateAskResourceOwnerForApprovalResponse(
            $client,
            $redirectUri,
            $isScopeModified,
            $scopeList,
            $state
        );

        return $response;
    }
558543
public function setHttpClient(HttpClient $client)
    {
        $this->httpClient = $client;

        $this->httpClient->setDefaultOption(
            'headers/Authorization',
            $this->getAuthorizationHeader()
        );
        $this->httpClient->setDefaultOption(
            'headers/Accepts',
            'application/json'
        );

        $this->bootModules();
    }
461352
public static function fromUsername($username, ApiClient $apiClient = null)
    {
        if (is_null($apiClient)) {
            $apiClient = static::createApiClient();
        }

        $apiResult = $apiClient->uuidApi($username);

        $json = $apiResult;

        if (isset($json->error)) {
            throw new \RuntimeException('Mojang Error: '.$json->errorMessage);
        }

        if (empty($json) || !isset($json[0]->id)) {
            throw new \RuntimeException('Invalid Username ('.$username.')');
        }
        static::rateLimitBust();

        return static::fromUuid($json[0]->id);
    }
1096041
public function executeAsync(ClientRequestInterface $request, array $headers = null, array $clientOptions = [])
    {
        if ($request instanceof ContextAwareInterface) {
            $request->setContextIfNull($this->getConfig()->getContext());
        }
        $httpRequest = $this->createHttpRequest($request, $headers);
        $client = $this->getHttpClient();
        if ($client instanceof AdapterOptionInterface) {
            $response = $request->buildResponse($client->executeAsync($httpRequest, $clientOptions));
        } else {
            $response = $request->buildResponse($client->executeAsync($httpRequest));
        }

        $response = $response->then(
            function ($httpResponse) use ($httpRequest) {
                $this->logDeprecatedRequest($httpResponse, $httpRequest);
                return $httpResponse;
            }
        );

        return $response;
    }
32851
public static function create(ApiContext $apiContext): BunqResponseSessionServer
    {
        $apiClient = new ApiClient($apiContext);
        $responseRaw = $apiClient->post(
            self::ENDPOINT_URL_POST,
            [self::FIELD_SECRET => $apiContext->getApiKey()],
            []
        );

        return BunqResponseSessionServer::castFromBunqResponse(
            static::classFromJson($responseRaw)
        );
    }
1110510
public static function create($baseUrl, self $apiClient = null)
    {
        return $apiClient === null ? new self(new Client(), $baseUrl) : $apiClient;
    }
34633
public function request($api, $params = array(), $entity = false)
    {
        $api = ServiceFactory::get($api);

        $url = $api->getEndPoint();

        if ((count($params) > 0) && ($api->getRequiredParam())) {
            foreach ($params as $item) {
                $url.= '/' . filter_var($item, FILTER_SANITIZE_URL);
            }
        }

        $body = array();
        if ($entity) {
            $body = [
                'body' => $entity->toJSON()
            ];
        }

        try {
            $response = $this->client->request(
                $api->getMethod(),
                $url,
                $body
            );

        } catch (\Exception $e) {
            $response = $e->getResponse();
        }

        return $response->getBody()->getContents();
    }
343616
public function findOneByClientAndRefreshToken(ApiClientInterface $client, $refreshToken)
    {
        $qb = $this->createQueryBuilder();

        $qb->field('client.id')->equals($client->getId());
        $qb->field('refreshCode')->equals($refreshToken);
        $qb->limit(1);

        return $qb->getQuery()->getSingleResult();
    }
239982
public function transform($user, array $params = array())
    {
        if (!$user instanceof UserInterface) {
            throw new TransformerParameterTypeException();
        }

        $facade = $this->newFacade();

        $facade->id = $user->getId();
        $facade->username = $user->getUsername();
        $facade->email = $user->getEmail();
        $facade->roles = implode(',', $user->getRoles());

        $groups = $user->getGroups();
        $labels = array();
        foreach($groups as $group){
            if (!$group->isDeleted()) {
                $labels[] = $this->multiLanguagesChoiceManager->choose($group->getLabels());
            }
        }

        $facade->groups = implode(',', $labels);

        if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS)) {
            $canDelete = $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $user);
            $facade->addRight('can_delete', $canDelete);
        }

        return $facade;
    }