コード例 #1
0
 /**
  * @param string    $from
  * @param string    $to
  * @param \DateTime $date
  * @return \Tufesa\Service\Type\Schedules
  * @throws \Tufesa\Service\Exceptions\ResponseException
  */
 public function getSchedules($from, $to, \DateTime $date)
 {
     $params = ["from" => $from, "to" => $to, "date" => $date->format("Ymd")];
     $request = $this->guzzleClient->get("schedules?" . http_build_query($params));
     $this->setLastRequest($request);
     try {
         // TODO make timeout configurable
         $response = $request->send();
     } catch (\Exception $e) {
         throw new TimeoutException('There was no response from the Booking Engine');
     }
     $this->setLastResponse($response);
     $resource = $response->json();
     if ($resource["_Response"]["resultField"]["_id"] != "00") {
         throw new ResponseException($resource["_Response"]["resultField"]["_message"]);
     }
     return ScheduleFactory::create($resource["_Response"]["dataField"]);
 }
コード例 #2
0
 /**
  * @expectedException InvalidArgumentException
  * @dataProvider invalidScheduleProvider
  */
 public function test_invalid_data_should_raise_an_exception($data)
 {
     ScheduleFactory::create($data);
 }