Perform Dropbox API request.

@throws \Exception

@return \Psr\Http\Message\ResponseInterface
436859
protected function doDropboxApiRequest()
    {
        $request = empty($this->request) ? [] : ['json' => $this->request];

        try {
            $response = $this->client->post("{$this->apiUrl}{$this->apiEndpoint}", $request);
        } catch (HttpClientException $exception) {
            throw $this->determineException($exception);
        }

        return json_decode($response->getBody(), true);
    }
1067267
public function getTicketResponse()
    {
        $response = Http::request('GET', static::JSAPI_TICKET)
            ->withAccessToken($this->accessToken)
            ->withQuery(['type' => 'jsapi'])
            ->send();

        if (0 != $response['errcode']) {
            throw new \Exception($response['errmsg'], $response['errcode']);
        }

        return $response;
    }
686520
public function create(): Response
    {
        $request = $this->request->getPost();

        if (empty($request)) {
            $request = $this->request->getJsonRawBody(true);
        }

        //try to save all the fields we allow
        if ($this->model->save($request, $this->createFields)) {
            return $this->response($this->model->toArray());
        } else {
            //if not thorw exception
            throw new Exception($this->model->getMessages()[0]);
        }
    }
1059025
public final function getResponse(): ResponseInterface
   {
       if (!$this->response) {
           try {
               $this->send();
           } catch (RuntimeException $e) {
               throw new RuntimeException(
                   "Can't get response: " . $e->getMessage());
           }
       }
       return $this->response;
   }
1209579
public function send(): HttpResponse {
        $ch = $this->createCurl();
        $response = $this->execCurl($ch);
        curl_close($ch);

        return $response;
    }
528748
public function create() 
    {
        try {            
            $fileData['alias'] = Input::get('filename') ? Input::get('filename') : date('m.d.Y - G:i:s');
            $fileData['type'] = 'folder';
            if(Input::get('pid') > 0) {
                $fileData['parent_id'] = Input::get('pid');
            }
            
            $this->file->create($fileData);

            return response()->json([
                'status' => 'success'
            ]);
        }
        
        catch (Exception $e) {
            return $this->handleError($e);
        }
    }
758550
public function run(): Response
    {
        try {
            $response = $this->dispatch();
            $this->send($response);
        } catch (\Error $e) {
            $response = $this->exceptionHandler->handleError($e);
            $this->send($response);
        } catch (\Exception $e) {
            $response = $this->exceptionHandler->handleException($e);
            $this->send($response);
        }

        return $response;
    }
220356
protected function setupDropboxHeaders()
    {
        $headers = [
            'Dropbox-API-Arg' => json_encode(
                $this->request
            ),
        ];
        if (!empty($this->content) ||
               $this->apiEndpoint == 'files/upload_session/finish') {
            // The upload_session/finish API requires a Content-Type, always
            $headers['Content-Type'] = 'application/octet-stream';
        }

        return $headers;
    }
844508
public function handler(): Response
    {
        $response = [];
        foreach (Bulletin::all() as $bulletin) {
            $response[] = [
                'id' => $bulletin->getId(),
                'createdAt' => $bulletin->getCreatedAt()->getTimestamp(),
                'title' => $bulletin->getTitle(),
                'abstract' => $bulletin->getAbstract(),
                'isDraft' => $bulletin->isDraft(),
                'statistics' => $bulletin->getStatistics()
            ];
        }
        return response($response);
    }
249965
public function accessToken(){
		$url = 'https://api.dropbox.com/1/oauth/access_token';
		$result = $this->doOAuthCall($url,'POST');
		parse_str($result['body'], $output);
		if (!count(array_diff(array('oauth_token','oauth_token_secret','uid'),
			array_keys($output))))
		{
			$this->setAuthToken($output['oauth_token'], $output['oauth_token_secret']);
			return $output;
		} else {
			$result = json_decode($result['body'], true);
			trigger_error(sprintf(self::E_AUTHERROR, $result['error']));
			return false;
		}
	}
812574
public function index()
    {
        try {            
            $files = $this->file->get(Input::get('pid'));
            
            return response()->json([
                'status' => 'success',
                'data' => $files,
            ]);
        }
        
        catch (Exception $e) {
            return $this->handleError($e);
        }
    }
758450
public function indexAction()
    {
        $response = $this->getResponse();

        $params = $this->params()->fromRoute();
        if ($params['path'] === '') {
            $response->setStatusCode(404);
            return $response;
        }

        $info = pathinfo($params['path']);

        if ($info['dirname'] === '.') {
            $info['dirname'] = '';
        }

        /* @var $folder \CmsFile\Mapping\FolderInterface */
        $folder  = $this->getFolderService()->getMapper()->findOneByPath('/' . trim($info['dirname'], '/'));
        if (!$folder) {
            $response->setStatusCode(404);
            return $response;
        }

        $file = $folder->getFile($info['basename']);
        if (!$file) {
            $response->setStatusCode(404);
            return $response;
        }

        $response = new Stream;
        $response->setStream(fopen($file, 'r'));
        $response->setStatusCode(200);

        $headers = new Headers;
        $headers->addHeaderLine('Content-Type', $file->getType())
            ->addHeaderLine('Content-Disposition', 'attachment; filename="' . $file->getTitle() . '"')
            ->addHeaderLine('Content-Length', filesize($file));

        $response->setHeaders($headers);

        return $response;
    }
457099
public function handler(): Response
    {
        $bulletin = Bulletin::find($this->getParameter('id'));
        if (!$bulletin) {
            throw new HttpNotFoundException();
        }
        return response([
            'id' => $bulletin->getId(),
            'createdAt' => $bulletin->getCreatedAt()->getTimestamp(),
            'updatedAt' => ($bulletin->getUpdatedAt() ?? $bulletin->getCreatedAt())->getTimestamp(),
            'title' => $bulletin->getTitle(),
            'content' => $bulletin->getContent(),
            'isDraft' => $bulletin->isDraft(),
            'receivers' => $bulletin->getReceivers(),
            'statistics' => $bulletin->getStatistics()
        ]);
    }
990897
public function getResponse():ResponseInterface
    {
        if (!$this->response) {
            $this->response = (new Client())->request('GET', $this->remoteUrl);
        }
        return $this->response;
    }
760725
protected function send()
    {
        $response = $this->httpClient->send($this->request);

        return $this->response = new MoipResponse($response, $this->resource);
    }
353820
public function request()
    {
        $reqUrl = sprintf('%s?APIKEY=%s', self::END_POINT_URL, rawurlencode($this->apikey));
        $reqBody = json_encode($this->getParameter()->makeParameter());

        $curl = new Curl();
        $curl->setHeader('Content-Type', 'application/json; charset=UTF-8');
        $ret = $curl->post($reqUrl, $reqBody);
        if ($curl->error) {
            trigger_error('docomo dialogue: Error ' . $curl->errorCode . ': ' . $curl->errorMessage, E_USER_WARNING);
            return false;
        }
        return new Response($ret);
    }
270113
public function dropsDownloadAction(Request $request)
    {
        $drops = $this->decodeIdsString($request, Drop::class);
        $dropzone = $drops[0]->getDropzone();
        $this->checkPermission('EDIT', $dropzone->getResourceNode(), [], true);
        $fileName = $dropzone->getResourceNode()->getName();

        $archive = $this->manager->generateArchiveForDrops($drops);

        $response = new StreamedResponse();
        $response->setCallBack(
            function () use ($archive) {
                readfile($archive);
            }
        );
        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename='.urlencode($fileName.'.zip'));
        $response->headers->set('Content-Type', 'application/zip; charset=utf-8');
        $response->headers->set('Connection', 'close');

        return $response->send();
    }