Send Data to APM Service

@link https://github.com/philkra/elastic-apm-laravel/issues/22
@link https://github.com/philkra/elastic-apm-laravel/issues/26

@return bool
430927
public function send() : bool
    {
        // Is the Agent enabled ?
        if ($this->config->get('active') === false) {
            return true;
        }

        $connector = new Connector($this->config);
        $status = true;

        // Commit the Errors
        if ($this->errorsStore->isEmpty() === false) {
            $status = $status && $connector->sendErrors($this->errorsStore);
            if ($status === true) {
                $this->errorsStore->reset();
            }
        }

        // Commit the Transactions
        if ($this->transactionsStore->isEmpty() === false) {
            $status = $status && $connector->sendTransactions($this->transactionsStore);
            if ($status === true) {
                $this->transactionsStore->reset();
            }
        }

        return $status;
    }
1282932
public function send()
    {
        $arguments = func_get_args();
        $method    = array_shift($arguments);
        $args      = array_shift($arguments);

        $helpers = $this->getConfig()->getHelpers();

        return call_user_func_array(array($helpers, $method), $args);
    }
52212
protected function sendPayRequest()
    {
        $this->newTransaction();

        $username = $this->config->get('gateway.asanpardakht.username');
        $password = $this->config->get('gateway.asanpardakht.password');
        $orderId = $this->transactionId();
        $price = $this->amount;
        $localDate = date("Ymd His");
        $additionalData = "";
        $callBackUrl = $this->getCallback();
        $req = "1,{$username},{$password},{$orderId},{$price},{$localDate},{$additionalData},{$callBackUrl},0";

        $encryptedRequest = $this->encrypt($req);
        $params = array(
            'merchantConfigurationID' => $this->config->get('gateway.asanpardakht.merchantConfigId'),
            'encryptedRequest' => $encryptedRequest
        );

        try {
            $soap = new SoapClient($this->serverUrl);
            $response = $soap->RequestOperation($params);

        } catch (\SoapFault $e) {
            $this->transactionFailed();
            $this->newLog('SoapFault', $e->getMessage());
            throw $e;
        }


        $response = $response->RequestOperationResult;
        $responseCode = explode(",", $response)[0];
        if ($responseCode != '0') {
            $this->transactionFailed();
            $this->newLog($response, AsanpardakhtException::getMessageByCode($response));
            throw new AsanpardakhtException($response);
        }
        $this->refId = substr($response, 2);
        $this->transactionSetRefId();
    }
236453
public function sendRequest()
    {
        if ($this->getError()->hasError() && !$this->inProgress) {
            return;
        }

        if (class_exists($this->dispatcher)) {
            $dispatcherClass = $this->dispatcher;
            $dispatcher = new $dispatcherClass($this->instance->getQuery());
            if ($dispatcher instanceof AbstractDispatcher) {
                $this->inProgress = true;
                try {
                    $client = new \Zend\XmlRpc\Client($this->getUrl());

                    $config = $this->config->getRawConfig();
                    $sql = $this->instance->getQuery()->toString();
                    $limit = $this->instance->getQuery()->getLimit();
                    $offset = $this->instance->getQuery()->getOffset();

                    $di = $client->getProxy('DBInstance');
                    if ($this->method == 'getAvailableDrivers') {
                        $this->availableDrivers = $di->getAvailableDrivers();
                    } elseif ($this->method == 'getServerVersion') {
                        $res = $di->getServerVersion();
                        $this->serverVersion = isset($res['version']) ? $res['version'] : null;
                    } else {
                        $response = $di->getResult(
                            $config,
                            $sql,
                            $limit,
                            $offset,
                            $this->instance->getQuery()->isSingle(),
                            $this->getKey(),
                            'array'
                        );
                        $dispatcher->dispatch($response);
                    }

                    $this->inProgress = false;
                } catch (\Zend\XmlRpc\Client\Exception\HttpException $e) {
                    $this->getError()->setMessage($e->getMessage());
                    $this->inProgress = false;
                } catch (\Zend\XmlRpc\Client\Exception\FaultException $e) {
                    $this->getError()->setMessage($e->getMessage());
                    $this->inProgress = false;
                } catch (\Exception $e) {
                    $this->getError()->setMessage('Error server response');
                    $this->inProgress = false;
                }
            } else {
                $this->getError()->setMessage(sprintf(
                    'Dispatcher class must be instance of %s, %s given',
                    AbstractDispatcher::class,
                    (string) $this->dispatcher
                ));
            }
        } else {
            $this->getError()->setMessage(sprintf('Class %s not found', (string) $this->dispatcher));
        }
    }
