74 lines
1.5 KiB
PHP
74 lines
1.5 KiB
PHP
<?php
|
|
|
|
class PopularDestinationsApi extends Api {
|
|
public $apiName = 'populardestinations';
|
|
|
|
public function __construct($requestUri, $encryption=true) {
|
|
$encryption = false; // We do not need encryption for this class
|
|
parent::__construct($requestUri, $encryption);
|
|
//$this->encryption = $encryption;
|
|
}
|
|
|
|
/**
|
|
* @OA\Get(
|
|
* path="/SAVVY/geofencearea/api/populardestinations?city={city_id}&country={country_code}",
|
|
* security={{"token": {}}},
|
|
* summary="Get list of popular destinations by city id and country code",
|
|
* @OA\Response(
|
|
* response="200",
|
|
* description="city list",
|
|
* @OA\JsonContent(
|
|
* type="object"
|
|
* )
|
|
* )
|
|
* )
|
|
*/
|
|
public function indexAction() {
|
|
$message = 'No popular destinations found';
|
|
|
|
$city = $this->requestParams['city'] ?? 0;
|
|
$country = $this->requestParams['country'] ?? '';
|
|
|
|
try {
|
|
if ($city<1) {
|
|
throw new Exception("Invalid city");
|
|
}
|
|
if ($country!='SG') {
|
|
throw new Exception("Invalid country");
|
|
}
|
|
$db = new Db();
|
|
list($res, $err) = PopularDestinations::get( $db->getConnect(), $country, $city );
|
|
return $this->response(
|
|
[
|
|
"destinations" => $res,
|
|
"error" => $err
|
|
], 200 );
|
|
|
|
} catch (Exception $e) {
|
|
$message = $e->getMessage();
|
|
}
|
|
return $this->response(
|
|
[
|
|
"destinations" => NULL,
|
|
"error" => $message
|
|
], 404);
|
|
}
|
|
|
|
public function viewAction() {
|
|
|
|
}
|
|
|
|
public function createAction() {
|
|
|
|
}
|
|
|
|
public function updateAction() {
|
|
|
|
}
|
|
|
|
public function deleteAction() {
|
|
|
|
}
|
|
|
|
}
|