-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
84 lines (75 loc) · 2.59 KB
/
index.php
File metadata and controls
84 lines (75 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require ('includes/restcommon.php');
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//Create REST object
$rest = RestUtils::processRequest();
//06.08.2012 naj - for now we only support json
$responsetype = 'application/json';
//Trim the leading /rest off the request uri and then parse the uri
$requesttype= $rest->getRequestType();
if (empty($requesttype))
die(RestUtils::sendResponse(400, 'Error 16532 Bad Request'));
//01.23.2013 naj - get the request vars
$requestvars = cleanRest($rest->getRequestVars());
//08.20.2015 ghh - now we need to verify the clientkey that was sent in and
//build a new one if we don't already have it. In the event we don't have one
//one will be build on the first every call and returned to the BSV to store for
//future calls. If they fail to store it then the client will be down until
//someone manually resets the client on the server.
$clientkey = verifyClientKey( $requestvars["clientkey"], $requestvars["accountnumber"] );
$requestvars['ClientKey'] = $clientkey;
switch($rest->getMethod())
{
//08.20.2015 ghh - get requests enter here
case 'get':
switch ($requesttype)
{
case 'getvendors':
RestLog("Getting List of Vendors");
require_once("getvendors.php");
getVendors( );
break;
case 'getinventory'://08.25.2015 ghh - added getinventory request
RestLog("Getting Inventory");
require_once("getinventory.php");
getInventory($requestvars, $responsetype);
break;
case 'getiteminfo'://08.25.2015 ghh - added getinventory request
RestLog("Getting Item Information");
require_once("getiteminfo.php");
getItemInfo($requestvars, $responsetype);
break;
case 'getmodel'://08.25.2015 ghh - added getinventory request
RestLog("Getting Model Info");
require_once("getmodel.php");
getModel($requestvars, $responsetype);
break;
case 'getorderstatus'://08.25.2015 ghh - added getinventory request
RestLog("Getting Order Status");
require_once("getorderstatus.php");
getOrderStatus($requestvars, $responsetype);
break;
default:
die(RestUtils::sendResponse(400, 'Error 16542: Bad Request')); //Bad Request
break;
}
break;
//08.20.2015 ghh - send requests enter here
case 'post':
switch ($requesttype)
{
case 'sendorder':
RestLog("Send Order Called");
require_once("sendorder.php");
sendOrder($requestvars, $responsetype);
break;
default:
die(RestUtils::sendResponse(400, 'Error 16543 Bad Request')); //Bad Request
break;
}
break;
default:
die(RestUtils::sendResponse(400, 'Error 16544 Bad Post/Get Request')); //Bad Request
break;
}
?>