/** @test */
 function location_collection_can_instantiate_from_array()
 {
     $rawLocations = [['label' => 'BANDUNG', 'code' => 'QkRPMTAwMDA=']];
     $collection = LocationCollection::fromArray($rawLocations, new LocationMapper());
     $this->assertInstanceOf(LocationCollection::class, $collection);
     $collection->each(function ($location) {
         $this->assertInstanceOf(LocationInterface::class, $location);
     });
 }
Beispiel #2
0
Datei: Jne.php Projekt: risan/jne
 /**
  * Search for available location.
  *
  * @param string $uri
  * @param string $query
  *
  * @return \Jne\Contracts\Collections\LocationCollectionInterface
  */
 protected function searchLocation($uri, $query)
 {
     $uri .= '?' . http_build_query(['term' => $query]);
     $locations = $this->httpClient()->getAndParseJson($uri);
     return LocationCollection::fromArray($locations, new LocationMapper());
 }
Beispiel #3
0
 /**
  * Search for available destination location.
  *
  * @param string $query
  *
  * @return Jne\Contracts\Collections\LocationCollection
  */
 public function searchDestination($query)
 {
     $uri = self::SEARCH_DESTINATION_URI . '?' . http_build_query(['term' => $query]);
     $destinations = $this->httpClient()->getAndParseJson($uri);
     return LocationCollection::fromArray($destinations, new LocationMapper());
 }