Send a request to Moip API

@return \Softpampa\Moip\MoipResponse
760725
protected function send()
    {
        $response = $this->httpClient->send($this->request);

        return $this->response = new MoipResponse($response, $this->resource);
    }
1303646
public function send() {
		
		$url = $this->url();

		// Set fields for post or put requests.
		$this->curl = curl_init();
		curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $this->method);
		if (in_array($this->method, ['POST', 'PUT'])) {
			$this->buildBody();
		} else {
			$this->header('Content-Type', null);
		}
		curl_setopt($this->curl, CURLOPT_URL, $url);
		curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);

		// Capture rate limit response headers.
		$rate_limit = [];
		curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$rate_limit) {
			$parts = explode(':', trim($header), 2);
			if (isset($parts[1]) && preg_match('/^X-RateLimit-(.*)/', $parts[0], $match)) {
				$rate_limit[$match[1]] = (int) $parts[1];
			}
			return strlen($header);
		});

		// Set authorization.
		$access_token = $this->client->accessToken();
		if ($access_token === null) {
			$this->setBearerToken($this->client->id());
		} else {
			$this->setBearerToken($access_token);
		}

		// Add headers.
		$headers = [];
		foreach ($this->headers as $name => $value) {
			if ($value !== null) {
				$headers[] = $name . ': ' . $value;
			}
			curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
		}

		// Allow the client to access the request before it is sent.
		$before = $this->client->before();
		if (is_callable($before)) {
			$before($this);
		}

		// Get response,
		$body = @curl_exec($this->curl);

		// Allow the client to access the request after it is sent.
		$after = $this->client->after();
		if (is_callable($after)) {
			$after($this);
		}

		// Get status and error info before closing the handle.
		$http_status = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
		$error_code = curl_errno($this->curl);
		$error_message = curl_error($this->curl);
		@curl_close($this->curl);

		// Check for curl error.
		if ($error_code > 0) {
			throw new NetworkException($error_message, $error_code);
		}

		return new Response($body, $http_status, $rate_limit);
	}
13709
protected function send()
    {
        try {
            $options = $this->getOptions();

            $message = sprintf(
                'Service: %2$s' . PHP_EOL .
                'Host: %3$s' . PHP_EOL .
                'State: %5$s' . PHP_EOL .
                'Message: %7$s',
                $options['type'],
                $options['service'],
                $options['host'],
                $options['address'],
                $options['state'],
                $options['time'],
                $options['output']
            );

            $priority = $this->determinePriority($options['state']);

            // verify API key
            $this->nmaClient->verify();

            // send notification
            $this->nmaClient->notify(
                self::SENDER,
                $options['type'],
                $message,
                $priority,
                'anag://open?updateonreceive=true'
            );

            $this->setMessage('Message was sent');
            $this->setCode(self::STATE_OK);
        } catch (Exception $e) {
            $this->setMessage(
                'Message could not be sent. Error from NMA client: ' .
                $e->getMessage()
            );
            $this->setCode(self::STATE_CRITICAL);
        }

        return $this;
    }
33584
public function send()
    {
        deprecationWarning('Response::send() will be removed in 4.0.0');

        if ($this->hasHeader('Location') && $this->_status === 200) {
            $this->statusCode(302);
        }

        $this->_setContent();
        $this->sendHeaders();

        if ($this->_file) {
            $this->_sendFile($this->_file, $this->_fileRange);
            $this->_file = null;
            $this->_fileRange = [];
        } else {
            $this->_sendContent($this->body());
        }

        if (function_exists('fastcgi_finish_request')) {
            fastcgi_finish_request();
        }
    }
1054455
protected function sendRequest()
    {
        try {
            $this->response = $this->client->send($this->request);
        } catch (RequestException $e) {
            $this->response = $e->getResponse();

            if (null === $this->response) {
                if ($this->throwsRequestException) {
                    throw $e;
                }
            }

            if ($this->throwsRequestException) {
                throw new \Exception((string)$this->response->getBody());
            }
        }
    }
1168474
public function send()
	{
		if (empty($this->getFrom())) {
			throw new \Exception('Missing "from" parameter, set the value using "setFrom($from)"');
		}
		if (empty($this->getTo())) {
			throw new \Exception('Missing "to" parameter, set the value using "setTo($to)"');
		}
		if (empty($this->getMessage())) {
			throw new \Exception('Missing "message" parameter, set the value using "setMessage($message)"');
		}
		$client = new Services_Twilio($this->getAccountSid(), $this->getAuthToken());
		try {
		    $message = $client->account->messages->create(array('From' => $this->getFrom(), 'To' => $this->getTo(), 'Body' => $this->getMessage()));
		} catch (Services_Twilio_RestException $e) {
		    return false;
		}
		return $message;
	}
