-
Notifications
You must be signed in to change notification settings - Fork 34
Description
There are a number of documented endpoints that are not able to be queried through the sift-php classes presently, due to not having methods to use them.
Such as the Webhooks API, for example: https://sift.com/developers/docs/curl/webhooks-api/overview
Rather than trying to push through methods for everything to handle every endpoint and maintain them as new ones are introduced, it would be useful if there was a generic method available in the SiftClient class to do so, something like --
public function queryEndpoint( $version, $endpoint, $method, $query_args = array() ) {
$api_url = self::urlPrefix( $version ) . '/' . str_replace( '{accountId}', $this->account_id, $endpoint );
$endpoint = ltrim( $endpoint, '/' );
$query_args['auth'] = $this->api_key . ':';
try {
$request = new SiftRequest(
$api_url,
$method,
$this->timeout,
$this->version,
$query_args
);
return $request->send();
} catch (Exception $e) {
$this->logError($e->getMessage());
return null;
}
}or something -- I could be off on a couple usages or paradigms, but that feels like it mirrors most of the existing patterns from a quick glance.
I'm unsure if there's other tokens that may need to be able to get str_replaced into the api url for other varied endpoints -- or if it's better to use accessor functions to pull those out of the SiftClient instance and add them in manually prior to invoking.
Once introduced, it could be used something like
$sift = new SiftClient([ 'api_key' => 'my_api_key', 'account_id' => 'my_account_id' ]);
$response = $sift->queryEndpoint( 3, 'accounts/{accountId}/webhooks', 'POST', $data_array );
print_r( $response->body ); In short, the big reason for this request is to enable the library to be used for all requests sent to the Sift API, rather than needing to maintain a secondary code path for unsupported endpoints -- at which point it would be easier when building client integrations to ignore this official client library and consolidate around a custom one, which sort of defeats the purpose and benefits of using and supporting an official client, in my opinion.