Makes the request to API and returns the result.

@param DmmRequest $request

@return DmmResponse

@throws DmmSDKException
501688
public function sendRequest(DmmRequest $request)
    {
        if (get_class($request) === 'Dmm\DmmRequest') {
            $request->validateCredentials();
        }

        list($url, $method, $headers, $body) = $this->prepareRequestMessage($request);

        // Since file uploads can take a while, we need to give more time for uploads
        $timeOut = static::DEFAULT_REQUEST_TIMEOUT;

        // Should throw `DmmSDKException` exception on HTTP client error.
        // Don't catch to allow it to bubble up.
        $rawResponse = $this->httpClientHandler->send($url, $method, $body, $headers, $timeOut);

        static::$requestCount++;

        $returnResponse = new DmmResponse(
            $request,
            $rawResponse->getBody(),
            $rawResponse->getHttpResponseCode(),
            $rawResponse->getHeaders()
        );

        if ($returnResponse->isError()) {
            throw $returnResponse->getThrownException();
        }

        return $returnResponse;
    }
666576
public function cgetAction(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);
        $fieldDescriptors = $this->getFieldDescriptors($locale, false);
        $types = array_filter(explode(',', $request->get('types')));
        $listBuilder = $this->getListBuilder($request, $fieldDescriptors, $types);
        $listBuilder->setParameter('locale', $locale);
        $listResponse = $listBuilder->execute();
        $count = $listBuilder->count();

        for ($i = 0, $length = count($listResponse); $i < $length; ++$i) {
            $format = $this->getFormatManager()->getFormats(
                $listResponse[$i]['id'],
                $listResponse[$i]['name'],
                $listResponse[$i]['storageOptions'],
                $listResponse[$i]['version'],
                $listResponse[$i]['subVersion'],
                $listResponse[$i]['mimeType']
            );

            if (0 < count($format)) {
                $listResponse[$i]['thumbnails'] = $format;
            }

            $listResponse[$i]['url'] = $this->getMediaManager()->getUrl(
                $listResponse[$i]['id'],
                $listResponse[$i]['name'],
                $listResponse[$i]['version']
            );
        }

        $ids = $listBuilder->getIds();
        if (null != $ids) {
            $result = [];
            foreach ($listResponse as $item) {
                $result[array_search($item['id'], $ids)] = $item;
            }
            ksort($result);
            $listResponse = array_values($result);
        }

        $list = new ListRepresentation(
            $listResponse,
            self::$entityKey,
            'cget_media',
            $request->query->all(),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $count
        );

        $view = $this->view($list, 200);

        return $this->handleView($view);
    }
66680
public function postRequestAsync( Request $request ) {
		$promise = $this->getClient()->requestAsync(
			'POST',
			$this->apiUrl,
			$this->getClientRequestOptions( $request, $this->getPostRequestEncoding( $request ) )
		);

		return $promise->then( function ( ResponseInterface $response ) {
			return call_user_func( [ $this, 'decodeResponse' ], $response );
		} );
	}
178305
protected function doRequest($request)
    {
        if (!$this->firstRequest) {
            $this->initialize($request);
        }
        $this->firstRequest = false;

        $this->applyBindings();
        $this->applyContextualBindings();
        $this->applyInstances();
        $this->applyApplicationHandlers();

        $request = Request::createFromBase($request);
        $response = $this->kernel->handle($request);
        $this->app->make('Illuminate\Contracts\Http\Kernel')->terminate($request, $response);

        return $response;
    }
349853
public function send(Request $request)
    {
        $response   = new GetIndexResponse();
        $rpbGetReq  = $this->createRpbMessage($request);
        $rpbGetResp = $this->client->send($rpbGetReq, RiakMessageCodes::YOKOZUNA_INDEX_GET_REQ, RiakMessageCodes::YOKOZUNA_INDEX_GET_RESP);

        if ( ! $rpbGetResp instanceof RpbYokozunaIndexGetResp) {
            return $response;
        }

        if ( ! $rpbGetResp->hasIndex()) {
            return $response;
        }

        $rpbIndex = is_array($rpbGetResp->index)
            ? reset($rpbGetResp->index)
            : $rpbGetResp->index;

        $response->nVal   = $rpbIndex->n_val;
        $response->name   = $rpbIndex->name;
        $response->schema = $rpbIndex->schema;

        return $response;
    }
