Esempio n. 1
0
 /**
  * Do manifest action (time definite)
  *
  * @Method ("POST")
  * @Route (
  *      "/td/manifest/{id}.{_format}",
  *      name="wk_dhl_api_b2b_do_manifest_td",
  *      requirements={
  *          "id"="^\d{12}$",
  *          "_format"="(xml|json)"
  *      },
  *      defaults={
  *          "_format"="json"
  *      }
  * )
  * @param Request $request
  * @return Response
  */
 public function doManifestTDAction(Request $request)
 {
     try {
         $shipmentNumber = new ShipmentNumberType($request->query->get('id'));
         $result = $this->connection->doManifestTD($shipmentNumber);
         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);
     }
 }
Esempio n. 2
0
 /**
  * Tests doing a manifest (TD)
  *
  * @param ShipmentNumberType $shipmentNumber
  * @param DoManifestResponse $expectedResponse
  * @param Exception          $expectedException
  *
  * @dataProvider provideDoManifestData
  */
 public function testDoManifestTD(ShipmentNumberType $shipmentNumber, DoManifestResponse $expectedResponse = null, Exception $expectedException = null)
 {
     if ($expectedException) {
         $this->clientWillThrowException($expectedException);
         // Fire the function which is to be tested
         $this->connection->doManifestTD($shipmentNumber);
     } elseif ($expectedResponse) {
         // Stubbing
         $this->client->expects($this->any())->method('__soapCall')->willReturn($expectedResponse);
         // Fire the function which is to be tested
         $response = $this->connection->doManifestTD($shipmentNumber);
         // check if the response has a status information with the expected status code
         $this->assertArrayHasKey('Status', $response);
         $this->assertArrayHasKey('StatusCode', $response['Status']);
         $this->assertSame($expectedResponse->toArray(), $response);
     }
 }