public function getAction($request) { $Class = new ClassModel(); $needle = $request->url_elements[1]; if ($request->url_elements[2]) { $needle = strtolower($request->url_elements[2]); switch ($needle) { case 'byclassid': if (is_numeric($request->url_elements[3])) { $data = $Class->GetClass($request->url_elements[3]); if ($data[0]['Class_Id'] != '') { $data = $data[0]; } else { $data["error"] = "No records to display."; } } else { $data["error"] = "Error: A number expected for parameter 2."; } break; case 'bycompanyid': if (is_numeric($request->url_elements[3])) { $data = $Class->GetClasses($request->url_elements[3]); if ($data[0]['Class_Id'] != '') { $data = $data[0]; } else { $data["error"] = "No records to display."; } } else { $data["error"] = "Error: A number expected for parameter 2."; } break; case 'instructors': $data = $Class->GetInstructorsList(''); $data = $data; break; default: $data["error"] = "Error: Please check the api documentation and try again."; break; } } else { switch ($needle) { case 'class': $data = $Class->GetClasses(''); $data = $data[0]; break; default: $data["error"] = "Error: Please check the api documentation and try again."; break; } } return $data; }