Esempio 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);
     });
 }
Esempio n. 2
0
File: Jne.php Progetto: 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());
 }
Esempio n. 3
0
File: Jne.php Progetto: 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());
 }