| @@ 18-62 (lines=45) @@ | ||
| 15 | use Core23\SetlistFm\Exception\NotFoundException; |
|
| 16 | use Core23\SetlistFm\Model\City; |
|
| 17 | ||
| 18 | final class CityService extends AbstractService |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * Get the city data for an id. |
|
| 22 | * |
|
| 23 | * @param int $cityId |
|
| 24 | * |
|
| 25 | * @throws ApiException |
|
| 26 | * @throws NotFoundException |
|
| 27 | * |
|
| 28 | * @return City |
|
| 29 | */ |
|
| 30 | public function getCity(int $cityId): City |
|
| 31 | { |
|
| 32 | return City::fromApi( |
|
| 33 | $this->call('city/'.$cityId) |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Search for cities. Returns cities sorted by relevance. |
|
| 39 | * |
|
| 40 | * @param array $fields |
|
| 41 | * @param int $page |
|
| 42 | * |
|
| 43 | * @throws ApiException |
|
| 44 | * @throws NotFoundException |
|
| 45 | * |
|
| 46 | * @return City[] |
|
| 47 | */ |
|
| 48 | public function search(array $fields, int $page = 1): array |
|
| 49 | { |
|
| 50 | $response = $this->call('search/cities', array_merge($fields, [ |
|
| 51 | 'p' => $page, |
|
| 52 | ])); |
|
| 53 | ||
| 54 | if (!array_key_exists('cities', $response)) { |
|
| 55 | return []; |
|
| 56 | } |
|
| 57 | ||
| 58 | return array_map(function ($data) { |
|
| 59 | return City::fromApi($data); |
|
| 60 | }, $response['cities']); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| @@ 18-62 (lines=45) @@ | ||
| 15 | use Core23\SetlistFm\Exception\NotFoundException; |
|
| 16 | use Core23\SetlistFm\Model\Venue; |
|
| 17 | ||
| 18 | final class VenueService extends AbstractService |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * Get the metadata for an artist. |
|
| 22 | * |
|
| 23 | * @param string $venueId |
|
| 24 | * |
|
| 25 | * @throws ApiException |
|
| 26 | * @throws NotFoundException |
|
| 27 | * |
|
| 28 | * @return Venue |
|
| 29 | */ |
|
| 30 | public function getVenue(string $venueId): Venue |
|
| 31 | { |
|
| 32 | return Venue::fromApi( |
|
| 33 | $this->call('venue/'.$venueId) |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Search for venues. Returns venues sorted by relevance. |
|
| 39 | * |
|
| 40 | * @param array $fields |
|
| 41 | * @param int $page |
|
| 42 | * |
|
| 43 | * @throws ApiException |
|
| 44 | * @throws NotFoundException |
|
| 45 | * |
|
| 46 | * @return Venue[] |
|
| 47 | */ |
|
| 48 | public function search(array $fields, int $page = 1): array |
|
| 49 | { |
|
| 50 | $response = $this->call('search/venues', array_merge($fields, [ |
|
| 51 | 'p' => $page, |
|
| 52 | ])); |
|
| 53 | ||
| 54 | if (!array_key_exists('venue', $response)) { |
|
| 55 | return []; |
|
| 56 | } |
|
| 57 | ||
| 58 | return array_map(function ($data) { |
|
| 59 | return Venue::fromApi($data); |
|
| 60 | }, $response['venue']); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||