getQueryStringParams(); if (strtoupper($requestMethod) == 'GET') { try { $purchaseModel = new PurchaseModel(); $intLimit = 10; $dtDate = date("M/d/yy"); if (isset($arrQueryStringParams['limit']) && $arrQueryStringParams['limit']) { $intLimit = $arrQueryStringParams['limit']; $dtDate = $arrQueryStringParams['date']; } $arrPurchases = $purchaseModel->getPurchases($dtDate, $intLimit); $responseData = json_encode($arrPurchases); } catch (Error $e) { $strErrorDesc = $e->getMessage().'Something went wrong! Please contact support.'; $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; } } else { $strErrorDesc = 'Method not supported'; $strErrorHeader = 'HTTP/1.1 422 Unprocessable Entity'; } // send output if (!$strErrorDesc) { $this->sendOutput( $responseData, array('Content-Type: application/json', 'HTTP/1.1 200 OK') ); } else { $this->sendOutput(json_encode(array('error' => $strErrorDesc)), array('Content-Type: application/json', $strErrorHeader) ); } } }