src/PhrestSDK.php
private function getHTTPResponse(
    $method,
    $path,
    RequestOptions $options = null
  )
  {
    $client = new Client();

    // Build body
    $body = new PostBody();

    if ($options)
    {
      foreach ($options->getPostParams() as $name => $value)
      {
        $body->setField($name, $value);
      }
    }

    // Prepare the request
    $request = new Request(
      $method,
      $this->url . $path,
      [],
      $body,
      []
    );

    // Get response
    $response = $client->send($request);
    $body = json_decode($response->getBody());

    if (isset($body->data))
    {
      return $body->data;
    }
    else
    {
      throw new \Exception('Error calling ' . $method . ' to: ' . $path);
    }
  }
private function getHTTPResponse(
    $method,
    $path,
    RequestOptions $options = null
  )
  {
    $client = new Client();

    // Build body
    $body = new PostBody();

    if ($options)
    {
      foreach ($options->getPostParams() as $name => $value)
      {
        $body->setField($name, $value);
      }
    }

    // Prepare the request
    $request = new Request(
      $method,
      $this->url . $path,
      [],
      $body,
      []
    );

    // Get response
    $response = $client->send($request);
    $body = json_decode($response->getBody());

    if (isset($body->data))
    {
      return $body->data;
    }
    else
    {
      throw new \Exception('Error calling ' . $method . ' to: ' . $path);
    }
  }
private function getHTTPResponse ( $ method , $ path , RequestOptions $ options = null ) { $ client = new Client ( ) ; // Build body $ body = new PostBody ( ) ; if ( $ options ) { foreach ( $ options -> getPostParams ( ) as $ name => $ value ) { $ body -> setField ( $ name , $ value ) ; } } // Prepare the request $ request = new Request ( $ method , $ this -> url . $ path , [ ] , $ body , [ ] ) ; // Get response $ response = $ client -> send ( $ request ) ; $ body = json_decode ( $ response -> getBody ( ) ) ; if ( isset ( $ body -> data ) ) { return $ body -> data ; } else { throw new \ Exception ( 'Error calling ' . $ method . ' to: ' . $ path ) ; } }
Makes a cURL HTTP request to the API and returns the response
todo this needs to also handle PUT, POST, DELETE

@param string                 $method
@param                        $path
@param RequestOptions         $options

@throws \Exception
@return string
Makes a cURL HTTP request to the API and returns the response todo this needs to also handle PUT POST DELETE