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/messageOrderSNICertificate.php';
11: require_once 'certumPartnerAPI/messages/messageOrderSNICertificateResponse.php';
12:
13: /*
14: <operation name="orderSNICertificate" parameterOrder="orderSNICertificate">
15: <input message="tns:PartnerServicePortType_orderSNICertificate">
16: </input>
17: <output message="tns:PartnerServicePortType_orderSNICertificateResponse">
18: </output>
19: </operation>
20: */
21:
22: /**
23: * This class represents the orderSNICertificate WSDL operation.
24: *
25: * It is based on the PartnerAPIOperation class and derives some properties and methods from that class.
26: *
27: * @method PartnerAPIMessageOrderSNICertificateResponse getResponseMessage() A complete response from a service
28: *
29: * @package operations
30: */
31: class PartnerAPIOperationOrderSNICertificate extends PartnerAPIOperation {
32:
33: /**
34: * @var PartnerAPIMessageOrderSNICertificate
35: */
36: protected $_input = NULL;
37:
38: /**
39: * @var PartnerAPIMessageOrderSNICertificateResponse
40: */
41: protected $_output = NULL;
42:
43: /**
44: * @var string
45: */
46: protected $_operation = 'orderSNICertificate';
47:
48: /**
49: * The constructor.
50: *
51: * It initializes input and output data.
52: */
53: public function __construct() {
54: $this->_input = new PartnerAPIMessageOrderSNICertificate();
55: $this->_output = new PartnerAPIMessageOrderSNICertificateResponse();
56: }
57:
58: /**
59: * Sets a CSR for the request.
60: *
61: * Setting this value is required.
62: *
63: * @param string $csr
64: * @return PartnerAPIOperationOrderSNICertificate
65: */
66: public function setCSR($csr) {
67: $this->_input->orderSNICertificate->orderSNIParameters->setCSR($csr);
68: return $this;
69: }
70:
71: /**
72: * Sets a language to be used for the request.
73: *
74: * Default is 'pl'.
75: *
76: * @param string|null $lang
77: * @return PartnerAPIOperationOrderSNICertificate
78: */
79: public function setLanguage($lang) {
80: $this->_input->orderSNICertificate->orderSNIParameters->setLanguage($lang);
81: return $this;
82: }
83:
84: /**
85: * Sets a hash algorithm to be used for the request.
86: *
87: * @param string|null $hashAlgorithm
88: * @return PartnerAPIOperationOrderSNICertificate
89: */
90: public function setHashAlgorithm($hashAlgorithm) {
91: $this->_input->orderSNICertificate->orderSNIParameters->setHashAlgorithm($hashAlgorithm);
92: return $this;
93: }
94:
95: /**
96: * Adds a new serial number to the operation's data.
97: *
98: * The $number argument is a string containing a serial number. It can also be an array
99: * of such strings.
100: * This method can be invoked several times and all passed serial numbers
101: * will be added to the existing set of serial numbers.
102: *
103: * It is required to set at least one serial number.
104: *
105: * @param string|string[] $number
106: * @return PartnerAPIOperationOrderSNICertificate
107: */
108: public function addSerialNumber($number) {
109: $serialNumbers = $this->_input->orderSNICertificate->serialNumbers;
110: if (is_null($serialNumbers)) {
111: $serialNumbers = new PartnerAPITypeSerialNumbers();
112: $this->_input->orderSNICertificate->setSerialNumbers($serialNumbers);
113: }
114: if (is_array($number))
115: foreach ($number as $n)
116: $serialNumbers->addSerialNumber($n);
117: else
118: $serialNumbers->addSerialNumber($number);
119: return $this;
120: }
121:
122: /**
123: * Sets all the contact data of a requestor.
124: *
125: * All arguments are required apart from the last which can be NULL.
126: *
127: * @param string $firstName
128: * @param string $lastName
129: * @param string $email
130: * @param string $phone
131: * @return PartnerAPIOperationOrderSNICertificate
132: */
133: public function setRequestorInfo($firstName, $lastName, $email, $phone) {
134: $ri = $this->_input->orderSNICertificate->requestorInfo;
135: $ri->setFirstName($firstName)->setLastName($lastName)
136: ->setEmail($email)->setPhone($phone);
137: return $this;
138: }
139:
140: /**
141: * Sets an organization information.
142: *
143: * It is not required to set organization information but if you need or have to set it
144: * all the arguments are required.
145: *
146: * @param string $taxNumber The tax identification number
147: * @return PartnerAPIOperationOrderSNICertificate
148: */
149: public function setOrganizationInfo($taxNumber) {
150: $oi = new PartnerAPITypeOrganizationInfo();
151: $oi->setTaxIdentificationNumber($taxNumber);
152: $this->_input->orderSNICertificate->setOrganizationInfo($oi);
153: return $this;
154: }
155:
156: /**
157: * Gets an order ID returned in a response.
158: *
159: * @return string
160: */
161: public function getOrderID() {
162: return $this->_output->orderSNICertificateResponse->orderID;
163: }
164:
165: /**
166: * Returns invalid serial numbers contained in a response.
167: *
168: * This method always returns an array.
169: * If there is no invalid serial number in a response an empty array is returned.
170: * Otherwise, an array with one or more invalid serial numbers is returned.
171: *
172: * @return string[]
173: */
174: public function getInvalidSerialNumbers() {
175: $numbers = $this->_output->orderSNICertificateResponse->invalidSerialNumbers;
176: if (is_null($numbers))
177: return array();
178: $number = $numbers->serialNumber;
179: if (! is_array($number))
180: $number = array($number);
181: return $number;
182: }
183:
184: }
185: