1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
require_once('../vendor/autoload.php'); |
4
|
|
|
require_once('../examples/utils/Helpers.php'); |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* PLEASE FILL YOUR PUBLIC KEY AND PRIVATE KEY |
8
|
|
|
*/ |
9
|
|
|
const PUBLIC_KEY = ''; //Set your public key |
10
|
|
|
const PRIVATE_KEY = ''; //Set your public key |
11
|
|
|
|
12
|
|
|
try { |
13
|
|
|
call_user_func('listMethod'); |
14
|
|
|
} catch (\Exception $e) { |
15
|
|
|
echo $e->getMessage(); |
16
|
|
|
exit; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @throws \Httpful\Exception\ConnectionErrorException |
21
|
|
|
* @throws \Pagantis\OrdersApiClient\Exception\ClientException |
22
|
|
|
* @throws Exception |
23
|
|
|
*/ |
24
|
|
|
function listMethod() |
25
|
|
|
{ |
26
|
|
|
$queryString = array( |
27
|
|
|
'channel' => 'ONLINE', |
28
|
|
|
'pageSize' => 2, |
29
|
|
|
'page' => 1, |
30
|
|
|
'status' => \Pagantis\OrdersApiClient\Model\Order::STATUS_CONFIRMED |
31
|
|
|
); |
32
|
|
|
try { |
33
|
|
|
$withDate = true; |
34
|
|
|
$fileName = basename(__FILE__); |
35
|
|
|
writeLog('Creating Client', $fileName, $withDate); |
36
|
|
|
$orderApiClient = new \Pagantis\OrdersApiClient\Client(PUBLIC_KEY, PRIVATE_KEY); |
37
|
|
|
writeLog('Client Created', $fileName, $withDate); |
38
|
|
|
writeLog('Fetching Orders', $fileName, $withDate); |
39
|
|
|
/** WARNING: orders must be confirmed on your back office or you will get a empty object */ |
40
|
|
|
$orders = $orderApiClient->listOrders($queryString); |
41
|
|
|
writeLog('Orders Fetched', $fileName, $withDate); |
42
|
|
|
|
43
|
|
|
writeLog(jsonEncoded($orders), $fileName, $withDate); |
44
|
|
|
print("<pre>" . print_r($orders, true) . "</pre>"); |
45
|
|
|
|
46
|
|
|
} catch (\Exception $exception) { |
47
|
|
|
$exception->getMessage(); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
|