-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
179 lines (170 loc) · 5.58 KB
/
index.php
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<html>
<head>
<style>
html,body{
background: #fafafa;
color: #555;
font-family: Helvetica, Arial;
padding:10px 20px;
}
code{
background: #ccc;
color: #111;
padding:10px;
line-height: 200%;
}
#wrapper{
max-width:960px;
margin:0 auto;
}
h1,h2,h3{
background: #889977;
padding:5px 10px;
}
#title{
background: #009af1;
text-align: center;
color:#fff;
}
</style>
</head>
<body>
<div id="wrapper">
<h2 id="title">Example file for using the Bucky Box Distributor API PHP Model</h2>
<p>
Review the code of this file to see some examples of how to use the included model to quickly interface your system with the Bucky Box Distributor API
</p>
<?php
if(!empty($_GET['test'])){
$code = "Nothing to see here.";
include_once('bucky-box-api-wrapper.php');
$api = new BuckyBoxApiWrapper($api_key, $api_secret);
$test = $_GET['test'];
echo "<h1>Test $test $code[0] </h1>";
switch ($test) {
case 'boxes':
$code = $api->boxes()->all(["embed"=>"extras,images"]);
break;
case 'box':
$code = $api->boxes()->id(12, ["embed"=>"extras,images"]);
break;
case 'customers':
$code = $api->customers()->all(["embed"=>"address"]);
break;
case 'customer':
$code = $api->customers()->id(123,["embed"=>"address"]);
break;
case 'customernew':
$code = $api->customers()->create('{"customer": {"first_name": "Joe","last_name": "Smith","email": "joe@buckybox.com", "delivery_service_id": 146, "address": {
"address_1": "12 Bucky Lane",
"address_2": "",
"suburb": "Boxville",
"city": "Wellington",
"delivery_note": "Just slip it through the catflap",
"home_phone": "01 234 5678",
"mobile_phone": "012 345 6789",
"work_phone": "98 765 4321"
}
}
}');
break;
case 'deliveryservices':
$code = $api->delivery_services()->all();
break;
case 'orders':
$code = $api->orders()->all();
break;
case 'order':
$code = $api->orders()->id(123);
break;
case 'ordernew':
$code = $api->orders()->create('{ "order": { "box_id": 12, "customer_id": 123 } }');
break;
default:
$code = " - that's not a test.";
break;
}
}
?>
<h2>Boxes</h2>
<form method="get">
<input type="hidden" name="test" value="boxes" />
<label>
GET /v1/boxes
<input type="submit" value="Go" />
</label>
</form>
<form method="get">
<input type="hidden" name="test" value="box" />
<label>
GET /v1/boxes/:id
<input type="submit" value="Go" />
</label>
</form>
<h2>Customers</h2>
<form method="get">
<input type="hidden" name="test" value="customers" />
<label>
GET /v1/customers
<input type="submit" value="Go" />
</label>
</form>
<form method="get">
<input type="hidden" name="test" value="customer" />
<label>
GET /v1/customers/:id
<input type="submit" value="Go" />
</label>
</form>
<form method="get">
<input type="hidden" name="test" value="customerbyemail" />
<label>
GET /v1/customers/:email
<input type="submit" value="Go" />
</label>
</form>
<form method="get">
<input type="hidden" name="test" value="customernew" />
<label>
POST /v1/customers
<input type="submit" value="Go" />
</label>
</form>
<h2>Delivery Services</h2>
<form method="get">
<input type="hidden" name="test" value="deliveryservices" />
<label>
GET /v1/delivery_services
<input type="submit" value="Go" />
</label>
</form>
<h2>Orders</h2>
<form method="get">
<input type="hidden" name="test" value="orders" />
<label>
GET /v1/orders
<input type="submit" value="Go" />
</label>
</form>
<form method="get">
<input type="hidden" name="test" value="order" />
<label>
GET /v1/orders/:id
<input type="submit" value="Go" />
</label>
</form>
<form method="get">
<input type="hidden" name="test" value="ordernew" />
<label>
POST /v1/orders
<input type="submit" value="Go" />
</label>
</form>
<?php
echo "<code>";
var_dump($code);
echo "</code>";
?>
</div>
</body>
</html>