src/Core/Communicator.php
private function sendRequest(string $endPoint, string $method, string $content = "", bool $https = true): Response
    {
        $url = ($https ? "https://" : "http://") . self::DOMAIN . "/" .$endPoint;
        $request = \Httpful\Request::init($method, 'application/json');
        $request->basicAuth($this->accountToken, $this->apiToken)
                ->addHeader('User-Agent', 'iP1sms/indev')
                ->expectsJson()
                ->Uri($url)
                ->body($content, 'application/json')
                ->neverSerialize();

        $response = $request->send();

        if ($response->hasErrors()) {
            $this->errorResponses[] = $response;
        }
        return $response;
    }
private function sendRequest(string $endPoint, string $method, string $content = "", bool $https = true): Response
    {
        $url = ($https ? "https://" : "http://") . self::DOMAIN . "/" .$endPoint;
        $request = \Httpful\Request::init($method, 'application/json');
        $request->basicAuth($this->accountToken, $this->apiToken)
                ->addHeader('User-Agent', 'iP1sms/indev')
                ->expectsJson()
                ->Uri($url)
                ->body($content, 'application/json')
                ->neverSerialize();

        $response = $request->send();

        if ($response->hasErrors()) {
            $this->errorResponses[] = $response;
        }
        return $response;
    }
private function sendRequest ( string $ endPoint , string $ method , string $ content = "" , bool $ https = true ) : Response { $ url = ( $ https ? "https://" : "http://" ) . self :: DOMAIN . "/" . $ endPoint ; $ request = \ Httpful \ Request :: init ( $ method , 'application/json' ) ; $ request -> basicAuth ( $ this -> accountToken , $ this -> apiToken ) -> addHeader ( 'User-Agent' , 'iP1sms/indev' ) -> expectsJson ( ) -> Uri ( $ url ) -> body ( $ content , 'application/json' ) -> neverSerialize ( ) ; $ response = $ request -> send ( ) ; if ( $ response -> hasErrors ( ) ) { $ this -> errorResponses [ ] = $ response ; } return $ response ; }
Sends a HTTP request to the RESTful API and returns the result as a JSON string.

@param string  $endPoint The URI that the function should use.
@param string  $method   The HTTP method that should be used, valid ones are:
METH_POST, METH_GET, METH_DELETE and METH_PUT.
@param string  $content  A JSON string containing all additional data that can not be provided by $endPoint.
@param boolean $https    Whether the the API call should use HTTPS or not(HTTP).
@return string             The response from the API.
Sends a HTTP request to the RESTful API and returns the result as a JSON string .