public function put($path, $params = null) { $response = $this->_doRequest('PUT', $path, $this->_buildXml($params)); $responseCode = $response['status']; if ($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) { return Xml::buildArrayFromXml($response['body']); } else { Util::throwStatusCodeException($responseCode); } }
/** * @expectedException Braintree\Exception\Unexpected */ public function testThrowUnknownException() { Braintree\Util::throwStatusCodeException(999); }
public function parseAndValidateQueryString($queryString) { // parse the params into an array parse_str($queryString, $params); // remove the hash $queryStringWithoutHash = null; if (preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) { $queryStringWithoutHash = $match[1]; } if ($params['http_status'] != '200') { $message = null; if (array_key_exists('bt_message', $params)) { $message = $params['bt_message']; } Util::throwStatusCodeException(isset($params['http_status']) ? $params['http_status'] : null, $message); } // recreate the hash and compare it if ($this->_hash($queryStringWithoutHash) == $params['hash']) { return $params; } else { throw new Exception\ForgedQueryString(); } }