561407
protected function send()
    {
        $userAgent = 'mpay24-php/' . self::VERSION;

        $ch = curl_init($this->getEtpURL());
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_USERPWD,
            'u' . $this->config->getMerchantId() . ':' . $this->config->getSoapPassword());
        curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        if ($this->config->isEnableCurlLog()) {
            $fh = fopen($this->getMpay24CurlLogPath(), 'a+') or $this->permissionError();

            curl_setopt($ch, CURLOPT_VERBOSE, 1);
            curl_setopt($ch, CURLOPT_STDERR, $fh);
        }

        try {
            curl_setopt($ch, CURLOPT_CAINFO, $this->config->getCaCertPath() . $this->config->getCaCertFileName());

            if ($this->config->getProxyHost()) {
                curl_setopt($ch, CURLOPT_PROXY, $this->config->getProxyHost() . ':' . $this->config->getProxyPort());

                if ($this->config->getProxyUser()) {
                    curl_setopt($ch, CURLOPT_PROXYUSERPWD,
                        $this->config->getProxyUser() . ':' . $this->config->getProxyPass());
                }

                if ($this->config->isVerifyPeer() !== true) {
                    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->config->isVerifyPeer());
                }
            }

            $this->response = curl_exec($ch);
            curl_close($ch);

        } catch (\Exception $e) {
            if ($this->config->isTestSystem()) {
                $dieMSG = "Your request couldn't be sent because of the following error:" . "\n" . curl_error(
                        $ch
                    ) . "\n" . $e->getMessage() . ' in ' . $e->getFile() . ', line: ' . $e->getLine() . '.';
            } else {
                $dieMSG = self::LIVE_ERROR_MSG;
            }

            echo $dieMSG;
        }

        if (isset($fh) && $this->config->isEnableCurlLog()) {
            fclose($fh);
        }
    }
1298080
protected function send(array $params)
    {
        $this->connect();
        return $this->socket->send(join(Driver::SEP, array_map([$this->socket, 'encode'], $params)).Driver::EOL);
    }
1216802
public boolean send()
	{
		assert sentRequests == null;
		sentRequests = new ArrayList<RequestCallInfo>();

		// add prepended requests,
		addPrependedRequests( sentRequests );

		// add requests to send
		while( !requestsToSend.isEmpty() )
			sentRequests.add( requestsToSend.remove( 0 ) );

		// add appended requests
		addAppendedRequests( sentRequests );

		// prepare payload
		JSONArray payload = createPayload();

		RequestBuilder builderPost = buildMultipart( "payload", payload.toString() );

		nbSentBytes += builderPost.getRequestData().length();

		try
		{
			sentRequest = builderPost.send();
		}
		catch( RequestException e )
		{
			callback.error( RPCErrorCodes.ERROR_REQUEST_SEND, e, this );
			return false;
		}

		callback.sent( this );

		return true;
	}
1033346
public function send()
    {
        $spool = new Spool(new Config($this->config));

        if ($spool->send($this)) {
            return true;
        }

        $this->setErrors($spool->getErrors());

        return false;
    }
562233
public function send()
    {
        if (empty($this->uri)) {
            throw new InvalidArgumentException('Invalid url for request.');
        }

        $customRequest = new Request();
        $customRequest->setHeaders($this->_headers);
        $this->httpClient->setRequest($customRequest);

        $this->httpClient->setMethod($this->method);
        $this->httpClient->setUri($this->uri);

        if ($this->method == Request::METHOD_GET) {
            if (!empty($this->params)) {
                $this->httpClient->setParameterGet($this->params);
            }
        }

        if ($this->method == Request::METHOD_POST) {
            if (!empty($this->params)) {
                $this->httpClient->setParameterPost($this->params);
            }
        }

        if ($this->postRawData !== null) {
            $this->httpClient->setRawBody($this->postRawData);
        }

        try {
            $this->response = $this->httpClient->send();
            if (!$this->response->isSuccess()) {
                throw new RuntimeException('Http request failure!');
            }
            $this->request = $this->httpClient->getRequest();

            return $this->response;

        } catch (HttpClientRuntimeException $exception) {
            throw new RuntimeException($exception->getMessage());
        } catch (HttpRuntimeException $exception) {
            throw new RuntimeException($exception->getMessage());
        }
    }
