Sent request and get response from a service

@param $message
@return object
965809
public function send($message)
    {
        try {
            $code = 200;
            $this->sendEvent($this->targetServiceName, $message);
            $message = 'Event has been sent';
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $code = $exception->getCode();
        }

        return new Response(
            json_encode(['message' => $message]),
            (!empty($code)) ? $code : 500
        );
    }
1303207
public function statusMessage($message = '')
    {
        $statusCode = $this->getStatusCode();

        if (!isset(ResponseHeader::$httpStatus[$statusCode])) {
            throw new ResponseException(sprintf('Invalid status code provided %s', $statusCode));
        }

        if (!empty($message)) {
            $this->statusMessage = $message;

            return $this;
        }

        $this->statusMessage = ResponseHeader::$httpStatus[$statusCode];

        return $this;
    }
241603
public function sendMessage($message) {
		$message = preg_replace("/(\n\r|\n)/","\r",$message);
		$query = http_build_query(array(
			'user' => $this->_user_id,
			'pass' => $this->_api_key,
			'msg' => $message
		));
		$url = self::api_url.'?'.$query;

		$curl_handler = curl_init();
		curl_setopt($curl_handler,CURLOPT_URL,$url);
		curl_setopt($curl_handler,CURLOPT_POST,false);
		curl_setopt($curl_handler,CURLOPT_RETURNTRANSFER,true);
		curl_setopt($curl_handler,CURLOPT_HEADER,true);
		curl_setopt($curl_handler,CURLOPT_NOBODY,true);
		curl_setopt($curl_handler,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($curl_handler,CURLOPT_SSL_VERIFYPEER,true);
		curl_setopt($curl_handler,CURLOPT_SSL_VERIFYHOST,2);
		curl_setopt($curl_handler,CURLOPT_CAINFO,__DIR__."/freemobile.crt");
		
		if (curl_exec($curl_handler) === false) {
			throw new Exception('Curl error : '.curl_error($curl_handler));
		}
		
		$status = curl_getinfo($curl_handler,CURLINFO_HTTP_CODE);
		curl_close($curl_handler);

		switch ($status) {
		case 200:
			return true;
			break;

		case 400:
			throw new Exception('Badly formed request');
			return false;
			break;

		case 402:
			throw new OverflowException('Too many messages sent in a short period of time');
			return false;
			break;

		case 403:
			throw new UnexpectedValueException('SMS notification service not activated or wrong credentials');
			return false;
			break;

		case 500:
			throw new RuntimeException('Server error, try later');
			return false;
			break;
			
		default:
			return false;
			break;
		}
	}
868464
public function withMessage(string $message): PayloadInterface
    {
        if ($this->message === $message) {
            return $this;
        }

        $clone = clone $this;
        $clone->message = $message;

        return $clone;
    }
1345391
public function sendMessage(AbstractMessage $message): FirebaseResponseInterface
    {
        $this->messageBuilder->setMessage($message);

        $response = $this->httpClient->post(
            '',
            ['body' => $this->messageBuilder->getMessageAsJson()]
        );

        $processedResponse = $this->responseProcessor->processResponse($message, $response);
        $this->dispatchEvent($processedResponse);

        return $processedResponse;
    }
148324
public function send(Message $message)
    {
        $response = $this->guzzleClient->post('/messages', [
            'json' => [
                'originator' => $message->getOriginator(),
                'recipients' => $message->getRecipient(),
                'body'       => $message->getBody(),
            ],
            'http_errors' => false,
        ]);

        try {
            $document = JsonHelper::decode((string) $response->getBody());
        } catch (\RuntimeException $e) {
            throw new ApiRuntimeException('The MessageBird server did not return valid JSON.', [], $e);
        }

        if (isset($document['errors'])) {
            $errors = $document['errors'];
        } else {
            $errors = [];
        }

        $statusCode = (int) $response->getStatusCode();

        if (!in_array($statusCode, [200, 201, 204, 401, 404, 405, 422]) && !($statusCode >= 500 && $statusCode < 600)) {
            throw new ApiRuntimeException(sprintf('Unexpected MessageBird server behaviour (HTTP %d)', $statusCode), $errors);
        }

        if (!isset($document['recipients']['items'][0]['status'])) {
            $deliveryStatus = SendMessageResult::STATUS_NOT_SENT;
        } else {
            $deliveryStatus = $document['recipients']['items'][0]['status'];
        }

        return new SendMessageResult($deliveryStatus, $errors);
    }
714713
public function createRequest(PushMessage $message) : RequestInterface
    {
        $host = $message->getPushSubscription()->getEndpoint()->getHost();
        $pushService = $this->pushServiceRegistry->getPushService($host);

        return $pushService->createRequest($message);
    }
55768
public function send($message)
    {
        try {
            $code = 200;
            $this->sendCommand($this->getTargetServiceName(), $message, false);
            $message = 'Command has been sent';
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $code = $exception->getCode();
        }

        return new Response(
            json_encode(['message' => $message]),
            (!empty($code)) ? $code : 500
        );
    }
15749
public function send($message = null)
    {
        if ($message) {
            $this->message($message);
        }

        if (empty($this->message)) {
            throw new RuntimeException('No message to send.');
        }

        if (is_null($this->agentId)) {
            throw new RuntimeException('No agentid specified.');
        }

        $message = $this->message->transformForJsonRequest(array_merge([
            'agentid' => $this->agentId,
            'safe' => intval($this->secretive),
        ], $this->to));

        $this->secretive = false;

        return $this->client->send($message);
    }
928325
public function sendMessage($message)
    {
        $message = sprintf("%s\r\n", $message);
        fwrite($this->getSocketStream(), $message, strlen($message));
        return $this->receiveMessage();
    }
1234224
public function getStoredConversation($message = null)
    {
        if (is_null($message)) {
            $message = $this->getMessage();
        }

        $conversation = $this->cache->get($message->getConversationIdentifier());
        if (is_null($conversation)) {
            $conversation = $this->cache->get($message->getOriginatedConversationIdentifier());
        }

        return $conversation;
    }
580128
public function resolve(object $message, ServiceBusContext $context, MessageHandlerArgument $argument): object
    {
        /** @var object $object */
        $object = $this->serviceLocator->get((string) $argument->typeClass);

        return $object;
    }
926498
public function reply ($message) {
		// Make sure we actually have a text to reply to
		if (!$this->inbound_message) {
			return false;
		}

		return $this->sendText($this->from, $this->to, $message);
	}
661773
public function parseRequest($message)
    {
        if (!($parts = $this->parseMessage($message))) {
            return false;
        }

        // Parse the protocol and protocol version
        if (isset($parts['start_line'][2])) {
            $startParts = explode('/', $parts['start_line'][2]);
            $protocol = strtoupper($startParts[0]);
            $version = isset($startParts[1]) ? $startParts[1] : '1.1';
        } else {
            $protocol = 'HTTP';
            $version = '1.1';
        }

        $parsed = [
            'method'   => strtoupper($parts['start_line'][0]),
            'protocol' => $protocol,
            'protocol_version' => $version,
            'headers'  => $parts['headers'],
            'body'     => $parts['body']
        ];

        $parsed['request_url'] = $this->getUrlPartsFromMessage(
            (isset($parts['start_line'][1]) ? $parts['start_line'][1] : ''), $parsed);

        return $parsed;
    }
813232
protected function askRequired($message) {
    $question = new Question($this->formatQuestion($message));
    $question->setValidator(function ($answer) {
      if (empty($answer)) {
        throw new \RuntimeException(
          'You must enter a value!'
        );
      }

      return $answer;
    });
    return $this->doAsk($question);
  }
531568
public function sendMessage(string $message) : ?Message 
    {
        $thread = $this->messageGroup();

        if ($thread === null) return null;

        return $thread->sendMessage($message);
    }
383413
protected function forbidden(string $message = 'Forbidden.'): Response
    {
        return $this->getResponse()
            ->setContent($message)
            ->setStatusCode(Response::HTTP_FORBIDDEN);
    }