1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the PayBreak/basket package. |
4
|
|
|
* |
5
|
|
|
* (c) PayBreak <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace PayBreak\Sdk\Gateways; |
12
|
|
|
use PayBreak\Sdk\Entities\GroupEntity; |
13
|
|
|
use PayBreak\Sdk\Entities\ProductEntity; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Product Gateway |
17
|
|
|
* |
18
|
|
|
* @author EB |
19
|
|
|
* @package PayBreak\Sdk\Gateways |
20
|
|
|
*/ |
21
|
|
|
class ProductGateway extends AbstractGateway |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @param string $extId |
25
|
|
|
* @param string $token |
26
|
|
|
* @return GroupEntity |
27
|
|
|
*/ |
28
|
2 |
|
public function getProductGroupsWithProducts($extId, $token) |
29
|
|
|
{ |
30
|
2 |
|
$response = $this->fetchDocument( |
31
|
2 |
|
'/v4/installations/' . $extId . '/product-groups?with=products', |
32
|
2 |
|
$token, |
33
|
|
|
'listGroupsWithProducts' |
34
|
2 |
|
); |
35
|
|
|
|
36
|
2 |
|
foreach($response as &$group) { |
37
|
|
|
foreach($group['products'] as &$product) { |
38
|
|
|
$product = ProductEntity::make($product); |
39
|
|
|
} |
40
|
|
|
$group = GroupEntity::make($group); |
41
|
2 |
|
} |
42
|
|
|
|
43
|
2 |
|
return $response; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @author WN |
48
|
|
|
* @param string $installation |
49
|
|
|
* @param string $product |
50
|
|
|
* @param string $token |
51
|
|
|
* @param array $params |
52
|
|
|
* @return array |
53
|
|
|
*/ |
54
|
|
|
public function getCreditInfo($installation, $product, $token, array $params) |
55
|
|
|
{ |
56
|
|
|
return $this->postDocument( |
57
|
|
|
'/v4/installations/' . $installation . '/products/' . $product . '/get-credit-information', |
58
|
|
|
$params, |
59
|
|
|
$token, |
60
|
|
|
'CreditInfo' |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param string $extId |
66
|
|
|
* @param string $productGroup |
67
|
|
|
* @param string $token |
68
|
|
|
* @return array |
69
|
|
|
* @author SL |
70
|
|
|
*/ |
71
|
|
|
public function getProductsInGroup($extId, $productGroup, $token) |
72
|
|
|
{ |
73
|
|
|
$response = $this->fetchDocument( |
74
|
|
|
'/v4/installations/' . $extId . '/product-groups/' . $productGroup . '/products', |
75
|
|
|
$token, |
76
|
|
|
'getProductsByGroup' |
77
|
|
|
); |
78
|
|
|
|
79
|
|
|
$products = []; |
80
|
|
|
|
81
|
|
|
foreach($response as $product) { |
82
|
|
|
$products[] = ProductEntity::make($product); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
return $products; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|