768811
public function sendSmsToSmppVersion1()
    {

        $this->logger->debug(__FUNCTION__, 'Input Data Send SMS to SMPP Version 1 => ' . json_encode($this->inputData));
        $phone_number = $this->inputData['phone_number'];
        $msg          = $this->inputData['msg'];
        $phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
        $msg          = trim($msg);
        $url          = $this->wsConfig['url'];
        $method       = $this->wsConfig['method'];
        $params       = array(
            'username' => $this->wsConfig['username'],
            'password' => $this->wsConfig['password'],
            'to'       => $phone_number,
            'text'     => $msg
        );
        $this->logger->debug(__FUNCTION__, 'SendSms To SMPP Version 1');
        $this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
        $this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
        if (strtoupper($method) == 'GET') {
            $this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
        } else {
            $this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
            $this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
        }
        $responseSms = $this->requests->sendRequest($url, $params, $method);
        $this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($responseSms));
        if ($responseSms === NULL || empty($responseSms)) {
            $result = array(
                'code'          => self::API_ERROR_CODE,
                'description'   => 'Error',
                'data'          => array(
                    'msg'           => 'Không gửi được MT. Response từ API về không hợp lệ',
                    'requestResult' => $responseSms
                ),
                'request_data'  => array('url' => $url, 'params' => $params, 'method' => $method),
                'response_data' => $responseSms,
                'content_data'  => array(
                    'phone_number' => $params['to'],
                    'msg'          => $params['text'],
                    'mo'           => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
                    'note'         => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
                    'subCode'      => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
                )
            );
        } else {
            if ($responseSms == self::SMPP_VER_1_SUCCESS) {
                $result = array(
                    'code'          => self::EXIT_SUCCESS,
                    'description'   => 'Success',
                    'data'          => array('requestResult' => $responseSms),
                    'request_data'  => array('url' => $url, 'params' => $params, 'method' => $method),
                    'response_data' => $responseSms,
                    'content_data'  => array(
                        'phone_number' => $params['to'],
                        'msg'          => $params['text'],
                        'mo'           => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
                        'note'         => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
                        'subCode'      => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
                    )
                );
            } else {
                $result = array(
                    'code'          => self::EXIT_ERROR,
                    'description'   => 'Failed',
                    'data'          => array('requestResult' => $responseSms),
                    'request_data'  => array('url' => $url, 'params' => $params, 'method' => $method),
                    'response_data' => $responseSms,
                    'content_data'  => array(
                        'phone_number' => $params['to'],
                        'msg'          => $params['text'],
                        'mo'           => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
                        'note'         => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
                        'subCode'      => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
                    )
                );
            }
        }
        if ($this->responseIsObject) {
            $result = Utils::arrayToObject($result);
        }
        $this->sendSmsResult = $result;
        $this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));

        return $this;
    }
732204
protected function sendData()
    {
        // So we assume that ...
        /* @var $response Doozr_Response_Web */
        $response = $this->front->getResponse();

        // Send our data as JSON through response
        $response->sendJson(
            $this->getData()->toJson(false),
            $this->generateFingerprint(1),
            null,
            false,
            false,
            true,
            $this->getData()->getCode()
        );
    }
1337765
public function push()
    {
        /** @var Push $push */
        foreach ($this->pushCollection as $push) {
            $adapter = $push->getAdapter();
            $adapter->setEnvironment($this->getEnvironment());

            if ($adapter->push($push)) {
                $push->pushed();
            }
        }

        if ($this->pushCollection && !$this->pushCollection->isEmpty()) {
            /** @var Push $push */
            $push           = $this->pushCollection->first();
            $this->response = $push->getAdapter()->getResponse();
        }
        
        return $this->pushCollection;
    }
