Passed
Pull Request — master (#26)
by
unknown
01:44
created

listMethod()   A

Complexity

Conditions 2
Paths 10

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 18
c 3
b 0
f 0
nc 10
nop 0
dl 0
loc 24
rs 9.6666
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