882230
public function httpPost(Request $request) : Response
    {
        $response = new Response();
        $response->headers->set('Content-Type', 'application/json');

        $response->setContent(
            $this->sdkEndpoint->index(
                $request->getContent()
            )
        );

        return $response;
    }
1025325
private function createRpbMessage(GetIndexRequest $request)
    {
        $rpbGetReq = new RpbYokozunaIndexGetReq();

        $rpbGetReq->setName($request->name);

        return $rpbGetReq;
    }
1369548
public function sendRequest(Request $request)
    {

        $result = $this->responseFactory->create();
        $client = $this->httpClientFactory->create();

        $apiData = $request->getApiData();
        $apiUrl = $request->getApiUrl();
        $apiKey = $request->getApiKey();
        $requestMethod = $request->getRequestMethod();

        $requestData = $requestMethod !== "GET" ? json_encode($apiData, JSON_UNESCAPED_SLASHES) : null;

        $client->setUri($apiUrl);

        $client->setConfig(['maxredirects' => 0, 'timeout' => 30]);

        $headers =  [
            'User-Agent'            => 'BoltPay/Magento-'.$this->configHelper->getStoreVersion() . '/' . $this->configHelper->getModuleVersion(),
            'X-Bolt-Plugin-Version' => $this->configHelper->getModuleVersion(),
            'Content-Type'          => 'application/json',
            'Content-Length'        => $requestData ? strlen($requestData) : null,
            'X-Api-Key'             => $apiKey,
            'X-Nonce'               => rand(100000000000, 999999999999)
        ] + (array)$request->getHeaders();

        $request->setHeaders($headers);

        $this->bugsnag->registerCallback(function ($report) use ($request) {
            $report->setMetaData([
                'BOLT API REQUEST' => $request->getData()
            ]);
        });

        $client->setHeaders($headers);

        $responseBody = null;

        try {
            $response     = $client->setRawData($requestData, 'application/json')->request($requestMethod);
            $responseBody = $response->getBody();

            $this->bugsnag->registerCallback(function ($report) use ($response) {
                $report->setMetaData([
                    'BOLT API RESPONSE' => [
                        'headers' => $response->getHeaders(),
                        'body'    => $response->getBody(),
                    ]
                ]);
            });

            $this->bugsnag->registerCallback(function ($report) use ($response) {
                $headers = $response->getHeaders();
                $report->setMetaData([
                    'META DATA' => [
                        'bolt_trace_id' => @$headers[ConfigHelper::BOLT_TRACE_ID_HEADER],
                    ]
                ]);
            });
        } catch (\Exception $e) {
            throw new LocalizedException($this->wrapGatewayError($e->getMessage()));
        }

        if ($request->getStatusOnly() && $response) {
            return $response->getStatus();
        }

        if ($responseBody) {
            $resultFromJSON = json_decode($responseBody);
            $jsonError  = $this->handleJsonParseError();
            if ($jsonError != null) {
                $message = __("JSON Parse Error: " . $jsonError);
                throw new LocalizedException($message);
            }

            if ($this->isResponseError($resultFromJSON)) {
                $message = isset($resultFromJSON->errors[0]->message) ? __($resultFromJSON->errors[0]->message) :  __("Bolt API Error Response");
                throw new LocalizedException($message);
            }

            $result->setResponse($resultFromJSON);
        } else {
            throw new LocalizedException(
                __('Something went wrong in the payment gateway.')
            );
        }
        return $result;
    }
347723
public function allAction(Request $request)
    {
        $model = $this->getModel();

        $content = $this->restUtils->serialize($model->findAll($request));

        $response = $this->getResponse()
            ->setStatusCode(Response::HTTP_OK)
            ->setContent($content);

        return $response;
    }
1324128
protected function doRequest($request)
    {
        $slimRequest = $this->convertRequest($request);

        $container = $this->app->getContainer();

        /* @var $slimResponse ResponseInterface */
        $slimResponse = $container->get('response');

        // reset body stream
        $slimResponse = $slimResponse->withBody(new Stream(fopen('php://temp', 'w+')));

        $slimResponse = $this->app->process($slimRequest, $slimResponse);

        return new BrowserKitResponse(
            (string) $slimResponse->getBody(),
            $slimResponse->getStatusCode(),
            $slimResponse->getHeaders()
        );
    }
429496
public function send(Request $request)
    {
        $response   = new PutSchemaResponse();
        $rpbPutReq  = $this->createRpbMessage($request);

        $this->client->send($rpbPutReq, RiakMessageCodes::YOKOZUNA_SCHEMA_PUT_REQ, RiakMessageCodes::PUT_RESP);

        return $response;
    }
