Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add ability to GET custom endpoint #7

Closed
rodrigoaguilera opened this issue Aug 9, 2023 · 2 comments
Closed

[FEATURE] Add ability to GET custom endpoint #7

rodrigoaguilera opened this issue Aug 9, 2023 · 2 comments

Comments

@rodrigoaguilera
Copy link

Summary / Description

I am using the salesforce knowledge base endpoint that require a GET HTTP request to fetch data. Currently the custom endpoint is hardcoded to POST.

Describe the solution you'd like

customEndpoint accepts a new parameter $method which defaults to POST.

Describe alternatives you've considered

I will just patch the code for my use case.

Possible solution

public function customEndpoint($customEndpoint, $data, $successStatusCode = 200, $additionalHeaders = [], $method = 'POST')
    {
        /* customEndpoint could be all behind /services/ */
        $url = "{$this->instanceUrl}/services/{$customEndpoint}";

        $headers = $this->getHeaders(
            [
                'Authorization' => "OAuth {$this->accessToken}",
                'Content-type' => 'application/json',
            ],
            $additionalHeaders
        );

        $client = new Client();

        try {
            $request = $client->request(
                $method,
                $url,
                [
                    'headers' => $headers,
                    'json' => $data
                ]
            );

            $status = $request->getStatusCode();
        } catch (ClientException $e) {
            throw SalesforceException::fromClientException($e);
        }
rodrigoaguilera added a commit to rodrigoaguilera/php-salesforce-rest-api that referenced this issue Aug 10, 2023
@Kephson
Copy link
Owner

Kephson commented Aug 14, 2023

Hi, thanks for implementing that; I merged your pull request and will release a new version.

@Kephson
Copy link
Owner

Kephson commented Aug 15, 2023

closed with new release 1.1.3, thanks for the pull request: https://github.com/Kephson/php-salesforce-rest-api/releases/tag/1.1.3

@Kephson Kephson closed this as completed Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants