SevenShores\Hubspot\Http\Client::generateUrl PHP Method

generateUrl() protected method

Generate the full endpoint url, including query string.
protected generateUrl ( string $endpoint, string $query_string = null, boolean $requires_auth = true ) : string
$endpoint string The HubSpot API endpoint.
$query_string string The query string to send to the endpoint.
$requires_auth boolean Whether or not this HubSpot API endpoint requires authentication
return string
    protected function generateUrl($endpoint, $query_string = null, $requires_auth = true)
    {
        $url = $endpoint . "?";
        if ($requires_auth) {
            $authType = $this->oauth ? "access_token" : "hapikey";
            if (!$this->oauth2) {
                $url .= $authType . "=" . $this->key;
                if ($this->userId) {
                    $url .= "&userId={$this->userId}";
                }
            } else {
                if ($this->userId) {
                    $url .= "userId={$this->userId}";
                }
            }
        }
        return $url . $query_string;
    }