Esempio n. 1
0
 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());
     }
 }
Esempio n. 2
0
 function testShipApi_Request_nodeUri_should_parse_nested()
 {
     $node = ShipApi_Request::parseNode($this->resource_nested);
     $this->assertEqual($node, 'packages');
 }