Beispiel #1
0
 /**
  * Get the shipment status history.
  *
  * @param array $response
  *
  * @return Track
  */
 protected function getTrack(array $response)
 {
     $track = new Track();
     foreach ($response['tuStatus'][0]['history'] as $index => $historyItem) {
         $event = new Event();
         $status = $this->resolveStatus($response, $index);
         $event->setStatus($status);
         $event->setLocation($this->getLocation($historyItem));
         $event->setDescription($historyItem['evtDscr']);
         $event->setDate($this->getDate($historyItem));
         $event->addAdditionalDetails('eventNumber', $response['tuStatus'][0]['progressBar']['evtNos'][$index]);
         $track->addEvent($event);
         if ($status == Track::STATUS_DELIVERED) {
             $track->setRecipient($this->getRecipient($response));
         }
         if ($status == Track::STATUS_PICKUP) {
             $track->addAdditionalDetails('parcelShop', $this->getParcelShopDetails($response));
         }
     }
     return $track->sortEvents();
 }
 /** @test */
 public function it_converts_the_date_to_carbon_if_passed_as_string()
 {
     $this->event->setDate('2016-01-31');
     $this->assertInstanceOf(Carbon::class, $this->event->getDate());
     $this->assertSame('2016-01-31', $this->event->getDate()->toDateString());
 }