44560
private function makeHttpRequest()
    {
        try {
            return $this->client->post($this->apiUrl, [
                'json'    => $this->post->toArray(),
                'headers' => $this->setHeaders(),
            ])->getBody();
        } catch (\GuzzleHttp\Exception\ClientException $e) {
            throw new \Exception(collect($e->getTrace())->implode('\n'));
        } catch (\GuzzleHttp\Exception\ServerException $e) {
            throw new \Exception(collect($e->getTrace())->implode('\n'));
        } catch (\GuzzleHttp\Exception\BadResponseException $e) {
            throw new \Exception(collect($e->getTrace())->implode('\n'));
        }
    }
599670
public function sendHeaders()
     {
         $response = $this->getResponse();
         $headers = $response->getHeaders();
         $isAjax = $response->getRequest()->isAjax();

         if (isset($headers['Location']) && $response->isSuccess() && !$isAjax) {
             $response->setStatus(AnHttpResponse::SEE_OTHER);
         }

         return parent::sendHeaders();
     }
1196758
public function send(): ResponseInterface
    {
        $client = new HttpClient(['base_uri' => $this->url]);

        return $client->get(
            $this->getUrlPath(),
            [
                'query' => $this->getParams(),
            ]
        );
    }
930431
protected function prepareRequest()
    {
        $request = Request::capture();
        $request->setSession($this->app['session']);
        //$request->enableHttpMethodParameterOverride();

        $this->app->singleton('Nano7\Http\Request');
        $this->app->alias('request', 'Nano7\Http\Request');
        $this->app->instance('request', $request);

        return $request;
    }
1090593
public function getRequest()
    {
        $request = parent::getRequest();

        // Force set the 'package' in the request
        $request->query->package = $this->getIdentifier()->package;

        return $request;
    }
135873
public function capture()
    {
        $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::PATH, $this->getId(), 'capture');
        if ($this->isMultipayment($this->getId())) {
            $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::MULTI_PAYMENTS_PATH, $this->getId(), 'capture');
        }

        $response = $this->httpRequest($path, Requests::POST, $this);

        return $this->populate($response);
    }
954105
function sendHeaders()
    {
        if ($this->isHeadersSent())
            throw new \Exception('Headers was sent.');

        $response = $this->getMessageObject();

        // Step 1: Send the "status line".
        $statusLine = sprintf('HTTP/%s %s %s'
            , $response->getProtocolVersion()
            , $response->getStatusCode()
            , $response->getReasonPhrase()
        );
        header($statusLine, true); /* The header replaces a previous similar header. */


        // Step 2: Send the response headers from the headers list.
        foreach ($response->getHeaders() as $name => $values) {
            $responseHeader = sprintf('%s: %s'
                , $name
                , $response->getHeaderLine($name)
            );
            header($responseHeader, false); /* The header doesn't replace a previous similar header. */
        }

        $this->isHeadersSent = true;
        return $this;
    }
1172434
protected function getRequest()
    {
        $url = $this->buildUrl($this->getBody());

        $response = $this->client->get($url, [
            'auth'    => $this->getAuth(),
            'headers' => [
                'Accept' => 'application/json',
            ],
        ]);

        if ($response->getStatusCode() != 201 && $response->getStatusCode() != 200) {
            throw new \Exception('Unable to request from API.');
        }

        return $response;
    }
1033347
public function send()
    {
        // gzip支持
        if($this->gzipStatus)
        {
            $this->swooleResponse->gzip($this->gzipLevel);
        }
        $this->sendHeaders();
        $this->swooleResponse->end($this->getBody());
        $this->isEnded = true;
        return $this;
    }
822027
private function _setRequestAndResponse()
    {
        if (!is_object($this->_request)) {
            $this->_request = \Mmi\App\FrontController::getInstance()->getRequest();
        }
        if (!is_object($this->_response)) {
            $this->_response = \Mmi\App\FrontController::getInstance()->getResponse();
        }
        return $this;
    }
607224
protected function sendHeaders() {
        $context = Context::getInstance();
        $context->getResponse()->setContentHeader($this->contentType);
        header(HTTPToolkit::statusCodeHeader($this->httpCode));
        return $this;
    }