164918
public function send()
    {
        if (!$this->_user->has('email') || !$this->_user->has('name')) {
            throw new BadMethodCallException(__d('user', 'Missing "name" or "email" property when trying to send the email.'));
        }

        if ($this->config('updateToken') === true) {
            $this->loadModel('User.Users');
            $this->_user->updateToken();
        }

        $subject = $this->_parseVariables((string)$this->subject());
        $body = $this->_parseVariables((string)$this->body());

        if (empty($subject) || empty($body)) {
            return false;
        }

        $sender = new Email($this->config('emailConfig'));
        $sent = false;
        try {
            $sent = $sender
                ->to($this->_user->get('email'), $this->_user->get('name'))
                ->subject($subject)
                ->send($body);
        } catch (\Exception $e) {
            return false;
        }

        return $sent;
    }
877964
public function send()
    {
        $req = radius_send_request($this->res);
        if (!$req) {
            throw new Auth_RADIUS_Exception('Error sending request: ' . $this->getError());
        }

        switch($req) {
            case RADIUS_ACCESS_ACCEPT:
                if (is_subclass_of($this, 'auth_radius_acct')) {
                    throw new Auth_RADIUS_Exception('RADIUS_ACCESS_ACCEPT is unexpected for accounting');
                }
                return true;

            case RADIUS_ACCESS_REJECT:
                return false;

            case RADIUS_ACCOUNTING_RESPONSE:
                if (is_subclass_of($this, 'auth_radius_pap')) {
                    throw new Auth_RADIUS_Exception('RADIUS_ACCOUNTING_RESPONSE is unexpected for authentication');
                }
                return true;

            default:
                throw new Auth_RADIUS_Exception("Unexpected return value: $req");
        }

    }
532614
public function execute(): bool
    {
        $messages = $this->app->make('orchestra.messages');
        $queues = $this->queued();
        $fails = [];

        foreach ($queues as $queue) {
            try {
                $this->driver()->upload($queue);

                $messages->add('success', trans('orchestra/foundation::response.extensions.activate', [
                    'name' => $queue,
                ]));
            } catch (Exception $e) {
                // this could be anything.
                $messages->add('error', $e->getMessage());
                $fails[] = $queue;
            }
        }

        $this->memory->put('orchestra.publisher.queue', $fails);

        return true;
    }
43284
public function send()
    {
        if (! $this->client) {
            return false;
        }

        if (
            1 == func_num_args() &&
            (is_array(func_get_arg(0)) || is_object(func_get_arg(0)))
        ) {
            return $this->client->sendMessage(func_get_arg(0));
        }

        if (func_num_args() > 0) {
            call_user_func_array([$this, 'content'], func_get_args());
        }

        return $this->client->sendMessage($this);
    }
1149554
private function sendBroadcast()
    {
        if (isset($this->inputs['action']) && trim($this->inputs['action']) == 'sendBroadcast') {
            $this->connectToWhatsApp();
            if (isset($this->inputs['message']) && trim($this->inputs['message'] !== '')) {
                $this->wa->sendBroadcastMessage($this->inputs['to'], $this->inputs['message']);
            }
            if (isset($this->inputs['image']) && $this->inputs['image'] !== false) {
                $this->wa->sendBroadcastImage($this->inputs['to'], $this->inputs['image']);
            }
            if (isset($this->inputs['audio']) && $this->inputs['audio'] !== false) {
                $this->wa->sendBroadcastAudio($this->inputs['to'], $this->inputs['audio']);
            }
            if (isset($this->inputs['video']) && $this->inputs['video'] !== false) {
                $this->wa->sendBroadcastVideo($this->inputs['to'], $this->inputs['video']);
            }
            if (isset($this->inputs['locationname']) && trim($this->inputs['locationname'] !== '')) {
                $this->wa->sendBroadcastPlace($this->inputs['to'], $this->inputs['userlong'], $this->inputs['userlat'], $this->inputs['locationname'], null);
            }
            exit(json_encode([
                'success'  => true,
                'data'     => 'Broadcast Message Sent!',
                'messages' => $this->messages,
            ]));
        }
    }