public function sendRequest($method, $resource, array $data = null) { $fullUri = ShipApi_Request::parseUri($this->shipApi->baseUri, $resource); $this->_zendRestClient->setAuth($this->shipApi->username, $this->shipApi->apiKey); $this->_zendRestClient->setUri($fullUri); $method = 'rest' . ucfirst(strtolower($method)); $rootNodeName = ShipApi_Request::parseNode($resource); $response = $this->_zendRestClient->{$method}($rootNodeName . ".xml", $data); if ($response->isSuccessful()) { return new Zend_Rest_Client_Result($response->getBody()); } else { throw new Zend_Rest_Client_Exception('Error ' . $response->getStatus() . ": " . $response->getBody()); } }
function testShipApi_Request_parseUri_should_parse_nested() { $uri = ShipApi_Request::parseUri($this->base, $this->resource_nested); $this->assertEqual($uri, $this->base . $this->resource_nested); }