231355
protected function doSendRequest(Request $request): Response
    {
        if (!$this->shouldUseGearman()) {
            return $this->locator->getRequestBus()->receiveRequest($request);
        }

        $envelope = new TransportEnvelope($request, 'php');
        $channel = $this->router->forRequest($request);

        try {
            $client = $this->getClient();
            $result = @$client->doNormal($channel, $envelope->toString(), (string)$request->get('request_id'));
            $this->validateReturnCode($client, $channel);
            return TransportEnvelope::fromString($result)->getMessage();
        } catch (\GearmanException $ge) {
            if (isset(self::$reconnectCodes[$ge->getCode()])) {
                $this->destroyClient();
                return $this->locator->getRequestBus()->receiveRequest($request);
            }

            throw $ge;
        } catch (\Throwable $e) {
            throw $e;
        }
    }
782269
public function send(Request $request)
    {
        $response   = new PutResponse();
        $rpbPutReq  = $this->createRpbMessage($request);
        $rpbPutResp = $this->client->send($rpbPutReq, RiakMessageCodes::DT_UPDATE_REQ, RiakMessageCodes::DT_UPDATE_RESP);

        if ( ! $rpbPutResp instanceof DtUpdateResp) {
            return $response;
        }

        if ($rpbPutResp->hasContext()) {
            $response->context = $rpbPutResp->context;
        }

        if ($rpbPutResp->hasCounterValue()) {
            $response->value = $rpbPutResp->counter_value;
            $response->type  = 'counter';
        }

        if ($rpbPutResp->hasSetValue()) {
            $response->value = $rpbPutResp->set_value;
            $response->type  = 'set';
        }

        if ($rpbPutResp->hasMapValue()) {
            $response->value = $this->opConverter->fromProtoBuf($rpbPutResp->map_value);
            $response->type  = 'map';
        }

        return $response;
    }
693075
private function createRpbMessage(PutRequest $request)
    {
        $rpbPutReq = new DtUpdateReq();
        $crdtOp    = $this->opConverter->toProtoBuf($request->op);

        $rpbPutReq->setBucket($request->bucket);
        $rpbPutReq->setType($request->type);
        $rpbPutReq->setKey($request->key);

        if ($request->w !== null) {
            $rpbPutReq->setW($this->encodeQuorum($request->w));
        }

        if ($request->dw !== null) {
            $rpbPutReq->setDw($this->encodeQuorum($request->dw));
        }

        if ($request->pw !== null) {
            $rpbPutReq->setPw($this->encodeQuorum($request->pw));
        }

        if ($request->returnBody !== null) {
            $rpbPutReq->setReturnBody($request->returnBody);
        }

        if ($request->includeContext !== null) {
            $rpbPutReq->setIncludeContext($request->includeContext);
        }

        if ($request->context !== null) {
            $rpbPutReq->setContext($request->context);
        }

        $rpbPutReq->setOp($crdtOp);

        return $rpbPutReq;
    }
905262
public function send(Request $request)
    {
        $response   = new PutResponse();
        $rpbPutReq  = $this->createRpbMessage($request);
        $rpbPutResp = $this->client->send($rpbPutReq, RiakMessageCodes::PUT_REQ, RiakMessageCodes::PUT_RESP);

        if ( ! $rpbPutResp instanceof RpbPutResp) {
            return $response;
        }

        if ( ! $rpbPutResp->hasContent()) {
            return $response;
        }

        if ($rpbPutResp->hasKey()) {
            $response->key = $rpbPutResp->key;
        }

        $response->vClock      = $rpbPutResp->getVclock()->get();
        $response->contentList = $this->createContentList($rpbPutResp->getContentList());

        return $response;
    }
464439
public function send(Request $request)
    {
        $response     = new PutSchemaResponse();
        $httpRequest  = $this->createHttpRequest($request);

        $this->client->send($httpRequest);

        return $response;
    }
845515
public function send(Request $request)
    {
        $rpbGetReq  = $this->createRpbMessage($request);
        $rpbGetResp = $this->client->send($rpbGetReq, RiakMessageCodes::GET_BUCKET_REQ, RiakMessageCodes::GET_BUCKET_RESP);
        $rpbProps   = $rpbGetResp->getProps();
        $response   = $this->createGetResponse($rpbProps);

        $response->name = $request->bucket;

        return $this->createGetResponse($rpbProps);
    }