diff --git a/routes/asmaAlHusna/asmaAlHusna.php b/routes/asmaAlHusna/archive/asmaAlHusna.php
similarity index 100%
rename from routes/asmaAlHusna/asmaAlHusna.php
rename to routes/asmaAlHusna/archive/asmaAlHusna.php
diff --git a/routes/asmaAlHusna/v1/apidoc.json b/routes/asmaAlHusna/v1/apidoc.json
new file mode 100644
index 0000000..a962c8d
--- /dev/null
+++ b/routes/asmaAlHusna/v1/apidoc.json
@@ -0,0 +1,6 @@
+{
+ "name": "Asma al Husna API by AlAdhan",
+ "version": "1.0.1",
+ "description": "A REST API (over HTTP and HTTPS) providing programmatic access to the 99 Islamic names of God"
+
+}
diff --git a/routes/asmaAlHusna/v1/asmaAlHusna.php b/routes/asmaAlHusna/v1/asmaAlHusna.php
new file mode 100644
index 0000000..6292d08
--- /dev/null
+++ b/routes/asmaAlHusna/v1/asmaAlHusna.php
@@ -0,0 +1,127 @@
+group('/v1', function() {
+ /**
+ *
+ * @api {get} http://api.aladhan.com/v1/asmaAlHusna/:numbers All or Multiple Names
+ * @apiName GetMultiAsmaAlHusna
+ * @apiDescription Includes the Arabic text with transliteration and meaning of each name.
+ * @apiGroup AsmaAlHusna
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string{number{1-99},number{1-99},number{1-99}}} [numbers] Names are numbered from 1 to 99, in the order usually recited
+ * in the Islamic tradition. They start with 1 (Ar Rahmaan) and end with 99 (As
+ * Saboor). If not specified, all names will be returned.
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/asmaAlHusna/1,2
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * code: 200,
+ * status: "OK",
+ * data: [
+ * {
+ * name: "الرَّحْمَنُ",
+ * transliteration: "Ar Rahmaan",
+ * number: 1,
+ * en: {
+ * meaning: "The Beneficent"
+ * }
+ * },
+ * {
+ * name: "الرَّحِيمُ",
+ * transliteration: "Ar Raheem",
+ * number: 2,
+ * en: {
+ * meaning: "The Merciful"
+ * }
+ * }
+ * ...
+ * ]
+ * }
+ *
+ * @apiError InvalidNumber Number must be between 1 and 99.
+ *
+ * @apiErrorExample Error-Response:
+ * HTTP/1.1 404 Not Found
+ * {
+ * "code": 400,
+ * "status": "Bad Request",
+ * "data": "Please specify a valid number between 1 and 99."
+ * }
+ */
+ $app->get('/asmaAlHusna', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $names = AsmaAlHusna::get();
+
+ return $response->withJson(ApiResponse::build($names, 200, 'OK'), 200);
+
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/asmaAlHusna/:number Single Name.
+ * @apiDescription Includes the Arabic text with transliteration and meaning.
+ * @apiName GetAsmaAlHusna
+ * @apiGroup AsmaAlHusna
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {number{1-99}} number Names are numbered from 1 to 99, in the order usually recited
+ * in the Islamic tradition. They start with 1 (Ar Rahmaan) and end with 99 (As
+ * Saboor).
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/asmaAlHusna/77
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * code: 200,
+ * status: "OK",
+ * data: [
+ * {
+ * name: "الْوَالِي",
+ * transliteration: "Al Waali",
+ * number: 77,
+ * en: {
+ * meaning: "The Governor"
+ * }
+ * }
+ * ]
+ * }
+ *
+ * @apiError InvalidNumber Number must be between 1 and 99.
+ *
+ * @apiErrorExample Error-Response:
+ * HTTP/1.1 404 Not Found
+ * {
+ * "code": 400,
+ * "status": "Bad Request",
+ * "data": "Please specify a valid number between 1 and 99."
+ * }
+ */
+ $app->get('/asmaAlHusna/{no}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $number = $request->getAttribute('no');
+ $number = explode(',', $number);
+ $nos = [];
+ foreach ($number as $no) {
+ $nos[] = (int) $no;
+ }
+ $names = AsmaAlHusna::get($nos);
+
+ if ($names == false) {
+ return $response->withJson(ApiResponse::build('Please specify a valid number between 1 and 99', 400, 'Bad Request'), 400);
+ }
+
+ return $response->withJson(ApiResponse::build($names, 200, 'OK'), 200);
+
+ });
+});
diff --git a/routes/hijri/hijriCalendar.php b/routes/hijri/archive/hijriCalendar.php
similarity index 100%
rename from routes/hijri/hijriCalendar.php
rename to routes/hijri/archive/hijriCalendar.php
diff --git a/routes/hijri/apidoc.json b/routes/hijri/v1/apidoc.json
similarity index 100%
rename from routes/hijri/apidoc.json
rename to routes/hijri/v1/apidoc.json
diff --git a/routes/hijri/v1/hijriCalendar.php b/routes/hijri/v1/hijriCalendar.php
new file mode 100644
index 0000000..f3d3119
--- /dev/null
+++ b/routes/hijri/v1/hijriCalendar.php
@@ -0,0 +1,372 @@
+group('/v1', function() {
+ /**
+ * @api {get} http://api.aladhan.com/v1/gToHCalendar/:month/:year Request a Hijri Calendar for a Gregorian month
+ * @apiName GetGToHCalendar
+ * @apiDescription Request a Hijri Calendar for a Gregorian month
+ * @apiGroup IslamicCalendar
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {number{1-12}} month A gregorian month. 1 = January and 12 = December.
+ * @apiParam {number} year A gregorian year. Example: 2015
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/gToHCalendar/8/2016
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * code: 200,
+ * status: "OK",
+ * data: [
+ * {
+ * gregorian: {
+ * date: "01-12-2578",
+ * format: "DD-MM-YYYY",
+ * day: "01",
+ * weekday: {
+ * en: "Tuesday"
+ * },
+ * month: {
+ * number: 12,
+ * en: "December"
+ * },
+ * year: "2578",
+ * designation: {
+ * abbreviated: "AD",
+ * expanded: "Anno Domini"
+ * }
+ * },
+ * hijri: {
+ * date: "01-06-2017",
+ * format: "DD-MM-YYYY",
+ * day: "01",
+ * weekday: {
+ * en: "Al Thalaata",
+ * ar: "الثلاثاء"
+ * },
+ * month: {
+ * number: 6,
+ * en: "Jumādá al-ākhirah",
+ * ar: "جُمادى الآخرة"
+ * },
+ * year: "2017",
+ * designation: {
+ * abbreviated: "AH",
+ * expanded: "Anno Hegirae"
+ * },
+ * holidays: [ ]
+ * }
+ * },
+ *
+ * ... more days
+ *
+ * ]
+ * }
+ */
+ $app->get('/gToHCalendar/{month}/{year}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $cs = new HijriCalendarService();
+
+ $y = (int) $request->getAttribute('year');
+ $m = (int) $request->getAttribute('month');
+
+
+ return $response->withJson(ApiResponse::build($cs->getGToHCalendar($m, $y), 200, 'OK'), 200);
+ });
+
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/hToGCalendar/:month/:year Request a Gregoran Calendar for a Hijri month
+ * @apiName GetHToGCalendar
+ * @apiDescription Request a Gregoran Calendar for a Hijri month
+ * @apiGroup IslamicCalendar
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {number{1-12}} month A Hijri month. 1 = Muharram and 12 = Dhu al Hijjah.
+ * @apiParam {number} year A hijri year. Example: 1437
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/gToHCalendar/3/1438
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * code: 200,
+ * status: "OK",
+ * data: [
+ * {
+ * gregorian: {
+ * date: "01-12-2578",
+ * format: "DD-MM-YYYY",
+ * day: "01",
+ * weekday: {
+ * en: "Tuesday"
+ * },
+ * month: {
+ * number: 12,
+ * en: "December"
+ * },
+ * year: "2578",
+ * designation: {
+ * abbreviated: "AD",
+ * expanded: "Anno Domini"
+ * }
+ * },
+ * hijri: {
+ * date: "01-06-2017",
+ * format: "DD-MM-YYYY",
+ * day: "01",
+ * weekday: {
+ * en: "Al Thalaata",
+ * ar: "الثلاثاء"
+ * },
+ * month: {
+ * number: 6,
+ * en: "Jumādá al-ākhirah",
+ * ar: "جُمادى الآخرة"
+ * },
+ * year: "2017",
+ * designation: {
+ * abbreviated: "AH",
+ * expanded: "Anno Hegirae"
+ * },
+ * holidays: [ ]
+ * }
+ * },
+ *
+ * ... more days
+ *
+ * ]
+ * }
+ */
+ $app->get('/hToGCalendar/{month}/{year}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $cs = new HijriCalendarService();
+
+ $y = (int) $request->getAttribute('year');
+ $m = (int) $request->getAttribute('month');
+
+ return $response->withJson(ApiResponse::build($cs->getHtoGCalendar($m, $y), 200, 'OK'), 200);
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/gToH Convert a Gregorian date to a Hijri date
+ * @apiName GetGToH
+ * @apiDescription Convert a Gregorian date to a Hijri date
+ * @apiGroup IslamicCalendar
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} date A gregorian date formatted as DD-MM-YYYY
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/gToH?date=07-12-2014
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * {
+ * code: 200,
+ * status: "OK",
+ * data: {
+ * hijri: {
+ * date: "14-02-1436",
+ * format: "DD-MM-YYYY",
+ * day: "14",
+ * month: {
+ * number: 2,
+ * en: "Ṣafar",
+ * ar: "صَفَر"
+ * },
+ * year: "1436",
+ * designation: {
+ * abbreviated: "AH",
+ * expanded: "Anno Hegirae"
+ * }
+ * },
+ * gregorian: {
+ * date: "07-12-2014",
+ * format: "DD-MM-YYYY",
+ * day: "07",
+ * month: {
+ * number: 12,
+ * en: "December"
+ * },
+ * year: "2014",
+ * designation: {
+ * abbreviated: "AD",
+ * expanded: "Anno Domini"
+ * }
+ * }
+ * }
+ * }
+ * }
+ */
+ $app->get('/gToH', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $date = $request->getQueryParam('date') == '' || null ? date('d-m-Y', time()) : $request->getQueryParam('date');
+ $hs = new HijriCalendarService();
+ $result = $hs->gToH($date);
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Invalid date or unable to convert it', 400, 'Bad Request'), 400);
+ }
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/hToG Convert a Hijri date to a Gregorian date
+ * @apiName GetHToG
+ * @apiDescription Convert a Hijri date to a Gregorian date
+ * @apiGroup IslamicCalendar
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} date A hijri date formatted as DD-MM-YYYY
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/gToH?date=14-02-1436
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * {
+ * code: 200,
+ * status: "OK",
+ * data: {
+ * hijri: {
+ * date: "14-02-1436",
+ * format: "DD-MM-YYYY",
+ * day: "14",
+ * month: {
+ * number: 2,
+ * en: "Ṣafar",
+ * ar: "صَفَر"
+ * },
+ * year: "1436",
+ * designation: {
+ * abbreviated: "AH",
+ * expanded: "Anno Hegirae"
+ * }
+ * },
+ * gregorian: {
+ * date: "07-12-2014",
+ * format: "DD-MM-YYYY",
+ * day: "07",
+ * month: {
+ * number: 12,
+ * en: "December"
+ * },
+ * year: "2014",
+ * designation: {
+ * abbreviated: "AD",
+ * expanded: "Anno Domini"
+ * }
+ * }
+ * }
+ * }
+ * }
+ */
+ $app->get('/hToG', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $hs = new HijriCalendarService();
+ if ($request->getQueryParam('date') == '' || null) {
+ $date = date('d-m-Y', time());
+ $fs = $hs->gToH($date);
+ $date = $fs['hijri']['date'];
+ } else {
+ $date = $request->getQueryParam('date');
+ }
+ $result = $hs->hToG($date);
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Invalid date or unable to convert it.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/nextHijriHoliday', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $hs = new HijriCalendarService();
+ $result = $hs->nextHijriHoliday();;
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to compute next holiday.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/currentIslamicYear', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $hs = new HijriCalendarService();
+ $result = $hs->getCurrentIslamicYear();
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to compute year.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/currentIslamicMonth', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $hs = new HijriCalendarService();
+ $result = $hs->getCurrentIslamicMonth();
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to compute year.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/islamicYearFromGregorianForRamadan/{year}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $y = (int) $request->getAttribute('year');
+ $hs = new HijriCalendarService();
+ $result = $hs->getIslamicYearFromGregorianForRamadan($y);
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to compute year.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/hijriHolidays/{day}/{month}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $d = (int) $request->getAttribute('day');
+ $m = (int) $request->getAttribute('month');
+ $hs = new HijriCalendarService();
+ $result = $hs->getHijriHolidays($d, $m);
+ if ($result !== false) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Please specify a valid day and month. Example, 23 and 11.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/specialDays', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $hs = new HijriCalendarService();
+ $result = $hs->specialDays();
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Something went wrong. Please try again later. Sorry.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/islamicMonths', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $hs = new HijriCalendarService();
+ $result = $hs->getIslamicMonths();
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Something went wrong. Please try again later. Sorry.', 400, 'Bad Request'), 400);
+ }
+ });
+});
diff --git a/routes/timings/dateAndTime.php b/routes/timings/archive/dateAndTime.php
similarity index 100%
rename from routes/timings/dateAndTime.php
rename to routes/timings/archive/dateAndTime.php
diff --git a/routes/timings/prayerTimes.php b/routes/timings/archive/prayerTimes.php
similarity index 100%
rename from routes/timings/prayerTimes.php
rename to routes/timings/archive/prayerTimes.php
diff --git a/routes/timings/apidoc.json b/routes/timings/v1/apidoc.json
similarity index 100%
rename from routes/timings/apidoc.json
rename to routes/timings/v1/apidoc.json
diff --git a/routes/timings/v1/dateAndTime.php b/routes/timings/v1/dateAndTime.php
new file mode 100644
index 0000000..45b52f6
--- /dev/null
+++ b/routes/timings/v1/dateAndTime.php
@@ -0,0 +1,102 @@
+group('/v1', function() {
+ /**
+ * @api {get} http://api.aladhan.com/v1/currentTime Current Time
+ * @apiDescription Returns the current time (in the HH:MM format) for the specified time zone
+ * @apiName GetCurrentTime
+ * @apiGroup DateAndTime
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} zone A valid timezone name as specified on http://php.net/manual/en/timezones.php<. Example: Europe/London
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/currentTime?zone=Europe/London
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": "13:56"
+ * }
+ */
+ $app->get('/currentTime', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $zone = $request->getQueryParam('zone');
+ if ($zone == '' || $zone == null || !Generic::isTimeZoneValid($zone)) {
+ return $response->withJson(ApiResponse::build('Please specify a valid timezone. Example: Europe/London', 400, 'Bad Request'), 400);
+ } else {
+ $date = new DateTime('now', new DateTimeZone($zone));
+ return $response->withJson(ApiResponse::build($date->format('H:i'), 200, 'OK'), 200);
+ }
+
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/currentDate Current Date
+ * @apiDescription Returns the current date (in the DD-MM-YYYY format) for the specified time zone
+ * @apiName GetCurrentDate
+ * @apiGroup DateAndTime
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} zone A valid timezone name as specified on http://php.net/manual/en/timezones.php<. Example: Europe/London
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/currentDate?zone=Europe/London
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": "23-08-2017"
+ * }
+ */
+ $app->get('/currentDate', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $zone = $request->getQueryParam('zone');
+ if ($zone == '' || $zone == null || !Generic::isTimeZoneValid($zone)) {
+ return $response->withJson(ApiResponse::build('Please specify a valid timezone. Example: Europe/London', 400, 'Bad Request'), 400);
+ } else {
+ $date = new DateTime('now', new DateTimeZone($zone));
+ return $response->withJson(ApiResponse::build($date->format('d-m-Y'), 200, 'OK'), 200);
+ }
+
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/currentTimestamp Current Timestamp
+ * @apiDescription Returns the current UNIX timestamp for the specified time zone
+ * @apiName GetCurrentTimestamp
+ * @apiGroup DateAndTime
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} zone A valid timezone name as specified on http://php.net/manual/en/timezones.php<. Example: Europe/London
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/currentTimestamp?zone=Europe/London
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": "1503495668"
+ * }
+ */
+ $app->get('/currentTimestamp', function (Request $request, Response $response) {
+ $zone = $request->getQueryParam('zone');
+ if ($zone == '' || $zone == null || !Generic::isTimeZoneValid($zone)) {
+ return $response->withJson(ApiResponse::build('Please specify a valid timezone. Example: Europe/London', 400, 'Bad Request'), 400);
+ } else {
+ $date = new DateTime('now', new DateTimeZone($zone));
+ return $response->withJson(ApiResponse::build($date->format('U'), 200, 'OK'), 200);
+ }
+ });
+});
diff --git a/routes/timings/v1/prayerTimes.php b/routes/timings/v1/prayerTimes.php
new file mode 100644
index 0000000..6ab4029
--- /dev/null
+++ b/routes/timings/v1/prayerTimes.php
@@ -0,0 +1,1131 @@
+group('/v1', function() {
+ /**
+ * @api {get} http://api.aladhan.com/v1/methods Prayer Times Methods
+ * @apiDescription Returns all the prayer times calculation methods supported by this API. For more information on how to use custom methods, see https://aladhan.com/calculation-methods.
+ * @apiName GetMethods
+ * @apiGroup Miscellaneous
+ * @apiVersion 1.0.1
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/methods
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": {
+ * "MWL": {
+ * "id": 3,
+ * "name": "Muslim World League",
+ * "params": {
+ * "Fajr": 18,
+ * "Isha": 17
+ * }
+ * },
+ * "ISNA": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * .... More methods
+ * "CUSTOM": {
+ * "id": 99
+ * }
+ * }
+ * }
+ *
+ **/
+ $app->get('/methods', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $pt = new PrayerTimes();
+
+ return $response->withJson(ApiResponse::build($pt->getMethods(), 200, 'OK'), 200);
+ });
+
+ $app->get('/nextPrayerByAddress', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $address = $request->getQueryParam('address');
+ $locInfo = $this->model->locations->getAddressCoOrdinatesAndZone($address);
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if ($locInfo) {
+ $pt = new PrayerTimes($method, $school, null);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ $d = new DateTime('@' . time());
+ $d->setTimezone(new DateTimeZone($locInfo['timezone']));
+ if ($pt->getMethod() == 'MAKKAH' && PrayerTimesHelper::isRamadan($d)) {
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], '30 min', $tune[8]);
+ }
+ $timings = $pt->getTimes($d, $locInfo['latitude'], $locInfo['longitude'], null, $latitudeAdjustmentMethod);
+ $nextPrayer = PrayerTimesHelper::nextPrayerTime($timings, $pt, $d, $locInfo, $latitudeAdjustmentMethod);
+ $date = ['readable' => $d->format('d M Y'), 'timestamp' => $d->format('U')];
+ return $response->withJson(ApiResponse::build(['timings' => $nextPrayer, 'date' => $date, 'meta' => PrayerTimesHelper::getMetaArray($pt)], 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to locate address (even via google geocoding). It is probably invalid!', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/nextPrayerByAddress/{timestamp}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $timestamp = ApiRequest::time($request->getAttribute('timestamp'));
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $address = $request->getQueryParam('address');
+ $locInfo = $this->model->locations->getAddressCoOrdinatesAndZone($address);
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if ($locInfo) {
+ $pt = new PrayerTimes($method, $school, null);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ $d = new DateTime(date('@' . $timestamp));
+ $d->setTimezone(new DateTimeZone($locInfo['timezone']));
+ if ($pt->getMethod() == 'MAKKAH' && PrayerTimesHelper::isRamadan($d)) {
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], '30 min', $tune[8]);
+ }
+ $timings = $pt->getTimes($d, $locInfo['latitude'], $locInfo['longitude'], null, $latitudeAdjustmentMethod);
+ $nextPrayer = PrayerTimesHelper::nextPrayerTime($timings, $pt, $d, $locInfo, $latitudeAdjustmentMethod);
+ $date = ['readable' => $d->format('d M Y'), 'timestamp' => $d->format('U')];
+ return $response->withJson(ApiResponse::build(['timings' => $nextPrayer, 'date' => $date, 'meta' => PrayerTimesHelper::getMetaArray($pt)], 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to locate address (even via google geocoding). It is probably invalid!', 400, 'Bad Request'), 400);
+ }
+ });
+
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/timings/:date_or_timestamp Timings
+ * @apiDescription Returns all prayer times for a specific date.
+ * @apiName GetTimings
+ * @apiGroup Timings
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} [date_or_timestamp = 'now'] A date in the DD-MM-YYYY format or UNIX timestamp. Default's to the current date.
+ * @apiParam {decimal} latitude The decimal value for the latitude co-ordinate of the location you want the time computed for. Example: 51.75865125
+ * @apiParam {decimal} longitude The decimal value for the longitude co-ordinate of the location you want the time computed for. Example: -1.25387785
+ * @apiParam {number=0,1,2,3,4,5,7,8,9,10,11,12,13,99} [method=2] A prayer times calculation method. Methods identify various schools of thought about how to compute the timings. This parameter accepts values from 0-12 and 99, as specified below:
+ * 0 - Shia Ithna-Ansari
+ * 1 - Muslim World League
+ * 2 - Islamic Society of North America
+ * 3 - Egyptian General Authority of Survey
+ * 4 - Umm Al-Qura University, Makkah
+ * 5 - University of Islamic Sciences, Karachi
+ * 7 - Institute of Geophysics, University of Tehran
+ * 8 - Gulf Region
+ * 9 - Kuwait
+ * 10 - Qatar
+ * 11 - Majlis Ugama Islam Singapura, Singapore
+ * 12 - Union Organization islamic de France
+ * 13 - Diyanet İşleri Başkanlığı, Turkey
+ * @apiParam {number{0-1}} [school = 0] 0 for Shafi (or the standard way), 1 for Hanafi. If you leave this empty, it defaults to Shafii.
+ * @apiParam {string} [timezonestring] A valid timezone name as specified on http://php.net/manual/en/timezones.php . Example: Europe/London. If you do not specify this, we'll calcuate it using the co-ordinates you provide.
+ * @apiParam {number} [latitudeAdjustmentMethod=3] Method for adjusting times higher latitudes - for instance, if you are checking timings in the UK or Sweden.
+ * 1 - Middle of the Night
+ * 2 - One Seventh
+ * 3 - Angle Based
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/timings/1398332113?latitude=51.508515&longitude=-0.1254872&method=2
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": {
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * }
+ * }
+ */
+ $app->get('/timings', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $latitude = $request->getQueryParam('latitude');
+ $longitude = $request->getQueryParam('longitude');
+ $timezone = Generic::computeTimezone($latitude, $longitude, $request->getQueryParam('timezonestring'), $this->model->locations);
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if (ApiRequest::isTimingsRequestValid($latitude, $longitude, $timezone)) {
+ $pt = new PrayerTimes($method, $school, null);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ $d = new DateTime('now', new DateTimeZone($timezone));
+ if ($pt->getMethod() == 'MAKKAH' && PrayerTimesHelper::isRamadan($d)) {
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], '30 min', $tune[8]);
+ }
+ $timings = $pt->getTimesForToday($latitude, $longitude, $timezone, null, $latitudeAdjustmentMethod);
+ $date = ['readable' => $d->format('d M Y'), 'timestamp' => $d->format('U')];
+ return $response->withJson(ApiResponse::build(['timings' => $timings, 'date' => $date, 'meta' => PrayerTimesHelper::getMetaArray($pt)], 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Please specify a valid latitude and longitude.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/timings/{timestamp}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $timestamp = ApiRequest::time($request->getAttribute('timestamp'));
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $latitude = $request->getQueryParam('latitude');
+ $longitude = $request->getQueryParam('longitude');
+ $timezone = Generic::computeTimezone($latitude, $longitude, $request->getQueryParam('timezonestring'), $this->model->locations);
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if (ApiRequest::isTimingsRequestValid($latitude, $longitude, $timezone)) {
+ $pt = new PrayerTimes($method, $school);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ $d = new DateTime(date('@' . $timestamp));
+ $d->setTimezone(new DateTimeZone($timezone));
+ if ($pt->getMethod() == 'MAKKAH' && PrayerTimesHelper::isRamadan($d)) {
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], '30 min', $tune[8]);
+ }
+ $date = ['readable' => $d->format('d M Y'), 'timestamp' => $d->format('U')];
+ $timings = $pt->getTimes($d, $latitude, $longitude, null, $latitudeAdjustmentMethod);
+ return $response->withJson(ApiResponse::build(['timings' => $timings, 'date' => $date, 'meta' => PrayerTimesHelper::getMetaArray($pt)], 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Please specify a valid latitude and longitude.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1//timingsByAddress/:date_or_timestamp Timings By Address
+ * @apiDescription Returns all prayer times for a specific date at a particular address.
+ * @apiName GetTimingsByAddresss
+ * @apiGroup Timings
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} [date_or_timestamp = 'now'] A date in the DD-MM-YYYY format or UNIX timestamp. Default's to the current date.
+ * @apiParam {string} address An address string. Example: 1420 Austin Bluffs Parkway, Colorado Springs, CO OR 25 Hampstead High Street, London, NW3 1RL, United Kingdom OR Sultanahmet Mosque, Istanbul, Turkey
+ * @apiParam {number=0,1,2,3,4,5,7,8,9,10,11,12,13,99} [method=2] A prayer times calculation method. Methods identify various schools of thought about how to compute the timings. This parameter accepts values from 0-12 and 99, as specified below:
+ * 0 - Shia Ithna-Ansari
+ * 1 - Muslim World League
+ * 2 - Islamic Society of North America
+ * 3 - Egyptian General Authority of Survey
+ * 4 - Umm Al-Qura University, Makkah
+ * 5 - University of Islamic Sciences, Karachi
+ * 7 - Institute of Geophysics, University of Tehran
+ * 8 - Gulf Region
+ * 9 - Kuwait
+ * 10 - Qatar
+ * 11 - Majlis Ugama Islam Singapura, Singapore
+ * 12 - Union Organization islamic de France
+ * 13 - Diyanet İşleri Başkanlığı, Turkey
+ * @apiParam {number{0-1}} [school = 0] 0 for Shafi (or the standard way), 1 for Hanafi. If you leave this empty, it defaults to Shafii.
+ * @apiParam {string} [timezonestring] A valid timezone name as specified on http://php.net/manual/en/timezones.php . Example: Europe/London. If you do not specify this, we'll calcuate it using the co-ordinates you provide.
+ * @apiParam {number} [latitudeAdjustmentMethod=3] Method for adjusting times higher latitudes - for instance, if you are checking timings in the UK or Sweden.
+ * 1 - Middle of the Night
+ * 2 - One Seventh
+ * 3 - Angle Based
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/timingsByAddress?address=Regents Park Mosque, London, UK
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": {
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * }
+ * }
+ */
+ $app->get('/timingsByAddress', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $address = $request->getQueryParam('address');
+ $locInfo = $this->model->locations->getAddressCoOrdinatesAndZone($address);
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if ($locInfo) {
+ $pt = new PrayerTimes($method, $school, null);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ $d = new DateTime('now', new DateTimeZone($locInfo['timezone']));
+ if ($pt->getMethod() == 'MAKKAH' && PrayerTimesHelper::isRamadan($d)) {
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], '30 min', $tune[8]);
+ }
+
+ $timings = $pt->getTimesForToday($locInfo['latitude'], $locInfo['longitude'],$locInfo['timezone'], null, $latitudeAdjustmentMethod);
+ $date = ['readable' => $d->format('d M Y'), 'timestamp' => $d->format('U')];
+ return $response->withJson(ApiResponse::build(['timings' => $timings, 'date' => $date, 'meta' => PrayerTimesHelper::getMetaArray($pt)], 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to locate address (even via google geocoding). It is probably invalid!', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/timingsByAddress/{timestamp}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $timestamp = ApiRequest::time($request->getAttribute('timestamp'));
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $address = $request->getQueryParam('address');
+ $locInfo = $this->model->locations->getAddressCoOrdinatesAndZone($address);
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if ($locInfo) {
+ $pt = new PrayerTimes($method, $school, null);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ $d = new DateTime(date('@' . $timestamp));
+ $d->setTimezone(new DateTimeZone($locInfo['timezone']));
+ if ($pt->getMethod() == 'MAKKAH' && PrayerTimesHelper::isRamadan($d)) {
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], '30 min', $tune[8]);
+ }
+ $timings = $pt->getTimes($d, $locInfo['latitude'], $locInfo['longitude'], null, $latitudeAdjustmentMethod);
+ $date = ['readable' => $d->format('d M Y'), 'timestamp' => $d->format('U')];
+ return $response->withJson(ApiResponse::build(['timings' => $timings, 'date' => $date, 'meta' => PrayerTimesHelper::getMetaArray($pt)], 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to locate address (even via google geocoding). It is probably invalid!', 400, 'Bad Request'), 400);
+ }
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/timingsByCity/:date_or_timestamp Timings By City
+ * @apiDescription Returns all prayer times for a specific date in a particular city.
+ * @apiName GetTimingsByCity
+ * @apiGroup Timings
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} [date_or_timestamp = 'now'] A date in the DD-MM-YYYY format or UNIX timestamp. Default's to the current date.
+ * @apiParam {string} city A city name. Example: London
+ * @apiParam {string} country A country name or 2 character alpha ISO 3166 code. Examples: GB or United Kindom
+ * @apiParam {string} [state] State or province. A state name or abbreviation. Examples: Colorado / CO / Punjab / Bengal
+ * @apiParam {number=0,1,2,3,4,5,7,8,9,10,11,12,13,99} [method=2] A prayer times calculation method. Methods identify various schools of thought about how to compute the timings. This parameter accepts values from 0-12 and 99, as specified below:
+ * 0 - Shia Ithna-Ansari
+ * 1 - Muslim World League
+ * 2 - Islamic Society of North America
+ * 3 - Egyptian General Authority of Survey
+ * 4 - Umm Al-Qura University, Makkah
+ * 5 - University of Islamic Sciences, Karachi
+ * 7 - Institute of Geophysics, University of Tehran
+ * 8 - Gulf Region
+ * 9 - Kuwait
+ * 10 - Qatar
+ * 11 - Majlis Ugama Islam Singapura, Singapore
+ * 12 - Union Organization islamic de France
+ * 13 - Diyanet İşleri Başkanlığı, Turkey
+ * @apiParam {number{0-1}} [school = 0] 0 for Shafi (or the standard way), 1 for Hanafi. If you leave this empty, it defaults to Shafii.
+ * @apiParam {string} [timezonestring] A valid timezone name as specified on http://php.net/manual/en/timezones.php . Example: Europe/London. If you do not specify this, we'll calcuate it using the co-ordinates you provide.
+ * @apiParam {number} [latitudeAdjustmentMethod=3] Method for adjusting times higher latitudes - for instance, if you are checking timings in the UK or Sweden.
+ * 1 - Middle of the Night
+ * 2 - One Seventh
+ * 3 - Angle Based
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/timingsByCity?city=Dubai&country=United Arab Emirates&method=8
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": {
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * }
+ * }
+ */
+ $app->get('/timingsByCity', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $city = $request->getQueryParam('city');
+ $country = $request->getQueryParam('country');
+ $state = $request->getQueryParam('state');
+ $locInfo = $this->model->locations->getGoogleCoOrdinatesAndZone($city, $country, $state);
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if ($locInfo) {
+ $pt = new PrayerTimes($method, $school, null);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ $d = new DateTime('now', new DateTimeZone($locInfo['timezone']));
+ if ($pt->getMethod() == 'MAKKAH' && PrayerTimesHelper::isRamadan($d)) {
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], '30 min', $tune[8]);
+ }
+ $timings = $pt->getTimesForToday($locInfo['latitude'], $locInfo['longitude'],$locInfo['timezone'], null, $latitudeAdjustmentMethod);
+ $date = ['readable' => $d->format('d M Y'), 'timestamp' => $d->format('U')];
+ return $response->withJson(ApiResponse::build(['timings' => $timings, 'date' => $date, 'meta' => PrayerTimesHelper::getMetaArray($pt)], 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to locate city and country (even via google geocoding). It is probably invalid!', 400, 'Bad Request'), 400);
+ }
+ });
+
+ $app->get('/timingsByCity/{timestamp}', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $timestamp = ApiRequest::time($request->getAttribute('timestamp'));
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $city = $request->getQueryParam('city');
+ $country = $request->getQueryParam('country');
+ $state = $request->getQueryParam('state');
+ $locInfo = $this->model->locations->getGoogleCoOrdinatesAndZone($city, $country, $state);
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if ($locInfo) {
+ $pt = new PrayerTimes($method, $school, null);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ $d = new DateTime(date('@' . $timestamp));
+ $d->setTimezone(new DateTimeZone($locInfo['timezone']));
+ if ($pt->getMethod() == 'MAKKAH' && PrayerTimesHelper::isRamadan($d)) {
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], '30 min', $tune[8]);
+ }
+ $timings = $pt->getTimes($d, $locInfo['latitude'], $locInfo['longitude'], null, $latitudeAdjustmentMethod);
+ $date = ['readable' => $d->format('d M Y'), 'timestamp' => $d->format('U')];
+ return $response->withJson(ApiResponse::build(['timings' => $timings, 'date' => $date, 'meta' => PrayerTimesHelper::getMetaArray($pt)], 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to locate city and country (even via google geocoding). It is probably invalid!', 400, 'Bad Request'), 400);
+ }
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/calendar Calendar
+ * @apiDescription Returns all prayer times for a specific calendar month.
+ * @apiName GetCalendar
+ * @apiGroup Calendar
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {decimal} latitude The decimal value for the latitude co-ordinate of the location you want the time computed for. Example: 51.75865125
+ * @apiParam {decimal} longitude The decimal value for the longitude co-ordinate of the location you want the time computed for. Example: -1.25387785
+ * @apiParam {number=1-12} month A gregorian calendar month. Example: 8 or 08 for August.
+ * @apiParam {number} year A gregorian calendar year. Example: 2014.
+ * @apiParam {boolean} [annual=false] If true, we'll ignore the month and return the calendar for the whole year.
+ * @apiParam {number=0,1,2,3,4,5,7,8,9,10,11,12,13,99} [method=2] A prayer times calculation method. Methods identify various schools of thought about how to compute the timings. This parameter accepts values from 0-12 and 99, as specified below:
+ * 0 - Shia Ithna-Ansari
+ * 1 - Muslim World League
+ * 2 - Islamic Society of North America
+ * 3 - Egyptian General Authority of Survey
+ * 4 - Umm Al-Qura University, Makkah
+ * 5 - University of Islamic Sciences, Karachi
+ * 7 - Institute of Geophysics, University of Tehran
+ * 8 - Gulf Region
+ * 9 - Kuwait
+ * 10 - Qatar
+ * 11 - Majlis Ugama Islam Singapura, Singapore
+ * 12 - Union Organization islamic de France
+ * 13 - Diyanet İşleri Başkanlığı, Turkey
+ * @apiParam {number{0-1}} [school = 0] 0 for Shafi (or the standard way), 1 for Hanafi. If you leave this empty, it defaults to Shafii.
+ * @apiParam {string} [timezonestring] A valid timezone name as specified on http://php.net/manual/en/timezones.php . Example: Europe/London. If you do not specify this, we'll calcuate it using the co-ordinates you provide.
+ * @apiParam {number} [latitudeAdjustmentMethod=3] Method for adjusting times higher latitudes - for instance, if you are checking timings in the UK or Sweden.
+ * 1 - Middle of the Night
+ * 2 - One Seventh
+ * 3 - Angle Based
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/calendar?latitude=51.508515&longitude=-0.1254872&method=2&month=4&year=2017
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": [{
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * },
+ * {
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * }
+ * ... // More data here till the end of the month
+ * ]
+ * }
+ */
+ $app->get('/calendar', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $month = ApiRequest::month($request->getQueryParam('month'));
+ $year = ApiRequest::year($request->getQueryParam('year'));
+ $latitude = $request->getQueryParam('latitude');
+ $longitude = $request->getQueryParam('longitude');
+ $annual = ApiRequest::annual($request->getQueryParam('annual'));
+ $timezone = $request->getQueryParam('timezonestring');
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+ if ($timezone == '' || $timezone === null) {
+ // Compute it.
+ $timezone = $this->model->locations->getTimezoneByCoOrdinates($latitude, $longitude);
+ }
+
+ if (ApiRequest::isCalendarRequestValid($latitude, $longitude, $timezone)) {
+ $pt = new PrayerTimes($method, $school);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ if ($annual) {
+ $times = PrayerTimesHelper::calculateYearPrayerTimes($latitude, $longitude, $year, $timezone, $latitudeAdjustmentMethod, $pt);
+ } else {
+ $times = PrayerTimesHelper::calculateMonthPrayerTimes($latitude, $longitude, $month, $year, $timezone, $latitudeAdjustmentMethod, $pt);
+ }
+ return $response->withJson(ApiResponse::build($times, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Please specify a valid latitude, longitude and timezone.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/calendarByAddress Calendar by address
+ * @apiDescription Returns all prayer times for a specific calendar month at a particular address.
+ * @apiName GetCalendarByAddress
+ * @apiGroup Calendar
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} address An address string. Example: 1420 Austin Bluffs Parkway, Colorado Springs, CO OR 25 Hampstead High Street, London, NW3 1RL, United Kingdom OR Sultanahmet Mosque, Istanbul, Turkey
+ * @apiParam {number=1-12} month A gregorian calendar month. Example: 8 or 08 for August.
+ * @apiParam {number} year A gregorian calendar year. Example: 2014.
+ * @apiParam {boolean} [annual=false] If true, we'll ignore the month and return the calendar for the whole year.
+ * @apiParam {number=0,1,2,3,4,5,7,8,9,10,11,12,13,99} [method=2] A prayer times calculation method. Methods identify various schools of thought about how to compute the timings. This parameter accepts values from 0-12 and 99, as specified below:
+ * 0 - Shia Ithna-Ansari
+ * 1 - Muslim World League
+ * 2 - Islamic Society of North America
+ * 3 - Egyptian General Authority of Survey
+ * 4 - Umm Al-Qura University, Makkah
+ * 5 - University of Islamic Sciences, Karachi
+ * 7 - Institute of Geophysics, University of Tehran
+ * 8 - Gulf Region
+ * 9 - Kuwait
+ * 10 - Qatar
+ * 11 - Majlis Ugama Islam Singapura, Singapore
+ * 12 - Union Organization islamic de France
+ * 13 - Diyanet İşleri Başkanlığı, Turkey
+ * @apiParam {number{0-1}} [school = 0] 0 for Shafi (or the standard way), 1 for Hanafi. If you leave this empty, it defaults to Shafii.
+ * @apiParam {string} [timezonestring] A valid timezone name as specified on http://php.net/manual/en/timezones.php . Example: Europe/London. If you do not specify this, we'll calcuate it using the co-ordinates you provide.
+ * @apiParam {number} [latitudeAdjustmentMethod=3] Method for adjusting times higher latitudes - for instance, if you are checking timings in the UK or Sweden.
+ * 1 - Middle of the Night
+ * 2 - One Seventh
+ * 3 - Angle Based
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/calendarByAddress?address=Sultanahmet Mosque, Istanbul, Turkey&method=2&month=04&year=2017
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": [{
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * },
+ * {
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * }
+ * ... // More data here till the end of the month
+ * ]
+ * }
+ */
+ $app->get('/calendarByAddress', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $month = ApiRequest::month($request->getQueryParam('month'));
+ $year = ApiRequest::year($request->getQueryParam('year'));
+ $address = $request->getQueryParam('address');
+ $locInfo = $this->model->locations->getAddressCoOrdinatesAndZone($address);
+ $annual = ApiRequest::annual($request->getQueryParam('annual'));
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+
+ if ($locInfo) {
+ $pt = new PrayerTimes($method, $school);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ if ($annual) {
+ $times = PrayerTimesHelper::calculateYearPrayerTimes($locInfo['latitude'], $locInfo['longitude'], $year, $locInfo['timezone'], $latitudeAdjustmentMethod, $pt);
+ } else {
+ $times = PrayerTimesHelper::calculateMonthPrayerTimes($locInfo['latitude'], $locInfo['longitude'], $month, $year, $locInfo['timezone'], $latitudeAdjustmentMethod, $pt);
+ }
+ return $response->withJson(ApiResponse::build($times, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Please specify a valid address.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/calendarByCity Calendar by City
+ * @apiDescription Returns all prayer times for a specific calendar month by City.
+ * @apiName GetCalendarByCitys
+ * @apiGroup Calendar
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} city A city name. Example: London
+ * @apiParam {string} country A country name or 2 character alpha ISO 3166 code. Examples: GB or United Kindom
+ * @apiParam {string} [state] State or province. A state name or abbreviation. Examples: Colorado / CO / Punjab / Bengal
+ * @apiParam {number=1-12} month A gregorian calendar month. Example: 8 or 08 for August.
+ * @apiParam {number} year A gregorian calendar year. Example: 2014.
+ * @apiParam {boolean} [annual=false] If true, we'll ignore the month and return the calendar for the whole year.
+ * @apiParam {number=0,1,2,3,4,5,7,8,9,10,11,12,13,99} [method=2] A prayer times calculation method. Methods identify various schools of thought about how to compute the timings. This parameter accepts values from 0-12 and 99, as specified below:
+ * 0 - Shia Ithna-Ansari
+ * 1 - Muslim World League
+ * 2 - Islamic Society of North America
+ * 3 - Egyptian General Authority of Survey
+ * 4 - Umm Al-Qura University, Makkah
+ * 5 - University of Islamic Sciences, Karachi
+ * 7 - Institute of Geophysics, University of Tehran
+ * 8 - Gulf Region
+ * 9 - Kuwait
+ * 10 - Qatar
+ * 11 - Majlis Ugama Islam Singapura, Singapore
+ * 12 - Union Organization islamic de France
+ * 13 - Diyanet İşleri Başkanlığı, Turkey
+ * @apiParam {number{0-1}} [school = 0] 0 for Shafi (or the standard way), 1 for Hanafi. If you leave this empty, it defaults to Shafii.
+ * @apiParam {string} [timezonestring] A valid timezone name as specified on http://php.net/manual/en/timezones.php . Example: Europe/London. If you do not specify this, we'll calcuate it using the co-ordinates you provide.
+ * @apiParam {number} [latitudeAdjustmentMethod=3] Method for adjusting times higher latitudes - for instance, if you are checking timings in the UK or Sweden.
+ * 1 - Middle of the Night
+ * 2 - One Seventh
+ * 3 - Angle Based
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/calendarByCity?city=London&country=United Kingdom&method=2&month=04&year=2017
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": [{
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * },
+ * {
+ * "timings": {
+ * "Fajr": "03:57",
+ * "Sunrise": "05:46",
+ * "Dhuhr": "12:59",
+ * "Asr": "16:55",
+ * "Sunset": "20:12",
+ * "Maghrib": "20:12",
+ * "Isha": "22:02",
+ * "Imsak": "03:47",
+ * "Midnight": "00:59"
+ * },
+ * "date": {
+ * "readable": "24 Apr 2014",
+ * "timestamp": "1398332113"
+ * },
+ * "meta": {
+ * "latitude": 51.508515,
+ * "longitude": -0.1254872,
+ * "timezone": "Europe/London",
+ * "method": {
+ * "id": 2,
+ * "name": "Islamic Society of North America (ISNA)",
+ * "params": {
+ * "Fajr": 15,
+ * "Isha": 15
+ * }
+ * },
+ * "latitudeAdjustmentMethod": "ANGLE_BASED",
+ * "midnightMode": "STANDARD",
+ * "school": "STANDARD",
+ * "offset": {
+ * "Imsak": 0,
+ * "Fajr": 0,
+ * "Sunrise": 0,
+ * "Dhuhr": 0,
+ * "Asr": 0,
+ * "Maghrib": 0,
+ * "Sunset": 0,
+ * "Isha": 0,
+ * "Midnight": 0
+ * }
+ * }
+ * }
+ * ... // More data here till the end of the month
+ * ]
+ * }
+ */
+ $app->get('/calendarByCity', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $method = ClassMapper::method(ApiRequest::method($request->getQueryParam('method')));
+ $school = ClassMapper::school(ApiRequest::school($request->getQueryParam('school')));
+ $latitudeAdjustmentMethod = ClassMapper::latitudeAdjustmentMethod(ApiRequest::latitudeAdjustmentMethod($request->getQueryParam('latitudeAdjustmentMethod')));
+ $month = ApiRequest::month($request->getQueryParam('month'));
+ $year = ApiRequest::year($request->getQueryParam('year'));
+ $city = $request->getQueryParam('city');
+ $country = $request->getQueryParam('country');
+ $state = $request->getQueryParam('state');
+ $locInfo = $this->model->locations->getGoogleCoOrdinatesAndZone($city, $country, $state);
+ $annual = ApiRequest::annual($request->getQueryParam('annual'));
+ $tune = ApiRequest::tune($request->getQueryParam('tune'));
+
+ if ($locInfo) {
+ $pt = new PrayerTimes($method, $school);
+ $pt->tune($tune[0], $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6], $tune[7], $tune[8]);
+ if ($method == PrayerTimes::METHOD_CUSTOM) {
+ $methodSettings = ApiRequest::customMethod($request->getQueryParam('methodSettings'));
+ $customMethod = PrayerTimesHelper::createCustomMethod($methodSettings[0], $methodSettings[1], $methodSettings[2]);
+ $pt->setCustomMethod($customMethod);
+ }
+ if ($annual) {
+ $times = PrayerTimesHelper::calculateYearPrayerTimes($locInfo['latitude'], $locInfo['longitude'], $year, $locInfo['timezone'], $latitudeAdjustmentMethod, $pt);
+ } else {
+ $times = PrayerTimesHelper::calculateMonthPrayerTimes($locInfo['latitude'], $locInfo['longitude'], $month, $year, $locInfo['timezone'], $latitudeAdjustmentMethod, $pt);
+ }
+ return $response->withJson(ApiResponse::build($times, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to find city and country pair.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/cityInfo City Geolocation info
+ * @apiDescription Returns the latitude, longitude and timezone for a given city
+ * @apiName GetCityInfo
+ * @apiGroup Geolocation
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} city A city name. Example: London
+ * @apiParam {string} country A country name or 2 character alpha ISO 3166 code. Examples: GB or United Kindom
+ * @apiParam {string} [state] State or province. A state name or abbreviation. Examples: Colorado / CO / Punjab / Bengal
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/cityInfo?city=Dubai&country=United Arab Emirates
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": {
+ * "latitude": "25.2048493",
+ * "longitude": "55.2707828",
+ * "timezone": "Asia/Dubai"
+ * }
+ * }
+ *
+ **/
+ $app->get('/cityInfo', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $city = $request->getQueryParam('city');
+ $country = $request->getQueryParam('country');
+ $state = $request->getQueryParam('state');
+ $result = $this->model->locations->getGoogleCoOrdinatesAndZone($city, $country, $state);
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to find city and country.', 400, 'Bad Request'), 400);
+ }
+ });
+
+ /**
+ * @api {get} http://api.aladhan.com/v1/addressInfo Address Geolocation info
+ * @apiDescription Returns the latitude, longitude and timezone for a given address
+ * @apiName GetAddressInfo
+ * @apiGroup Geolocation
+ * @apiVersion 1.0.1
+ *
+ * @apiParam {string} address An address string. Example: 1420 Austin Bluffs Parkway, Colorado Springs, CO OR 25 Hampstead High Street, London, NW3 1RL, United Kingdom OR Sultanahmet Mosque, Istanbul, Turkey
+ *
+ * @apiExample {http} Example usage:
+ * http://api.aladhan.com/v1/addressInfo?address=1420 Austin Bluffs Parkway, Colorado Springs, CO 80918
+ *
+ * @apiSuccessExample Success-Response:
+ * HTTP/1.1 200 OK
+ * {
+ * "code": 200,
+ * "status": "OK",
+ * "data": {
+ * "latitude": 38.8889823,
+ * "longitude": -104.7881199,
+ * "timezone": "America/Denver"
+ * }
+ * }
+ *
+ **/
+ $app->get('/addressInfo', function (Request $request, Response $response) {
+ $this->helper->logger->write();
+ $address = $request->getQueryParam('address');
+ $result = $this->model->locations->getAddressCoOrdinatesAndZone($address);
+ if ($result) {
+ return $response->withJson(ApiResponse::build($result, 200, 'OK'), 200);
+ } else {
+ return $response->withJson(ApiResponse::build('Unable to find address.', 400, 'Bad Request'), 400);
+ }
+ });
+});
diff --git a/www/index.php b/www/index.php
index 56e7e6d..ca8b637 100644
--- a/www/index.php
+++ b/www/index.php
@@ -6,9 +6,13 @@
require_once realpath(__DIR__) . '/../config/dependencies.php';
// Load routes.
-require_once realpath(__DIR__) . '/../routes/asmaAlHusna/asmaAlHusna.php';
-require_once realpath(__DIR__) . '/../routes/timings/dateAndTime.php';
-require_once realpath(__DIR__) . '/../routes/hijri/hijriCalendar.php';
-require_once realpath(__DIR__) . '/../routes/timings/prayerTimes.php';
+require_once realpath(__DIR__) . '/../routes/asmaAlHusna/archive/asmaAlHusna.php';
+require_once realpath(__DIR__) . '/../routes/timings/archive/dateAndTime.php';
+require_once realpath(__DIR__) . '/../routes/hijri/archive/hijriCalendar.php';
+require_once realpath(__DIR__) . '/../routes/timings/archive/prayerTimes.php';
+require_once realpath(__DIR__) . '/../routes/asmaAlHusna/v1/asmaAlHusna.php';
+require_once realpath(__DIR__) . '/../routes/timings/v1/dateAndTime.php';
+require_once realpath(__DIR__) . '/../routes/hijri/v1/hijriCalendar.php';
+require_once realpath(__DIR__) . '/../routes/timings/v1/prayerTimes.php';
$app->run();