Dwolla\RestClient::_post PHP Метод

_post() защищенный Метод

Wrapper around Guzzle POST request.
protected _post ( string $endpoint, string $request, boolean $customPostfix = false, boolean $dwollaParse = true ) : String[]
$endpoint string API endpoint string
$request string Request body. JSON encoding is optional.
$customPostfix boolean Use default REST postfix?
$dwollaParse boolean Parse out of message envelope?
Результат String[] Response body.
    protected function _post($endpoint, $request, $customPostfix = false, $dwollaParse = true)
    {
        // First, we try to catch any errors as the request "goes out the door"
        try {
            $response = $this->client->post($this->_host() . ($customPostfix ? $customPostfix : self::$settings->default_postfix) . $endpoint, ['json' => $request]);
            if (self::$settings->debug) {
                $this->_console("POST 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 POST 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;
        }
    }