Ejemplo n.º 1
0
 /** @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);
     });
 }
Ejemplo n.º 2
0
Archivo: Jne.php Proyecto: 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());
 }
Ejemplo n.º 3
0
Archivo: Jne.php Proyecto: akivaron/jne
 /**
  * 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());
 }