/** * 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_can_access_the_status() { $this->event->setStatus('delivered'); $this->assertSame('delivered', $this->event->getStatus()); }