DHL-PHP-SDK  v0.4
A wrapper for the DHL-XML-API Version 2
Credentials.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Petschko\DHL;
4 
21 class Credentials {
22  // Test-Type Constants
26  const TEST_NORMAL = 'test';
27 
31  const TEST_THERMO_PRINTER = 'thermo';
32 
33  // Test-User Value Constants
37  const DHL_BUSINESS_TEST_USER = '2222222222_01';
38 
42  const DHL_BUSINESS_TEST_USER_THERMO = '2222222222_03';
43 
48 
54  const DHL_BUSINESS_TEST_EPK = '2222222222'; // Still in here for backward compatibility
55 
59  const DHL_BUSINESS_TEST_EKP = '2222222222';
60 
70  private $user = '';
71 
81  private $signature = '';
82 
91  private $ekp = '';
92 
104  private $apiUser = '';
105 
117  private $apiPassword = '';
118 
129  public function __construct($testMode = false) {
130  if($testMode) {
131  switch($testMode) {
132  case self::TEST_THERMO_PRINTER:
133  $this->setUser(self::DHL_BUSINESS_TEST_USER_THERMO);
134  break;
135  case self::TEST_NORMAL:
136  case true:
137  default:
138  $this->setUser(self::DHL_BUSINESS_TEST_USER);
139  }
140 
141  $this->setSignature(self::DHL_BUSINESS_TEST_USER_PASSWORD);
142  $this->setEkp(self::DHL_BUSINESS_TEST_EKP);
143  }
144  }
145 
149  public function __destruct() {
150  unset($this->user);
151  unset($this->signature);
152  unset($this->ekp);
153  unset($this->apiUser);
154  unset($this->apiPassword);
155  }
156 
162  public function getUser() {
163  return $this->user;
164  }
165 
171  public function setUser($user) {
172  $this->user = mb_strtolower($user);
173  }
174 
180  public function getSignature() {
181  return $this->signature;
182  }
183 
189  public function setSignature($signature) {
190  $this->signature = $signature;
191  }
192 
199  public function getEkp($len = null) {
200  return mb_substr($this->ekp, 0, $len);
201  }
202 
211  public function getEpk($len = null) {
212  trigger_error('Called deprecated method ' . __METHOD__ . ': Use getEkp() instead, this method will removed in the future!', E_USER_DEPRECATED);
213 
214  return $this->getEkp($len);
215  }
216 
222  public function setEkp($ekp) {
223  $this->ekp = $ekp;
224  }
225 
233  public function setEpk($ekp) {
234  trigger_error('Called deprecated method ' . __METHOD__ . ': Use setEkp() instead, this method will removed in the future!', E_USER_DEPRECATED);
235 
236  $this->setEkp($ekp);
237  }
238 
244  public function getApiUser() {
245  return $this->apiUser;
246  }
247 
253  public function setApiUser($apiUser) {
254  $this->apiUser = $apiUser;
255  }
256 
262  public function getApiPassword() {
263  return $this->apiPassword;
264  }
265 
271  public function getApiKey() {
272  return $this->getApiPassword();
273  }
274 
280  public function setApiPassword($apiPassword) {
281  $this->apiPassword = $apiPassword;
282  }
283 
289  public function setApiKey($apiKey) {
290  $this->setApiPassword($apiKey);
291  }
292 }
$testMode
Definition: test.php:15
setApiPassword($apiPassword)
__construct($testMode=false)