mirror of
https://github.com/sctn4elk/CustomerRewardsRESTAPI.git
synced 2025-01-09 15:14:29 -06:00
Allow for use in development environment
This commit is contained in:
parent
326b1521ba
commit
6212095c32
|
@ -10,12 +10,13 @@ header("Content-Type: application/json");
|
||||||
*
|
*
|
||||||
* @author SCTN4
|
* @author SCTN4
|
||||||
* http://localhost:8000/index.php/customer/process/insert?name=Mike%20Howard&email=sctn4elk@msn.com&phone=208-841-4159&birthday=05/07/1965&loyalty=1&city=Winnsboro&state=TX&zip=75494
|
* http://localhost:8000/index.php/customer/process/insert?name=Mike%20Howard&email=sctn4elk@msn.com&phone=208-841-4159&birthday=05/07/1965&loyalty=1&city=Winnsboro&state=TX&zip=75494
|
||||||
|
* http://localhost:8000/index.php/customer/process/select?limit=20
|
||||||
*/
|
*/
|
||||||
class CustomerController extends BaseController{
|
class CustomerController extends BaseController{
|
||||||
/**
|
/**
|
||||||
* "/customer/list" Endpoint - Get list of users
|
* "/customer/list" Endpoint - Get list of users
|
||||||
*/
|
*/
|
||||||
public function processAction()
|
public function processAction($action)
|
||||||
{
|
{
|
||||||
$strErrorDesc = '';
|
$strErrorDesc = '';
|
||||||
$requestMethod = $_SERVER["REQUEST_METHOD"];
|
$requestMethod = $_SERVER["REQUEST_METHOD"];
|
||||||
|
@ -25,7 +26,7 @@ class CustomerController extends BaseController{
|
||||||
$customerModel = new CustomerModel();
|
$customerModel = new CustomerModel();
|
||||||
|
|
||||||
$uri = $this->getUriSegments();
|
$uri = $this->getUriSegments();
|
||||||
switch($uri[4]) {
|
switch($action) {
|
||||||
case "select":
|
case "select":
|
||||||
$customerModel->limit = 10;
|
$customerModel->limit = 10;
|
||||||
if (isset($arrQueryStringParams['limit']) && $arrQueryStringParams['limit']) {
|
if (isset($arrQueryStringParams['limit']) && $arrQueryStringParams['limit']) {
|
||||||
|
@ -67,7 +68,7 @@ class CustomerController extends BaseController{
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$strErrorDesc = 'Controller Method not supported for processAction: ' . $uri[4];
|
$strErrorDesc = 'Controller Method not supported for processAction: ' . $action;
|
||||||
$strErrorHeader = 'HTTP/1.1 422 Unprocessable Entity';
|
$strErrorHeader = 'HTTP/1.1 422 Unprocessable Entity';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
21
index.php
21
index.php
|
@ -12,12 +12,25 @@ require __DIR__ . "/include/bootstrap.php";
|
||||||
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||||
$uri = explode( '/', $uri );
|
$uri = explode( '/', $uri );
|
||||||
|
|
||||||
if (!isset($uri[2]) || !isset($uri[3]) || !isset($uri[4])) {
|
/* When testing with UniServer the URI array placement position will be
|
||||||
|
* incremented by 1 due to the folder addition
|
||||||
|
* http://localhost/CustomerRewards/index.php/customer/process/select?limit=5
|
||||||
|
* uri[1] = folder
|
||||||
|
* uri[2] = index
|
||||||
|
* uri[3] = module
|
||||||
|
* uri[4] = action
|
||||||
|
* uri[5] = parmeters
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Set uri module location position to 1 for production, 2 for testing
|
||||||
|
$uri_pos = 2;
|
||||||
|
|
||||||
|
if (!isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2]) || !isset($uri[$uri_pos+3])) {
|
||||||
header("HTTP/1.1 404 Not Found");
|
header("HTTP/1.1 404 Not Found");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($uri[2]) {
|
switch($uri[$uri_pos]) {
|
||||||
case "purchase":
|
case "purchase":
|
||||||
header("HTTP/1.1 404 Module Not Defined");
|
header("HTTP/1.1 404 Module Not Defined");
|
||||||
exit();
|
exit();
|
||||||
|
@ -36,6 +49,6 @@ switch($uri[2]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$strMethodName = $uri[3] . 'Action';
|
$strMethodName = $uri[$uri_pos+1] . 'Action';
|
||||||
$objFeedController->{$strMethodName}();
|
$objFeedController->{$strMethodName}($uri[$uri_pos+2]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user