getQueryStringParams(); if (strtoupper($requestMethod) == 'GET') { try { $customerModel = new CustomerModel(); $uri = $this->getUriSegments(); switch($action) { case "select": $customerModel->limit = 10; if (isset($arrQueryStringParams['limit']) && $arrQueryStringParams['limit']) { $customerModel->limit = $arrQueryStringParams['limit']; } $arrCustomer = $customerModel->getCustomers(); unset($customerModel->limit); break; case "insert": $customerModel->first = $arrQueryStringParams['first']; $customerModel->last = $arrQueryStringParams['last']; $customerModel->email = $arrQueryStringParams['email']; $customerModel->phone = $arrQueryStringParams['phone']; $customerModel->birthday = $arrQueryStringParams['birthday']; $customerModel->street = $arrQueryStringParams['street']; $customerModel->city = $arrQueryStringParams['city']; $customerModel->state = $arrQueryStringParams['state']; $customerModel->zip = $arrQueryStringParams['zip']; $customerModel->loyalty = $arrQueryStringParams['loyalty']; $arrCustomer = $customerModel->insertCustomer(); unset($customerModel->first); unset($customerModel->last); unset($customerModel->email); unset($customerModel->phone); unset($customerModel->birthday); unset($customerModel->street); unset($customerModel->city); unset($customerModel->state); unset($customerModel->zip); unset($customerModel->loyalty); break; case "update": $arrCustomer = $customerModel->updateCustomer($arrQueryStringParams); break; case "delete": $arrCustomer = $customerModel->deleteCustomer($arrQueryStringParams); break; default: $strErrorDesc = 'Controller Method not supported for processAction: ' . $action; $strErrorHeader = 'HTTP/1.1 422 Unprocessable Entity'; break; } $responseData = json_encode($arrCustomer); } catch (Error $e) { $strErrorDesc = $e->getMessage().' Something went wrong in processAction! Please contact support.'; $strErrorHeader = 'HTTP/1.1 500 Internal Server Error'; } } else { $strErrorDesc = 'Request Method not supported for processAction'; $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) ); } } }