protected function _put($endpoint, $request, $customPostfix = false, $dwollaParse = true)
{
// First, we try to catch any errors as the request "goes out the door"
try {
$response = $this->client->put($this->_host() . ($customPostfix ? $customPostfix : self::$settings->default_postfix) . $endpoint, ['json' => $request]);
if (self::$settings->debug) {
$this->_console("PUT Request to {$endpoint}\n");
$this->_console(" " . json_encode($request));
}
} catch (RequestException $exception) {
$response = false;
if (self::$settings->debug) {
$this->_console("DwollaPHP: An error has occurred during a PUT request.\nRequest Body:\n");
$this->_console($exception->getRequest());
if ($exception->hasResponse()) {
$this->_console("Server Response:\n");
$this->_console($exception->getResponse());
}
}
}
if ($response) {
if ($response->getBody()) {
// If we get a response, we parse it out of the Dwolla envelope and catch API errors.
return $dwollaParse ? $this->_dwollaparse(json_decode($response->getBody(), true)) : json_decode($response->getBody(), true);
}
} else {
if (self::$settings->debug) {
$this->_console("DwollaPHP: An error has occurred; the response body is empty");
}
return null;
}
}