コード例 #1
0
ファイル: B2bController.php プロジェクト: pvankouteren/dhlapi
 /**
  * Get manifest action (day definite)
  *
  * @Method ("GET")
  * @Route (
  *      "/dd/manifest/{from}/{to}.{_format}",
  *      name="wk_dhl_api_b2b_get_manifest_dd",
  *      requirements={
  *          "_format"="(xml|json)"
  *      },
  *      defaults={
  *          "_format"="json"
  *      }
  * )
  * @ParamConverter("from", options={"format": "Y-m-d"})
  * @ParamConverter("to", options={"format": "Y-m-d"})
  *
  * @param DateTime $from
  * @param DateTime $to
  * @return Response
  */
 public function getManifestDDAction(DateTime $from, DateTime $to)
 {
     try {
         $result = $this->connection->getManifestDD($from, $to);
         return $this->generateResponse($result);
     } catch (BadRequestHttpException $exception) {
         return $this->generateError($exception->getMessage(), $exception->getCode(), 400);
     } catch (\InvalidArgumentException $exception) {
         return $this->generateError($exception->getMessage(), 1001, 400);
     } catch (\Exception $exception) {
         return $this->generateError($exception->getMessage(), 1000);
     }
 }
コード例 #2
0
ファイル: ConnectionTest.php プロジェクト: asgoodasnu/dhlapi
 /**
  * Provides data to test getting export documents
  *
  * @return array
  */
 public function provideGetExportDocData()
 {
     // Misc
     $version = Connection::getVersion();
     // Create response for success case
     $shipmentNumber = new ShipmentNumberType('960701151320');
     $successStatus = new StatusInformation(0, 'ok');
     $exportData = new ExportDocData($shipmentNumber, $successStatus);
     $response = new GetExportDocResponse($version, $successStatus, $exportData);
     // Create an exception for a bad request
     $exception = new BadRequestHttpException('General error', null, 1000);
     return array(array($shipmentNumber, $response), array($shipmentNumber, null, $exception));
 }