@@ 39-55 (lines=17) @@ | ||
36 | * |
|
37 | * @return \Symfony\Component\HttpFoundation\Response |
|
38 | */ |
|
39 | public function getForecastByCityName($cityName, $numberOfDays = 16, $countryCode = '') |
|
40 | { |
|
41 | $response = new Response(); |
|
42 | ||
43 | try { |
|
44 | $data = $this->dailyForecast->fetchForecastByCityName($cityName, $countryCode, $numberOfDays); |
|
45 | $response->setContent($data); |
|
46 | } catch (NotAuthorizedException $e) { |
|
47 | $response->setContent($e->getMessage()); |
|
48 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
49 | } catch (NotFoundException $e) { |
|
50 | $response->setContent($e->getMessage()); |
|
51 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
52 | } |
|
53 | ||
54 | return $response; |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * Returns daily forecast by city id. |
|
@@ 65-81 (lines=17) @@ | ||
62 | * |
|
63 | * @return \Symfony\Component\HttpFoundation\Response |
|
64 | */ |
|
65 | public function getForecastByCityId($cityId, $numberOfDays = 16) |
|
66 | { |
|
67 | $response = new Response(); |
|
68 | ||
69 | try { |
|
70 | $data = $this->dailyForecast->fetchForecastByCityId($cityId, $numberOfDays); |
|
71 | $response->setContent($data); |
|
72 | } catch (NotAuthorizedException $e) { |
|
73 | $response->setContent($e->getMessage()); |
|
74 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
75 | } catch (NotFoundException $e) { |
|
76 | $response->setContent($e->getMessage()); |
|
77 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
78 | } |
|
79 | ||
80 | return $response; |
|
81 | } |
|
82 | ||
83 | /** |
|
84 | * Returns daily forecast by geographic coordinates. |
|
@@ 92-108 (lines=17) @@ | ||
89 | * |
|
90 | * @return \Symfony\Component\HttpFoundation\Response |
|
91 | */ |
|
92 | public function getForecastByCityGeographicCoordinates($latitude, $longitude, $numberOfDays = 16) |
|
93 | { |
|
94 | $response = new Response(); |
|
95 | ||
96 | try { |
|
97 | $data = $this->dailyForecast->fetchForecastByCityGeographicCoordinates($latitude, $longitude, $numberOfDays); |
|
98 | $response->setContent($data); |
|
99 | } catch (NotAuthorizedException $e) { |
|
100 | $response->setContent($e->getMessage()); |
|
101 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
102 | } catch (NotFoundException $e) { |
|
103 | $response->setContent($e->getMessage()); |
|
104 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
105 | } |
|
106 | ||
107 | return $response; |
|
108 | } |
|
109 | } |
|
110 |
@@ 38-54 (lines=17) @@ | ||
35 | * |
|
36 | * @return \Symfony\Component\HttpFoundation\Response |
|
37 | */ |
|
38 | public function getForecastByCityName($cityName, $countryCode = '') |
|
39 | { |
|
40 | $response = new Response(); |
|
41 | ||
42 | try { |
|
43 | $data = $this->hourForecast->fetchForecastByCityName($cityName, $countryCode); |
|
44 | $response->setContent($data); |
|
45 | } catch (NotAuthorizedException $e) { |
|
46 | $response->setContent($e->getMessage()); |
|
47 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
48 | } catch (NotFoundException $e) { |
|
49 | $response->setContent($e->getMessage()); |
|
50 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
51 | } |
|
52 | ||
53 | return $response; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * Returns hour forecast by city id. |
|
@@ 63-79 (lines=17) @@ | ||
60 | * |
|
61 | * @return \Symfony\Component\HttpFoundation\Response |
|
62 | */ |
|
63 | public function getForecastByCityId($cityId) |
|
64 | { |
|
65 | $response = new Response(); |
|
66 | ||
67 | try { |
|
68 | $data = $this->hourForecast->fetchForecastByCityId($cityId); |
|
69 | $response->setContent($data); |
|
70 | } catch (NotAuthorizedException $e) { |
|
71 | $response->setContent($e->getMessage()); |
|
72 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
73 | } catch (NotFoundException $e) { |
|
74 | $response->setContent($e->getMessage()); |
|
75 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
76 | } |
|
77 | ||
78 | return $response; |
|
79 | } |
|
80 | ||
81 | /** |
|
82 | * Returns hour forecast by geographic coordinates. |
|
@@ 89-105 (lines=17) @@ | ||
86 | * |
|
87 | * @return \Symfony\Component\HttpFoundation\Response |
|
88 | */ |
|
89 | public function getForecastByCityGeographicCoordinates($latitude, $longitude) |
|
90 | { |
|
91 | $response = new Response(); |
|
92 | ||
93 | try { |
|
94 | $data = $this->hourForecast->fetchForecastByCityGeographicCoordinates($latitude, $longitude); |
|
95 | $response->setContent($data); |
|
96 | } catch (NotAuthorizedException $e) { |
|
97 | $response->setContent($e->getMessage()); |
|
98 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
99 | } catch (NotFoundException $e) { |
|
100 | $response->setContent($e->getMessage()); |
|
101 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
102 | } |
|
103 | ||
104 | return $response; |
|
105 | } |
|
106 | } |
|
107 |
@@ 39-55 (lines=17) @@ | ||
36 | * |
|
37 | * @return \Symfony\Component\HttpFoundation\Response |
|
38 | */ |
|
39 | public function byGeographicCoordinates($latitude, $longitude) |
|
40 | { |
|
41 | $response = new Response(); |
|
42 | ||
43 | try { |
|
44 | $data = $this->weather->fetchWeatherDataByGeographicCoordinates($latitude, $longitude); |
|
45 | $response->setContent($data); |
|
46 | } catch (NotAuthorizedException $e) { |
|
47 | $response->setContent($e->getMessage()); |
|
48 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
49 | } catch (NotFoundException $e) { |
|
50 | $response->setContent($e->getMessage()); |
|
51 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
52 | } |
|
53 | ||
54 | return $response; |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * Returns weather data by city name. |
|
@@ 65-81 (lines=17) @@ | ||
62 | * |
|
63 | * @return \Symfony\Component\HttpFoundation\Response |
|
64 | */ |
|
65 | public function byCityName($cityName, $countryCode = '') |
|
66 | { |
|
67 | $response = new Response(); |
|
68 | ||
69 | try { |
|
70 | $data = $this->weather->fetchWeatherDataByCityName($cityName, $countryCode); |
|
71 | $response->setContent($data); |
|
72 | } catch (NotAuthorizedException $e) { |
|
73 | $response->setContent($e->getMessage()); |
|
74 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
75 | } catch (NotFoundException $e) { |
|
76 | $response->setContent($e->getMessage()); |
|
77 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
78 | } |
|
79 | ||
80 | return $response; |
|
81 | } |
|
82 | ||
83 | /** |
|
84 | * Returns weather data by city id. |
|
@@ 90-106 (lines=17) @@ | ||
87 | * |
|
88 | * @return \Symfony\Component\HttpFoundation\Response |
|
89 | */ |
|
90 | public function byCityId($cityId) |
|
91 | { |
|
92 | $response = new Response(); |
|
93 | ||
94 | try { |
|
95 | $data = $this->weather->fetchWeatherDataByCityId($cityId); |
|
96 | $response->setContent($data); |
|
97 | } catch (NotAuthorizedException $e) { |
|
98 | $response->setContent($e->getMessage()); |
|
99 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
100 | } catch (NotFoundException $e) { |
|
101 | $response->setContent($e->getMessage()); |
|
102 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
103 | } |
|
104 | ||
105 | return $response; |
|
106 | } |
|
107 | ||
108 | /** |
|
109 | * Returns weather data by zip code. |
|
@@ 116-132 (lines=17) @@ | ||
113 | * |
|
114 | * @return \Symfony\Component\HttpFoundation\Response |
|
115 | */ |
|
116 | public function byZipCode($zipCode, $countryCode = '') |
|
117 | { |
|
118 | $response = new Response(); |
|
119 | ||
120 | try { |
|
121 | $data = $this->weather->fetchWeatherDataByZipCode($zipCode, $countryCode); |
|
122 | $response->setContent($data); |
|
123 | } catch (NotAuthorizedException $e) { |
|
124 | $response->setContent($e->getMessage()); |
|
125 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
126 | } catch (NotFoundException $e) { |
|
127 | $response->setContent($e->getMessage()); |
|
128 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
129 | } |
|
130 | ||
131 | return $response; |
|
132 | } |
|
133 | ||
134 | /** |
|
135 | * Returns weather data for cities in rectangle zone. |
|
@@ 176-192 (lines=17) @@ | ||
173 | * |
|
174 | * @return \Symfony\Component\HttpFoundation\Response |
|
175 | */ |
|
176 | public function byCircle($latitude, $longitude, $cluster = 'yes', $numberOfCities = 10) |
|
177 | { |
|
178 | $response = new Response(); |
|
179 | ||
180 | try { |
|
181 | $data = $this->weather->fetchWeatherDataForCitiesInCycle($latitude, $longitude, $cluster, $numberOfCities); |
|
182 | $response->setContent($data); |
|
183 | } catch (NotAuthorizedException $e) { |
|
184 | $response->setContent($e->getMessage()); |
|
185 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
186 | } catch (NotFoundException $e) { |
|
187 | $response->setContent($e->getMessage()); |
|
188 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
189 | } |
|
190 | ||
191 | return $response; |
|
192 | } |
|
193 | ||
194 | /** |
|
195 | * Returns weather data by several city ids. |
@@ 37-53 (lines=17) @@ | ||
34 | * |
|
35 | * @return \Symfony\Component\HttpFoundation\Response |
|
36 | */ |
|
37 | public function getFromOnStationById($stationId) |
|
38 | { |
|
39 | $response = new Response(); |
|
40 | ||
41 | try { |
|
42 | $data = $this->weatherStations->fetchFromOnStationById($stationId); |
|
43 | $response->setContent($data); |
|
44 | } catch (NotAuthorizedException $e) { |
|
45 | $response->setContent($e->getMessage()); |
|
46 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
47 | } catch (NotFoundException $e) { |
|
48 | $response->setContent($e->getMessage()); |
|
49 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
50 | } |
|
51 | ||
52 | return $response; |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * Returns data from several stations by rectangle zone. |
|
@@ 99-115 (lines=17) @@ | ||
96 | * |
|
97 | * @return \Symfony\Component\HttpFoundation\Response |
|
98 | */ |
|
99 | public function getFromSeveralByGeoPoint($latitude, $longitude, $numberOfStations = 10) |
|
100 | { |
|
101 | $response = new Response(); |
|
102 | ||
103 | try { |
|
104 | $data = $this->weatherStations->fetchFromSeveralByGeoPoint($latitude, $longitude, $numberOfStations); |
|
105 | $response->setContent($data); |
|
106 | } catch (NotAuthorizedException $e) { |
|
107 | $response->setContent($e->getMessage()); |
|
108 | $response->setStatusCode(Response::HTTP_UNAUTHORIZED); |
|
109 | } catch (NotFoundException $e) { |
|
110 | $response->setContent($e->getMessage()); |
|
111 | $response->setStatusCode(Response::HTTP_NOT_FOUND); |
|
112 | } |
|
113 | ||
114 | return $response; |
|
115 | } |
|
116 | } |
|
117 |