-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListProductsExample.php
42 lines (35 loc) · 1.47 KB
/
ListProductsExample.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
<?php
#-------------------------------------------------------------------------------
# INCLUDE THE CONFIGURATION FILE
#
# This file contains some default environment configuration which are used to
# ensure your examples will run.
#-------------------------------------------------------------------------------
require 'config.php';
#-------------------------------------------------------------------------------
# SETUP CLIENT
#
# Edit your credentials in config.php to use the examples.
#-------------------------------------------------------------------------------
$client = new Vleks\SDK\Client(
VLEKS_API_PUBLIC_KEY, VLEKS_API_PRIVATE_KEY,
VLEKS_MERCHANT_ID, VLEKS_API_CLUSTER
);
#-------------------------------------------------------------------------------
# LIST PRODUCTS
#-------------------------------------------------------------------------------
try {
$request = new Vleks\SDK\Requests\ListProducts(array (
'Limit' => 100
));
$result = $client->listProducts($request);
if ($result->hasProducts()) {
foreach ($result->getProducts() as $product) {
var_dump($product->getVleksID() . ':' . $product->getSKU() . ':' . $product->getTitle());
}
}
} catch (Vleks\SDK\Exceptions\ClientException $clientException) {
var_dump($clientException->getMessage());
} catch (Vleks\SDK\Exceptions\ServiceException $serviceException) {
var_dump($serviceException->getMessage());
}