1: <?php
2: /**
3: * Partner API Library
4: *
5: * @copyright Copyright (c) 2020 Asseco Data Systems SA
6: * @license license.txt
7: */
8:
9: require_once 'operation.php';
10: require_once 'certumPartnerAPI/messages/messageGetProductList.php';
11: require_once 'certumPartnerAPI/messages/messageGetProductListResponse.php';
12:
13: /*
14: <operation name="getProductList" parameterOrder="getProductList">
15: <input message="tns:PartnerServicePortType_getProductList">
16: </input>
17: <output message="tns:PartnerServicePortType_getProductListResponse">
18: </output>
19: </operation>
20: */
21:
22: /**
23: * This class represents the getProductList WSDL operation.
24: *
25: * It is based on the PartnerAPIOperation class and derives some properties and methods from that class.
26: *
27: * @method PartnerAPIMessageGetProductListResponse getResponseMessage() A complete response from a service
28: *
29: * @package operations
30: */
31: class PartnerAPIOperationGetProductList extends PartnerAPIOperation {
32:
33: /**
34: * @var PartnerAPIMessageGetProductList
35: */
36: protected $_input = NULL;
37:
38: /**
39: * @var PartnerAPIMessageGetProductListResponse
40: */
41: protected $_output = NULL;
42:
43: /**
44: * @var string
45: */
46: protected $_operation = 'getProductList';
47:
48: /**
49: * The constructor.
50: *
51: * It initializes input and output data.
52: */
53: public function __construct() {
54: $this->_input = new PartnerAPIMessageGetProductList();
55: $this->_output = new PartnerAPIMessageGetProductListResponse();
56: }
57:
58: /**
59: * Sets whether or not returned products should contain information about available hash algorithms.
60: *
61: * @param boolean $hashAlgorithm
62: * @return PartnerAPIOperationGetProductList
63: */
64: public function setHashAlgorithm($hashAlgorithm) {
65: $this->_input->getProductList->setHashAlgorithm($hashAlgorithm);
66: return $this;
67: }
68:
69: /**
70: * Returns products contained in a response.
71: *
72: * This method always returns an array.
73: * If there is no product in the response an empty array is returned.
74: * Otherwise, an array with one or more products is returned.
75: * Keys in the array are numbers meaning the product code
76: * and values are objects of type PartnerAPITypeProduct.
77: * The following properties are set for each product: code, type and
78: * validityPeriod.
79: *
80: * @return PartnerAPITypeProduct[]
81: */
82: public function getProducts() {
83: $productList = array();
84: $products = $this->_output->getProductListResponse->products;
85: if (is_null($products))
86: return $productList;
87: $product = $products->product;
88: if (is_array($product))
89: foreach ($product as $p)
90: $productList[$p->code] = $p;
91: else
92: $productList[$product->code] = $product;
93: return $productList;
94: }
95:
96: }
97: