├── .gitignore
├── .editorconfig
├── composer.json
├── LICENSE
├── includes
├── _nonComposerLoader.php
├── Receiver.php
├── Sender.php
├── ReturnReceiver.php
├── LabelResponse.php
├── Version.php
├── PackStation.php
├── Filial.php
├── IdentCheck.php
├── SendPerson.php
├── BankData.php
├── Product.php
├── ExportDocPosition.php
├── Credentials.php
├── Address.php
├── ShipmentOrder.php
├── ProductInfo.php
├── LabelData.php
├── ExportDocument.php
├── Response.php
└── ShipmentDetails.php
├── README.md
├── test.php
└── lib
├── 2.0
└── geschaeftskundenversand-api-2.0.wsdl
├── 2.1
└── geschaeftskundenversand-api-2.1.wsdl
└── 2.2
└── geschaeftskundenversand-api-2.2.wsdl
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea/
2 | /vendor/
3 | Doxyfile.conf
4 | testDhl.php
5 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | charset = utf-8
9 | end_of_line = lf
10 | insert_final_newline = true
11 | trim_trailing_whitespace = true
12 |
13 | # PHP-Files
14 | [*.php]
15 | indent_style = tab
16 | indent_size = 4
17 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "petschko/dhl-php-sdk",
3 | "description": "DHL SDK",
4 | "type": "library",
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "Peter Dragicevic",
9 | "email": "peter@petschko.org",
10 | "homepage": "http://petschko.org/",
11 | "role": "developer"
12 | }
13 | ],
14 | "support": {
15 | "email": "peter@petschko.org",
16 | "issues": "https://github.com/Petschko/dhl-php-sdk/issues",
17 | "source": "https://github.com/Petschko/dhl-php-sdk",
18 | "docs": "http://docs.petschko.org/dhl-php-sdk/index.html"
19 | },
20 | "require": {
21 | "php": ">=5.4.0",
22 | "ext-soap": "*",
23 | "ext-mbstring": "*"
24 | },
25 | "autoload": {
26 | "psr-4": {
27 | "Petschko\\DHL\\": "includes/"
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Peter Dragicevic
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/includes/_nonComposerLoader.php:
--------------------------------------------------------------------------------
1 | name1 = $this->getName();
33 |
34 | // Communication
35 | $class->Communication = new StdClass;
36 | if($this->getPhone() !== null)
37 | $class->Communication->phone = $this->getPhone();
38 | if($this->getEmail() !== null)
39 | $class->Communication->email = $this->getEmail();
40 | if($this->getContactPerson() !== null)
41 | $class->Communication->contactPerson = $this->getContactPerson();
42 |
43 | // Address
44 | $class->Address = new StdClass;
45 | if($this->getName2() !== null)
46 | $class->Address->name2 = $this->getName2();
47 | if($this->getName3() !== null)
48 | $class->Address->name3 = $this->getName3();
49 | $class->Address->streetName = $this->getStreetName();
50 | $class->Address->streetNumber = $this->getStreetNumber();
51 | if($this->getAddressAddition() !== null)
52 | $class->Address->addressAddition = $this->getAddressAddition();
53 | if($this->getDispatchingInfo() !== null)
54 | $class->Address->dispatchingInformation = $this->getDispatchingInfo();
55 | $class->Address->zip = $this->getZip();
56 | $class->Address->city = $this->getLocation();
57 |
58 | // Origin
59 | if($this->getCountryISOCode() !== null) {
60 | $class->Address->Origin = new StdClass;
61 | if($this->getCountry() !== null)
62 | $class->Address->Origin->country = $this->getCountry();
63 | $class->Address->Origin->countryISOCode = $this->getCountryISOCode();
64 | if($this->getState() !== null)
65 | $class->Address->Origin->state = $this->getState();
66 | }
67 |
68 | return $class;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/includes/Sender.php:
--------------------------------------------------------------------------------
1 | Name = new StdClass;
34 | $class->Name->name1 = $this->getName();
35 | if($this->getName2() !== null)
36 | $class->Name->name2 = $this->getName2();
37 | if($this->getName3() !== null)
38 | $class->Name->name3 = $this->getName3();
39 |
40 | // Address
41 | $class->Address = new StdClass;
42 | $class->Address->streetName = $this->getStreetName();
43 | $class->Address->streetNumber = $this->getStreetNumber();
44 | if($this->getAddressAddition() !== null)
45 | $class->Address->addressAddition = $this->getAddressAddition();
46 | if($this->getDispatchingInfo() !== null)
47 | $class->Address->dispatchingInformation = $this->getDispatchingInfo();
48 | $class->Address->zip = $this->getZip();
49 | $class->Address->city = $this->getLocation();
50 |
51 | // Origin
52 | if($this->getCountryISOCode() !== null) {
53 | $class->Address->Origin = new StdClass;
54 | if($this->getCountry() !== null)
55 | $class->Address->Origin->country = $this->getCountry();
56 | $class->Address->Origin->countryISOCode = $this->getCountryISOCode();
57 | if($this->getState() !== null)
58 | $class->Address->Origin->state = $this->getState();
59 | }
60 |
61 | // Communication
62 | $class->Communication = new StdClass;
63 | if($this->getPhone() !== null)
64 | $class->Communication->phone = $this->getPhone();
65 | if($this->getEmail() !== null)
66 | $class->Communication->email = $this->getEmail();
67 | if($this->getContactPerson() !== null)
68 | $class->Communication->contactPerson = $this->getContactPerson();
69 |
70 | return $class;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/includes/ReturnReceiver.php:
--------------------------------------------------------------------------------
1 | Name = new StdClass;
34 | $class->Name->name1 = $this->getName();
35 | if($this->getName2() !== null)
36 | $class->Name->name2 = $this->getName2();
37 | if($this->getName3() !== null)
38 | $class->Name->name3 = $this->getName3();
39 |
40 | // Address
41 | $class->Address = new StdClass;
42 | $class->Address->streetName = $this->getStreetName();
43 | $class->Address->streetNumber = $this->getStreetNumber();
44 | if($this->getAddressAddition() !== null)
45 | $class->Address->addressAddition = $this->getAddressAddition();
46 | if($this->getDispatchingInfo() !== null)
47 | $class->Address->dispatchingInformation = $this->getDispatchingInfo();
48 | $class->Address->zip = $this->getZip();
49 | $class->Address->city = $this->getLocation();
50 |
51 | // Origin
52 | if($this->getCountryISOCode() !== null) {
53 | $class->Address->Origin = new StdClass;
54 | if($this->getCountry() !== null)
55 | $class->Address->Origin->country = $this->getCountry();
56 | $class->Address->Origin->countryISOCode = $this->getCountryISOCode();
57 | if($this->getState() !== null)
58 | $class->Address->Origin->state = $this->getState();
59 | }
60 |
61 | // Communication
62 | $class->Communication = new StdClass;
63 | if($this->getPhone() !== null)
64 | $class->Communication->phone = $this->getPhone();
65 | if($this->getEmail() !== null)
66 | $class->Communication->email = $this->getEmail();
67 | if($this->getContactPerson() !== null)
68 | $class->Communication->contactPerson = $this->getContactPerson();
69 |
70 | return $class;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/includes/LabelResponse.php:
--------------------------------------------------------------------------------
1 | Status-Code was not set
26 | * - Response::DHL_ERROR_NO_ERROR (0) -> No Error occurred
27 | * - Response::DHL_ERROR_WEAK_WARNING (1) -> A week warning has occurred
28 | * - Response::DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE (500) -> DHL-API Service is not available
29 | * - Response::DHL_ERROR_GENERAL (1000)-> General Error
30 | * - Response::DHL_ERROR_AUTH_FAILED (1001) -> Authentication has failed
31 | * - Response::DHL_ERROR_HARD_VAL_ERROR (1101) -> A hard-validation Error has occurred
32 | * - Response::DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER (2000) -> Given Shipment-Number is unknown
33 | *
34 | * @return int - Status-Code
35 | */
36 | function getStatusCode();
37 |
38 | /**
39 | * Getter for Status-Text
40 | *
41 | * @return string|null - Status-Text or null if not set
42 | */
43 | function getStatusText();
44 |
45 | /**
46 | * Getter for Status-Message
47 | *
48 | * @return string|null - Status-Message or null if not set
49 | */
50 | function getStatusMessage();
51 |
52 | /**
53 | * Getter for Sequence-Number
54 | *
55 | * @return string|null - Sequence-Number of the Request or null if not set
56 | */
57 | function getSequenceNumber();
58 |
59 | /**
60 | * Getter for Shipment-Number
61 | *
62 | * @return null|string - Shipment-Number or null if not set
63 | */
64 | function getShipmentNumber();
65 |
66 | /**
67 | * Getter for Label
68 | *
69 | * @return null|string - Label URL/Base64-Data (Can also contain the return label) or null if not set
70 | */
71 | function getLabel();
72 |
73 | /**
74 | * Getter for ReturnLabel
75 | *
76 | * @return null|string - Return Label-URL/Base64-Label-Data or null if not requested/set
77 | */
78 | function getReturnLabel();
79 |
80 | /**
81 | * Getter for Export-Document
82 | *
83 | * @return null|string - Export-Document Label-URL/Base64-Label-Data or null if not requested/set
84 | */
85 | function getExportDoc();
86 |
87 | /**
88 | * Getter for Cod-Label
89 | *
90 | * @return null|string - Cod-Label-URL/Base64-Data or null if not requested/set
91 | */
92 | function getCodLabel();
93 | }
94 |
--------------------------------------------------------------------------------
/includes/Version.php:
--------------------------------------------------------------------------------
1 | setVersion($version);
50 | }
51 |
52 | /**
53 | * Clears Memory
54 | */
55 | protected function __destruct() {
56 | unset($this->version);
57 | unset($this->mayor);
58 | unset($this->minor);
59 | }
60 |
61 | /**
62 | * Getter for Current-Version
63 | *
64 | * @return string - Current-Version
65 | */
66 | public function getVersion() {
67 | return $this->version;
68 | }
69 |
70 | /**
71 | * Set/Change the Version and also Update Mayor and Minor-Fields
72 | *
73 | * @param string $version - Version
74 | */
75 | protected function setVersion($version) {
76 | $this->version = $version;
77 |
78 | $numbers = explode('.', $version);
79 |
80 | // Update Mayor and Minor-Version-Numbers
81 | $this->setMayor((int) $numbers[0]);
82 | $this->setMinor((int) $numbers[1]);
83 | }
84 |
85 | /**
86 | * Getter for Mayor-Version-Number
87 | *
88 | * @return int - Mayor-Version-Number
89 | */
90 | public function getMayor() {
91 | return $this->mayor;
92 | }
93 |
94 | /**
95 | * Setter for Mayor-Version-Number
96 | *
97 | * @param int $mayor - Mayor-Version-Number
98 | */
99 | private function setMayor($mayor) {
100 | $this->mayor = $mayor;
101 | }
102 |
103 | /**
104 | * Getter for Minor-Version-Number
105 | *
106 | * @return int - Minor-Version-Number
107 | */
108 | public function getMinor() {
109 | return $this->minor;
110 | }
111 |
112 | /**
113 | * Setter for Minor-Version-Number
114 | *
115 | * @param int $minor - Minor-Version-Number
116 | */
117 | private function setMinor($minor) {
118 | $this->minor = $minor;
119 | }
120 |
121 | /**
122 | * Returns the Version DHL-Class
123 | *
124 | * @return StdClass - Version DHL-Class
125 | */
126 | protected function getVersionClass() {
127 | $class = new StdClass;
128 |
129 | $class->majorRelease = $this->getMayor();
130 | $class->minorRelease = $this->getMinor();
131 |
132 | return $class;
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/includes/PackStation.php:
--------------------------------------------------------------------------------
1 | postNumber);
50 | unset($this->packStationNumber);
51 | }
52 |
53 | /**
54 | * Get the Post-Number
55 | *
56 | * @return string - Post-Number
57 | */
58 | public function getPostNumber() {
59 | return $this->postNumber;
60 | }
61 |
62 | /**
63 | * Set the Post-Number
64 | *
65 | * @param string $postNumber - Post-Number
66 | */
67 | public function setPostNumber($postNumber) {
68 | $this->postNumber = $postNumber;
69 | }
70 |
71 | /**
72 | * Get the Pack-Station-Number
73 | *
74 | * @return string - Pack-station-Number
75 | */
76 | public function getPackStationNumber() {
77 | return $this->packStationNumber;
78 | }
79 |
80 | /**
81 | * Set the Pack-Station-Number
82 | *
83 | * @param string $packStationNumber - Pack-Station-Number
84 | */
85 | public function setPackStationNumber($packStationNumber) {
86 | $this->packStationNumber = $packStationNumber;
87 | }
88 |
89 | /**
90 | * Returns a Class for the DHL-SendPerson
91 | *
92 | * @return StdClass - DHL-SendPerson-class
93 | */
94 | public function getClass_v2() {
95 | $class = new StdClass;
96 | $class->name1 = $this->getName();
97 |
98 | $class->Communication = new StdClass;
99 | if($this->getPhone() !== null)
100 | $class->Communication->phone = $this->getPhone();
101 | if($this->getEmail() !== null)
102 | $class->Communication->email = $this->getEmail();
103 | if($this->getContactPerson() !== null)
104 | $class->Communication->contactPerson = $this->getContactPerson();
105 |
106 | $class->Packstation = new StdClass;
107 | $class->Packstation->postNumber = $this->getPostNumber();
108 | $class->Packstation->packstationNumber = $this->getPackStationNumber();
109 | $class->Packstation->zip = $this->getZip();
110 | $class->Packstation->city = $this->getLocation();
111 |
112 | if($this->getCountryISOCode() !== null) {
113 | $class->Packstation->Origin = new StdClass;
114 |
115 | if($this->getCountry() !== null)
116 | $class->Packstation->Origin->country = $this->getCountry();
117 |
118 | $class->Packstation->Origin->countryISOCode = $this->getCountryISOCode();
119 |
120 | if($this->getState() !== null)
121 | $class->Packstation->Origin->state = $this->getState();
122 | }
123 |
124 | return $class;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/includes/Filial.php:
--------------------------------------------------------------------------------
1 | postNumber);
50 | unset($this->filialNumber);
51 | }
52 |
53 | /**
54 | * Get the Post-Number
55 | *
56 | * @return string - Post-Number
57 | */
58 | public function getPostNumber() {
59 | return $this->postNumber;
60 | }
61 |
62 | /**
63 | * Set the Post-Number
64 | *
65 | * @param string $postNumber - Post-Number
66 | */
67 | public function setPostNumber($postNumber) {
68 | $this->postNumber = $postNumber;
69 | }
70 |
71 | /**
72 | * Get the Filial-Number
73 | *
74 | * @return string - Filial-Number
75 | */
76 | public function getFilialNumber() {
77 | return $this->filialNumber;
78 | }
79 |
80 | /**
81 | * Alias for $this->getFilialNumber
82 | *
83 | * @return string $filialNumber - Filial-Number
84 | */
85 | public function getPostFilialNumber() {
86 | return $this->filialNumber;
87 | }
88 |
89 | /**
90 | * Set the Filial-Number
91 | *
92 | * @param string $filialNumber - Filial-Number
93 | */
94 | public function setFilialNumber($filialNumber) {
95 | $this->filialNumber = $filialNumber;
96 | }
97 |
98 | /**
99 | * Alias for $this->setFilialNumber
100 | *
101 | * @param string $filialNumber - Filial-Number
102 | */
103 | public function setPostFilialNumber($filialNumber) {
104 | $this->filialNumber = $filialNumber;
105 | }
106 |
107 | /**
108 | * Returns a Class for the DHL-SendPerson
109 | *
110 | * @return StdClass - DHL-SendPerson-class
111 | */
112 | public function getClass_v2() {
113 | $class = new StdClass;
114 | $class->name1 = $this->getName();
115 |
116 | $class->Communication = new StdClass;
117 | if($this->getPhone() !== null)
118 | $class->Communication->phone = $this->getPhone();
119 | if($this->getEmail() !== null)
120 | $class->Communication->email = $this->getEmail();
121 | if($this->getContactPerson() !== null)
122 | $class->Communication->contactPerson = $this->getContactPerson();
123 |
124 | $class->Postfiliale = new StdClass;
125 | $class->Postfiliale->postfilialNumber = $this->getFilialNumber();
126 | $class->Postfiliale->postNumber = $this->getPostNumber();
127 | $class->Postfiliale->zip = $this->getZip();
128 | $class->Postfiliale->city = $this->getLocation();
129 |
130 | if($this->getCountryISOCode() !== null) {
131 | $class->Postfiliale->Origin = new StdClass;
132 |
133 | if($this->getCountry() !== null)
134 | $class->Postfiliale->Origin->country = $this->getCountry();
135 |
136 | $class->Postfiliale->Origin->countryISOCode = $this->getCountryISOCode();
137 |
138 | if($this->getState() !== null)
139 | $class->Postfiliale->Origin->state = $this->getState();
140 | }
141 |
142 | return $class;
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/includes/IdentCheck.php:
--------------------------------------------------------------------------------
1 | setLastName($lastName);
64 | $this->setFirstName($firstName);
65 | $this->setBirthday($birthday);
66 | $this->setMinimumAge($minimumAge);
67 | }
68 |
69 | /**
70 | * Clears Memory
71 | */
72 | public function __destruct() {
73 | unset($this->lastName);
74 | unset($this->firstName);
75 | unset($this->birthday);
76 | unset($this->minimumAge);
77 | }
78 |
79 | /**
80 | * Get the Last-Name
81 | *
82 | * @return string - Last-Name
83 | */
84 | public function getLastName() {
85 | return $this->lastName;
86 | }
87 |
88 | /**
89 | * Set the Last-Name
90 | *
91 | * @param string $lastName - Last-Name
92 | */
93 | private function setLastName($lastName) {
94 | $this->lastName = $lastName;
95 | }
96 |
97 | /**
98 | * Get the First-Name
99 | *
100 | * @return string - First-Name
101 | */
102 | public function getFirstName() {
103 | return $this->firstName;
104 | }
105 |
106 | /**
107 | * Set the First-Name
108 | *
109 | * @param string $firstName - First-Name
110 | */
111 | private function setFirstName($firstName) {
112 | $this->firstName = $firstName;
113 | }
114 |
115 | /**
116 | * Get the Birthday
117 | *
118 | * @return string - Birthday
119 | */
120 | public function getBirthday() {
121 | return $this->birthday;
122 | }
123 |
124 | /**
125 | * Set the Birthday
126 | *
127 | * @param string $birthday - Birthday
128 | */
129 | private function setBirthday($birthday) {
130 | $this->birthday = $birthday;
131 | }
132 |
133 | /**
134 | * Get the minimum Age
135 | *
136 | * @return int - Minimum Age
137 | */
138 | public function getMinimumAge() {
139 | return $this->minimumAge;
140 | }
141 |
142 | /**
143 | * Set the minimum Age
144 | *
145 | * @param int $minimumAge - Minimum Age
146 | */
147 | private function setMinimumAge($minimumAge) {
148 | $this->minimumAge = $minimumAge;
149 | }
150 |
151 | /**
152 | * Get the Ident-DHL-Class
153 | *
154 | * @return stdClass - Ident-DHL-Class
155 | *
156 | * @deprecated - DHL-API-Version 1 Method
157 | */
158 | public function getIdentClass_v1() {
159 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
160 | trigger_error('[DHL-PHP-SDK]: Called Version 1 Method: ' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
161 |
162 | return new StdClass;
163 | }
164 |
165 | /**
166 | * Get the Ident-DHL-Class
167 | *
168 | * @return StdClass - Ident-DHL-Class
169 | */
170 | public function getIdentClass_v2() {
171 | $class = new StdClass;
172 | $class->surname = $this->getLastName();
173 | $class->givenName = $this->getFirstName();
174 | $class->dateOfBirth = $this->getBirthday();
175 | $class->minimumAge = $this->getMinimumAge();
176 |
177 | return $class;
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # INACTIVE Repo
2 | ** This REPO is out of support ** Please checkout other repos or request examples from DHL
3 |
4 | In case you still have questions, you can send me an E-Mail or visit this Project on [Gitlab.com](https://gitlab.com/Petschko/dhl-php-sdk)
5 |
6 | # DHL PHP SDK
7 |
8 | This *unofficial* library is wrapping some functions of the DHL SOAP API in order to easy create/delete shipments and labels.
9 |
10 | ## Requirements
11 |
12 | - You need a [DHL developer Account](https://entwickler.dhl.de/) and - as long as you want to use the API in production systems - a DHL Intraship Account.
13 | - PHP-Version 5.4 or higher _(It may work on older Versions, but I don't offer Support for these)_
14 | - PHP-SOAP-Client installed + enabled on your Server. [More information on php.net](http://php.net/manual/en/soap.setup.php)
15 |
16 | ## Installation
17 |
18 | ### Composer
19 |
20 | You can use [Composer](https://getcomposer.org/) to install the package to your project:
21 |
22 | ```
23 | composer require petschko/dhl-php-sdk
24 | ```
25 |
26 | The classes are then added to the autoloader automatically.
27 |
28 | ### Without Composer
29 |
30 | If you can't use Composer (or don't want to), you can also use this SDK without it.
31 |
32 | To initial this SDK, just require the [_nonComposerLoader.php](https://github.com/Petschko/dhl-php-sdk/blob/master/includes/_nonComposerLoader.php)-File from the `/includes/` directory.
33 |
34 | ```php
35 | require_once(__DIR__ . '/includes/_nonComposerLoader.php');
36 | ```
37 |
38 | ## Compatibility
39 |
40 | This Project is written for the DHL-SOAP-API **Version 2 or higher**.
41 |
42 | ### API Version 3.0
43 |
44 | This Project is **currently** not available for Version 3.0+, I plan to update it soon! Please don't send me any E-Mails about this! If you want to talk about Version 3.0, please use the Issue for it: https://github.com/Petschko/dhl-php-sdk/issues/64
45 |
46 | #### Use BETA for Version 3.0
47 |
48 | You can still try out the dev-branch of this repo for Version 3:
49 |
50 | ```
51 | composer require petschko/dhl-php-sdk:dev-dev
52 | ```
53 |
54 | ### Version 1
55 |
56 | Version 1 Methods are marked as deprecated and will removed soon. Please upgrade to the API-Version 2 as soon as possible.
57 |
58 | ## Usage / Getting started
59 |
60 | - [Getting started (Just a quick guide how you have to use it)](https://github.com/Petschko/dhl-php-sdk/blob/master/examples/getting-started.md)
61 | - _More examples soon_
62 |
63 | Please have a look at the `examples` [Directory](https://github.com/Petschko/dhl-php-sdk/tree/master/examples). There you can find how to use this SDK also with Code-Examples, else check the _(Doxygen)_ [Documentation](http://docs.petschko.org/dhl-php-sdk/index.html) for deeper knowledge.
64 |
65 | ## Code Documentation
66 |
67 | You find Code-Examples with explanations in the `examples` Directory. I also explain how it works.
68 |
69 | You can find a Code-Reference here: _(Doxygen)_ http://docs.petschko.org/dhl-php-sdk/index.html
70 |
71 | ## Motivation
72 |
73 | I had a lot of pain studying and programming the DHL SOAP API - just to wrap some bits in a lot of XML. There is a lot, but not very helpful, documentation to the API. So I decided to create some functions in an easy to use and understand library.
74 |
75 | There is also a lot of old stuff in the Documentation, so that you can not sure if it is right...
76 |
77 | ## Credits
78 |
79 | All these Persons helped to create this SDK for the DHL-API:
80 | - [aschempp](https://github.com/aschempp) - For the help with the Notification E-Mail
81 | - [cedricziel](https://github.com/cedricziel) - For turning this Project into a [Composer](https://getcomposer.org/)-Package
82 | - [Dakror](https://github.com/Dakror) - For the `ProductInfo`-Class
83 | - [octlabs](https://github.com/octlabs) - For adding some missing Documentation
84 | - [Petschko](https://github.com/Petschko) - Initially created this Project and decided to share it for free
85 | - [tobias-redmann](https://github.com/tobias-redmann) - For the `setFullStreet` method and the PHP-DHL-Example-Project for Version 1 _(This helped a lot to understand how the API works)_
86 |
87 |
88 | ## Donate
89 |
90 | If you like this Project may consider to [Donate](https://www.paypal.me/petschko). I usually do this Project in my spare time and it's completely free. So I appreciate anything, which helps the Project (Pull-Requests, Bug Report etc), these are more worth than Donations but I'm happy for every amount as well. ^.^
91 |
92 | ## Contact
93 |
94 | - You can E-Mail me if you have Questions or whatever (No Bug-Reporting please!): peter@petschko.org
95 | - You can Chat with me in Telegram `@petschkoo`
96 | - You can Report Bugs here in the "[Issue](https://github.com/Petschko/dhl-php-sdk/issues)"-Section of the Project.
97 | - Of course you can also ask any stuff there, feel free for that!
98 | - If you want to use German, you can do it. Please keep in mind that not everybody can speak German, so it's better to use english =)
99 |
--------------------------------------------------------------------------------
/includes/SendPerson.php:
--------------------------------------------------------------------------------
1 | name);
95 | unset($this->name2);
96 | unset($this->name3);
97 | unset($this->phone);
98 | unset($this->email);
99 | unset($this->contactPerson);
100 | }
101 |
102 | /**
103 | * Get the Name
104 | *
105 | * @return string - Name
106 | */
107 | public function getName() {
108 | return $this->name;
109 | }
110 |
111 | /**
112 | * Set the Name
113 | *
114 | * @param string $name - Name
115 | */
116 | public function setName($name) {
117 | $this->name = $name;
118 | }
119 |
120 | /**
121 | * Get the Name2 Field
122 | *
123 | * @return null|string - Name2 or null if none
124 | */
125 | public function getName2() {
126 | return $this->name2;
127 | }
128 |
129 | /**
130 | * Set the Name2 Field
131 | *
132 | * @param null|string $name2 - Name2 or null for none
133 | */
134 | public function setName2($name2) {
135 | $this->name2 = $name2;
136 | }
137 |
138 | /**
139 | * Get the Name3 Field
140 | *
141 | * @return null|string - Name3 or null if none
142 | */
143 | public function getName3() {
144 | return $this->name3;
145 | }
146 |
147 | /**
148 | * Set the Name3 Field
149 | *
150 | * @param null|string $name3 - Name3 or null for none
151 | */
152 | public function setName3($name3) {
153 | $this->name3 = $name3;
154 | }
155 |
156 | /**
157 | * Get the Phone
158 | *
159 | * @return null|string - Phone or null if none
160 | */
161 | public function getPhone() {
162 | return $this->phone;
163 | }
164 |
165 | /**
166 | * Set the Phone
167 | *
168 | * @param null|string $phone - Phone or null for none
169 | */
170 | public function setPhone($phone) {
171 | $this->phone = $phone;
172 | }
173 |
174 | /**
175 | * Get the E-Mail
176 | *
177 | * @return null|string - E-Mail or null if none
178 | */
179 | public function getEmail() {
180 | return $this->email;
181 | }
182 |
183 | /**
184 | * Set the E-Mail
185 | *
186 | * @param null|string $email - E-Mail or null for none
187 | */
188 | public function setEmail($email) {
189 | $this->email = $email;
190 | }
191 |
192 | /**
193 | * Get the Contact-Person
194 | *
195 | * @return null|string - Contact-Person or null if none
196 | */
197 | public function getContactPerson() {
198 | return $this->contactPerson;
199 | }
200 |
201 | /**
202 | * Set the Contact-Person
203 | *
204 | * @param null|string $contactPerson - Contact-Person or null for none
205 | */
206 | public function setContactPerson($contactPerson) {
207 | $this->contactPerson = $contactPerson;
208 | }
209 |
210 |
211 | /**
212 | * Returns a Class for the DHL-SendPerson
213 | *
214 | * @return StdClass - DHL-SendPerson-class
215 | *
216 | * @deprecated - DHL-API-Version 1 Method
217 | */
218 | public function getClass_v1() {
219 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
220 | trigger_error('[DHL-PHP-SDK]: Called Version 1 Method: ' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
221 |
222 | return new StdClass;
223 | }
224 |
225 | /**
226 | * Returns a Class for the DHL-SendPerson
227 | *
228 | * @return StdClass - DHL-SendPerson-class
229 | */
230 | abstract public function getClass_v2();
231 | }
232 |
--------------------------------------------------------------------------------
/includes/BankData.php:
--------------------------------------------------------------------------------
1 | accountOwnerName);
110 | unset($this->bankName);
111 | unset($this->iban);
112 | unset($this->note1);
113 | unset($this->note2);
114 | unset($this->bic);
115 | unset($this->accountReference);
116 | }
117 |
118 | /**
119 | * Get the Account Owner Name
120 | *
121 | * @return string - Account Owner Name
122 | */
123 | public function getAccountOwnerName() {
124 | return $this->accountOwnerName;
125 | }
126 |
127 | /**
128 | * Set the Account Owner Name
129 | *
130 | * @param string $accountOwnerName - Account Owner Name
131 | */
132 | public function setAccountOwnerName($accountOwnerName) {
133 | $this->accountOwnerName = $accountOwnerName;
134 | }
135 |
136 | /**
137 | * Get the Bank-Name
138 | *
139 | * @return string - Bank-Name
140 | */
141 | public function getBankName() {
142 | return $this->bankName;
143 | }
144 |
145 | /**
146 | * Set the Bank-Name
147 | *
148 | * @param string $bankName - Bank-Name
149 | */
150 | public function setBankName($bankName) {
151 | $this->bankName = $bankName;
152 | }
153 |
154 | /**
155 | * Get the IBAN
156 | *
157 | * @return string - IBAN
158 | */
159 | public function getIban() {
160 | return $this->iban;
161 | }
162 |
163 | /**
164 | * Set the IBAN
165 | *
166 | * @param string $iban - IBAN
167 | */
168 | public function setIban($iban) {
169 | $this->iban = $iban;
170 | }
171 |
172 | /**
173 | * Get additional Bank-Note (1)
174 | *
175 | * @return null|string - Bank-Note (1) or null for none
176 | */
177 | public function getNote1() {
178 | return $this->note1;
179 | }
180 |
181 | /**
182 | * Set addition Bank-Note (1)
183 | *
184 | * @param null|string $note1 - Bank-Note (1) or null for none
185 | */
186 | public function setNote1($note1) {
187 | $this->note1 = $note1;
188 | }
189 |
190 | /**
191 | * Get additional Bank-Note (2)
192 | *
193 | * @return null|string - Bank-Note (2) or null for none
194 | */
195 | public function getNote2() {
196 | return $this->note2;
197 | }
198 |
199 | /**
200 | * Set additional Bank-Note (2)
201 | *
202 | * @param null|string $note2 - Bank-Note (2) or null for none
203 | */
204 | public function setNote2($note2) {
205 | $this->note2 = $note2;
206 | }
207 |
208 | /**
209 | * Get the BIC
210 | *
211 | * @return null|string - BIC or null for none
212 | */
213 | public function getBic() {
214 | return $this->bic;
215 | }
216 |
217 | /**
218 | * Set the BIC
219 | *
220 | * @param null|string $bic - BIC or null for none
221 | */
222 | public function setBic($bic) {
223 | $this->bic = $bic;
224 | }
225 |
226 | /**
227 | * Get the Account reference
228 | *
229 | * @return null|string - Account reference or null for none
230 | */
231 | public function getAccountReference() {
232 | return $this->accountReference;
233 | }
234 |
235 | /**
236 | * Set the Account reference
237 | *
238 | * @param null|string $accountReference - Account reference or null for none
239 | */
240 | public function setAccountReference($accountReference) {
241 | $this->accountReference = $accountReference;
242 | }
243 |
244 | /**
245 | * Returns a DHL-Bank-Class for API v1
246 | *
247 | * @return stdClass - DHL-Bank-Class
248 | *
249 | * @deprecated - DHL-API-Version 1 Method
250 | */
251 | public function getBankClass_v1() {
252 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
253 | trigger_error('[DHL-PHP-SDK]: Called Version 1 Method: ' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
254 |
255 | return new StdClass;
256 | }
257 |
258 | /**
259 | * Returns a DHL-Bank-Class for API v2
260 | *
261 | * @return StdClass - DHL-Bank-Class
262 | */
263 | public function getBankClass_v2() {
264 | $class = new StdClass;
265 |
266 | $class->accountOwner = $this->getAccountOwnerName();
267 | $class->bankName = $this->getBankName();
268 | $class->iban = $this->getIban();
269 | if($this->getNote1() !== null)
270 | $class->note1 = $this->getNote1();
271 | if($this->getNote2() !== null)
272 | $class->note2 = $this->getNote2();
273 | if($this->getBic() !== null)
274 | $class->bic = $this->getBic();
275 | if($this->getAccountReference() !== null)
276 | $class->accountreference = $this->getAccountReference();
277 |
278 | return $class;
279 | }
280 | }
281 |
--------------------------------------------------------------------------------
/test.php:
--------------------------------------------------------------------------------
1 | setUser('Your-DHL-Account'); // Don't needed if initialed with Test-Mode
25 | $credentials->setSignature('Your-DHL-Account-Password'); // Don't needed if initialed with Test-Mode
26 | $credentials->setEkp('EKP-Account-Number'); // Don't needed if initialed with Test-Mode
27 | }
28 |
29 | // Set your API-Login
30 | $credentials->setApiUser(''); // Test-Mode: Your DHL-Dev-Account (Developer-ID NOT E-Mail!!) | Production: Your Applications-ID
31 | $credentials->setApiPassword(''); // Test-Mode: Your DHL-Dev-Account Password | Production: Your Applications-Token
32 |
33 | // Set Service stuff (look at the class member - many settings here - just set them you need)
34 | $service = new Service();
35 | // Set stuff you want in that class - This is very optional
36 |
37 | // Set Shipment Details
38 | $shipmentDetails = new ShipmentDetails($credentials->getEkp(10) . '0101'); // Create a Shipment-Details with the first 10 digits of your EKP-Number and 0101 (?)
39 | $shipmentDetails->setShipmentDate('2018-09-20'); // Optional: Need to be in the future and NOT on a sunday | null or drop it, to use today
40 | $shipmentDetails->setNotificationEmail('mail@inform.me'); // Needed if you want inform the receiver via mail
41 | //$shipmentDetails->setReturnAccountNumber($credentials->getEkp(10) . '0701'); // Needed if you want to print a return label
42 | //$shipmentDetails->setReturnReference($reference); // Only needed if you want to print a return label
43 | $shipmentDetails->setService($service); // Optional, just needed if you add some services
44 | // $shipmentDetails->setBank($bank); // Very optional, you need to add the Bank Object, whenever you need it here
45 |
46 | // Set Sender
47 | $sender = new Sender();
48 | $sender->setName('Peter Muster');
49 | $sender->setStreetName('Test Straße');
50 | $sender->setStreetNumber('12a');
51 | $sender->setZip('21037');
52 | $sender->setCity('Hamburg');
53 | $sender->setCountry('Germany');
54 | $sender->setCountryISOCode('DE');
55 | // $sender->setEmail('peter@petschko.org'); // These are super optional, it will printed on the label, can set under receiver as well
56 | // $sender->setPhone('015774121861');
57 | // $sender->setContactPerson('Anna Muster');
58 |
59 | // Set Receiver
60 | $receiver = new Receiver();
61 | $receiver->setName('Test Empfänger');
62 | $receiver->setStreetName('Test Straße');
63 | $receiver->setStreetNumber('23b');
64 | $receiver->setZip('21037');
65 | $receiver->setCity('Hamburg');
66 | $receiver->setCountry('Germany');
67 | $receiver->setCountryISOCode('DE');
68 |
69 | $returnReceiver = new ReturnReceiver(); // Needed if you want to print an return label
70 | // If want to use it, please set Address etc of the return receiver to!
71 |
72 | // Required just Credentials also accept Test-Mode and Version
73 | $dhl = new BusinessShipment($credentials, /*Optional*/$testMode, /*Optional*/$version);
74 |
75 | // You can add your own API-File (if you want to use a remote one or your own) - else you don't need this
76 | //$dhl->setCustomAPIURL('http://myserver.com/myAPIFile.wsdl');
77 |
78 | // Don't forget to assign the created objects to the ShipmentOrder Object!
79 | $shipmentOrder = new ShipmentOrder();
80 | $shipmentOrder->setSequenceNumber($reference); // Just needed to identify the shipment if you do multiple
81 | $shipmentOrder->setSender($sender);
82 | $shipmentOrder->setReceiver($receiver); // You can set these Object-Types here: DHL_Filial, DHL_Receiver & DHL_PackStation
83 | //$shipmentOrder->setReturnReceiver($returnReceiver); // Needed if you want print a return label
84 | $shipmentOrder->setShipmentDetails($shipmentDetails);
85 | $shipmentOrder->setLabelResponseType(BusinessShipment::RESPONSE_TYPE_URL);
86 |
87 | // Add the ShipmentOrder to the BusinessShipment Object, you can add up to 30 ShipmentOrder Objects in 1 call
88 | $dhl->addShipmentOrder($shipmentOrder);
89 |
90 | $response = $dhl->createShipment(); // Creates the request
91 |
92 | // For deletion you just need the shipment number and credentials
93 | // $dhlDel = new BusinessShipment($credentials, $testMode, $version);
94 | // $response_del = $dhlDel->deleteShipment('shipment_number'); // Deletes a Shipment
95 | // $response_del = $dhlDel->deleteShipment(array('shipment_number1', 'shipment_number2')); // Deletes multiple Shipments (up to 30)
96 |
97 | // To re-get the Label you can use the getShipmentLabel method - the shipment must be created with createShipment before
98 | //$dhlReGetLabel = new BusinessShipment($credentials, $testMode, $version);
99 | //$dhlReGetLabel->setLabelResponseType(DHL_BusinessShipment::RESPONSE_TYPE_B64); // Optional: Set the Label-Response-Type
100 | //$reGetLabelResponse = $dhlReGetLabel->getLabel('shipment_number'); // ReGet a single Label
101 | //$reGetLabelResponse = $dhlReGetLabel->getLabel(array('shipment_number1', 'shipment_number2')); // ReGet multiple Labels (up to 30)
102 |
103 | // To do a Manifest-Request you can use the doManifest method - you have to provide a Shipment-Number
104 | //$manifestDHL = new BusinessShipment($credentials, $testMode, $version);
105 | //$manifestResponse = $manifestDHL->doManifest('shipment_number'); // Does Manifest on a Shipment
106 | //$manifestResponse = $manifestDHL->doManifest(array('shipment_number1', 'shipment_number2')); // Does Manifest on multiple Shipments (up to 30)
107 |
108 | // To do a Manifest-Request you can use the doManifest method - you have to provide a Shipment-Number
109 | //$getManifestDHL = new BusinessShipment($credentials, $testMode, $version);
110 | //$getManifestResponse = $getManifestDHL->getManifest('YYYY-MM-DD'); // Need to be in the past or today after doManifest()
111 |
112 | // Get the result (just use var_dump to show all results)
113 | if($response !== false)
114 | var_dump($response);
115 | else
116 | var_dump($dhl->getErrors());
117 |
118 | // You can show yourself also the XML-Request as string
119 | var_dump($dhl->getLastXML());
120 |
--------------------------------------------------------------------------------
/includes/Product.php:
--------------------------------------------------------------------------------
1 | setType($type);
104 | }
105 |
106 | /**
107 | * Clears Memory
108 | */
109 | public function __destruct() {
110 | unset($this->type);
111 | unset($this->name);
112 | unset($this->austria);
113 | unset($this->minLength);
114 | unset($this->maxLength);
115 | unset($this->minWidth);
116 | unset($this->maxWidth);
117 | unset($this->minHeight);
118 | unset($this->maxHeight);
119 | unset($this->maxWeight);
120 | unset($this->services);
121 | }
122 |
123 | /**
124 | * Get the Product-Type
125 | *
126 | * @return string - Product-Type
127 | */
128 | public function getType() {
129 | return $this->type;
130 | }
131 |
132 | /**
133 | * Set the Product-Type
134 | *
135 | * @param string $type - Product-Type
136 | */
137 | private function setType($type) {
138 | $this->type = $type;
139 | }
140 |
141 | /**
142 | * Get the Name
143 | *
144 | * @return string - Name
145 | */
146 | public function getName() {
147 | return $this->name;
148 | }
149 |
150 | /**
151 | * Set the Name
152 | *
153 | * @param string $name - Name
154 | */
155 | public function setName($name) {
156 | $this->name = $name;
157 | }
158 |
159 | /**
160 | * Shows if send to Austria is allowed
161 | *
162 | * @return bool - Is send to Austria allowed
163 | */
164 | public function isAustria() {
165 | return $this->austria;
166 | }
167 |
168 | /**
169 | * Set if send to Austria is allowed
170 | *
171 | * @param bool $austria - Is send to Austria allowed
172 | */
173 | public function setAustria($austria) {
174 | $this->austria = $austria;
175 | }
176 |
177 | /**
178 | * Get the Min-Length
179 | *
180 | * @return float|int - Min-Length
181 | */
182 | public function getMinLength() {
183 | return $this->minLength;
184 | }
185 |
186 | /**
187 | * Set the Min-Length
188 | *
189 | * @param float|int $minLength - Min-Length
190 | */
191 | public function setMinLength($minLength) {
192 | $this->minLength = $minLength;
193 | }
194 |
195 | /**
196 | * Get the Max-Length
197 | *
198 | * @return float|int - Max-Length
199 | */
200 | public function getMaxLength() {
201 | return $this->maxLength;
202 | }
203 |
204 | /**
205 | * Set the Max-Length
206 | *
207 | * @param float|int $maxLength - Max-Length
208 | */
209 | public function setMaxLength($maxLength) {
210 | $this->maxLength = $maxLength;
211 | }
212 |
213 | /**
214 | * Get the Min-Width
215 | *
216 | * @return float|int - Min-Width
217 | */
218 | public function getMinWidth() {
219 | return $this->minWidth;
220 | }
221 |
222 | /**
223 | * Set the Min-Width
224 | *
225 | * @param float|int $minWidth - Min-Width
226 | */
227 | public function setMinWidth($minWidth) {
228 | $this->minWidth = $minWidth;
229 | }
230 |
231 | /**
232 | * Get the Max-Width
233 | *
234 | * @return float|int - Max-Width
235 | */
236 | public function getMaxWidth() {
237 | return $this->maxWidth;
238 | }
239 |
240 | /**
241 | * Set the Max-Width
242 | *
243 | * @param float|int $maxWidth - Max-Width
244 | */
245 | public function setMaxWidth($maxWidth) {
246 | $this->maxWidth = $maxWidth;
247 | }
248 |
249 | /**
250 | * Get the Min-Height
251 | *
252 | * @return float|int - Min-Height
253 | */
254 | public function getMinHeight() {
255 | return $this->minHeight;
256 | }
257 |
258 | /**
259 | * Set the Min-Height
260 | *
261 | * @param float|int $minHeight - Min-Height
262 | */
263 | public function setMinHeight($minHeight) {
264 | $this->minHeight = $minHeight;
265 | }
266 |
267 | /**
268 | * Get the Max-Height
269 | *
270 | * @return float|int - Max-Height
271 | */
272 | public function getMaxHeight() {
273 | return $this->maxHeight;
274 | }
275 |
276 | /**
277 | * Set the Max-Height
278 | *
279 | * @param float|int $maxHeight - Max-Height
280 | */
281 | public function setMaxHeight($maxHeight) {
282 | $this->maxHeight = $maxHeight;
283 | }
284 |
285 | /**
286 | * Get the Max-Weight
287 | *
288 | * @return float|int - Max-Weight
289 | */
290 | public function getMaxWeight() {
291 | return $this->maxWeight;
292 | }
293 |
294 | /**
295 | * Set the Max-Weight
296 | *
297 | * @param float|int $maxWeight - Max-Weight
298 | */
299 | public function setMaxWeight($maxWeight) {
300 | $this->maxWeight = $maxWeight;
301 | }
302 |
303 | /**
304 | * Get the Services
305 | *
306 | * @return string[] - Services
307 | */
308 | public function getServices() {
309 | return $this->services;
310 | }
311 |
312 | /**
313 | * Set Services
314 | *
315 | * @param string[] $services - Services
316 | */
317 | public function setServices($services) {
318 | $this->services = $services;
319 | }
320 |
321 | /**
322 | * Adds a Service
323 | *
324 | * @param string $service - Service to add
325 | */
326 | public function addService($service) {
327 | $this->services[] = $service;
328 | }
329 |
330 | /**
331 | * Checks if this Products has a Service
332 | *
333 | * @param string $service - Service to check
334 | * @return bool - Has this Product this Service
335 | */
336 | public function hasService($service) {
337 | return in_array($service, $this->services);
338 | }
339 | }
340 |
--------------------------------------------------------------------------------
/includes/ExportDocPosition.php:
--------------------------------------------------------------------------------
1 | ' . __FUNCTION__ .
90 | ': All values must be filled out! (Not null, Not false, Not 0, Not "", Not empty) - Ignore this function for this call now', E_USER_WARNING);
91 | error_log('PHP-DHL-API: ' . __CLASS__ . '->' . __FUNCTION__ .
92 | ': All values must be filled out! (Not null, Not false, Not 0, Not "", Not empty) - Ignore this function for this call now', E_USER_WARNING);
93 | return;
94 | }
95 |
96 | $this->setDescription($description);
97 | $this->setCountryCodeOrigin($countryCodeOrigin);
98 | $this->setCustomsTariffNumber($customsTariffNumber);
99 | $this->setAmount($amount);
100 | $this->setNetWeightInKG((float) $netWeightInKG);
101 | $this->setCustomsValue((float) $customsValue);
102 | }
103 |
104 | /**
105 | * Clears Memory
106 | */
107 | public function __destruct() {
108 | unset($this->description);
109 | unset($this->countryCodeOrigin);
110 | unset($this->customsTariffNumber);
111 | unset($this->amount);
112 | unset($this->netWeightInKG);
113 | unset($this->customsValue);
114 | }
115 |
116 | /**
117 | * Get the Description
118 | *
119 | * @return string|null - Description or null on failure
120 | */
121 | public function getDescription() {
122 | return $this->description;
123 | }
124 |
125 | /**
126 | * Set the Description
127 | *
128 | * @param string $description - Description
129 | */
130 | private function setDescription($description) {
131 | $this->description = $description;
132 | }
133 |
134 | /**
135 | * Get the Country Code Origin
136 | *
137 | * @return string|null - Country Code Origin or null on failure
138 | */
139 | public function getCountryCodeOrigin() {
140 | return $this->countryCodeOrigin;
141 | }
142 |
143 | /**
144 | * Set the Country Code Origin
145 | *
146 | * @param string $countryCodeOrigin - Country Code Origin
147 | */
148 | private function setCountryCodeOrigin($countryCodeOrigin) {
149 | $this->countryCodeOrigin = $countryCodeOrigin;
150 | }
151 |
152 | /**
153 | * Get the Custom Tariff Number
154 | *
155 | * @return float|int|string|null - Custom Tariff Number or null for none
156 | */
157 | public function getCustomsTariffNumber() {
158 | return $this->customsTariffNumber;
159 | }
160 |
161 | /**
162 | * Set the Custom Tariff Number
163 | *
164 | * @param float|int|string|null $customsTariffNumber - Custom Tariff Number or null for none
165 | */
166 | private function setCustomsTariffNumber($customsTariffNumber) {
167 | $this->customsTariffNumber = $customsTariffNumber;
168 | }
169 |
170 | /**
171 | * Get the Amount
172 | *
173 | * @return int|null - Amount or null on failure
174 | */
175 | public function getAmount() {
176 | return $this->amount;
177 | }
178 |
179 | /**
180 | * Set the Amount
181 | *
182 | * @param int $amount - Amount
183 | */
184 | private function setAmount($amount) {
185 | $this->amount = $amount;
186 | }
187 |
188 | /**
189 | * Get the Weight in KG
190 | *
191 | * @return float|null - Weight in KG or null on failure
192 | */
193 | public function getNetWeightInKG() {
194 | return $this->netWeightInKG;
195 | }
196 |
197 | /**
198 | * Set the Weight in KG
199 | *
200 | * @param float $netWeightInKG - Weight in KG
201 | */
202 | private function setNetWeightInKG($netWeightInKG) {
203 | $this->netWeightInKG = $netWeightInKG;
204 | }
205 |
206 | /**
207 | * Get the Customs Value for the Unit / Package
208 | *
209 | * @return float|null - Custom Value for the Unit / Package or null on failure
210 | */
211 | public function getCustomsValue() {
212 | return $this->customsValue;
213 | }
214 |
215 | /**
216 | * Sets the Customs Value for the Unit / Package
217 | *
218 | * @param float $customsValue - Customs Value for the Unit / Package
219 | */
220 | private function setCustomsValue($customsValue) {
221 | $this->customsValue = $customsValue;
222 | }
223 |
224 | /**
225 | * Returns a Class for ExportDocPosition
226 | *
227 | * @return StdClass - DHL-ExportDocPosition-Class
228 | *
229 | * @deprecated - DHL-API-Version 1 Method
230 | */
231 | protected function getExportDocPositionClass_v1() {
232 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
233 | trigger_error('[DHL-PHP-SDK]: Called Version 1 Method: ' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
234 |
235 | $class = new StdClass;
236 |
237 | return $class;
238 | }
239 |
240 | /**
241 | * Returns a Class for ExportDocPosition
242 | *
243 | * @return StdClass - DHL-ExportDocPosition-Class
244 | */
245 | public function getExportDocPositionClass_v2() {
246 | $class = new StdClass;
247 |
248 | $class->description = $this->getDescription();
249 | $class->countryCodeOrigin = $this->getCountryCodeOrigin();
250 | $class->customsTariffNumber = $this->getCustomsTariffNumber();
251 | $class->amount = $this->getAmount();
252 | $class->netWeightInKG = $this->getNetWeightInKG();
253 | $class->customsValue = $this->getCustomsValue();
254 |
255 | return $class;
256 | }
257 | }
258 |
--------------------------------------------------------------------------------
/includes/Credentials.php:
--------------------------------------------------------------------------------
1 | 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 |
146 | /**
147 | * Clears Memory
148 | */
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 |
157 | /**
158 | * Get the DHL-Intraship Username
159 | *
160 | * @return string - DHL-Intraship Username
161 | */
162 | public function getUser() {
163 | return $this->user;
164 | }
165 |
166 | /**
167 | * Sets the DHL-Intraship Username in lower case
168 | *
169 | * @param string $user - DHL-Intraship Username
170 | */
171 | public function setUser($user) {
172 | $this->user = mb_strtolower($user);
173 | }
174 |
175 | /**
176 | * Get the DHL-Intraship Password
177 | *
178 | * @return string - DHL-Intraship Password
179 | */
180 | public function getSignature() {
181 | return $this->signature;
182 | }
183 |
184 | /**
185 | * Set the DHL-Intraship Password
186 | *
187 | * @param string $signature - DHL-Intraship Password
188 | */
189 | public function setSignature($signature) {
190 | $this->signature = $signature;
191 | }
192 |
193 | /**
194 | * Get the (x first Digits of the) EKP
195 | *
196 | * @param null|int $len - Max-Chars to get from this String or null for all
197 | * @return string - EKP-Number with x Chars
198 | */
199 | public function getEkp($len = null) {
200 | return mb_substr($this->ekp, 0, $len);
201 | }
202 |
203 | /**
204 | * Alias for $this->getEkp
205 | *
206 | * @param null|int $len - Max-Chars to get from this String or null for all
207 | * @return string - EKP-Number with x Chars
208 | *
209 | * @deprecated - Invalid name of the function
210 | */
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 |
217 | /**
218 | * Set the EKP-Number
219 | *
220 | * @param string $ekp - EKP-Number
221 | */
222 | public function setEkp($ekp) {
223 | $this->ekp = $ekp;
224 | }
225 |
226 | /**
227 | * Alias for $this->setEkp
228 | *
229 | * @param string $ekp - EKP-Number
230 | *
231 | * @deprecated - Invalid name of the function
232 | */
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 |
239 | /**
240 | * Get the API-User
241 | *
242 | * @return string - API-User
243 | */
244 | public function getApiUser() {
245 | return $this->apiUser;
246 | }
247 |
248 | /**
249 | * Set the API-User
250 | *
251 | * @param string $apiUser - API-User
252 | */
253 | public function setApiUser($apiUser) {
254 | $this->apiUser = $apiUser;
255 | }
256 |
257 | /**
258 | * Get the API-Password/Key
259 | *
260 | * @return string - API-Password/Key
261 | */
262 | public function getApiPassword() {
263 | return $this->apiPassword;
264 | }
265 |
266 | /**
267 | * Alias for $this->getApiPassword
268 | *
269 | * @return string - API-Password/Key
270 | */
271 | public function getApiKey() {
272 | return $this->getApiPassword();
273 | }
274 |
275 | /**
276 | * Set the API-Password/Key
277 | *
278 | * @param string $apiPassword - API-Password/Key
279 | */
280 | public function setApiPassword($apiPassword) {
281 | $this->apiPassword = $apiPassword;
282 | }
283 |
284 | /**
285 | * Alias for $this->setApiPassword
286 | *
287 | * @param string $apiKey - API-Password/Key
288 | */
289 | public function setApiKey($apiKey) {
290 | $this->setApiPassword($apiKey);
291 | }
292 | }
293 |
--------------------------------------------------------------------------------
/includes/Address.php:
--------------------------------------------------------------------------------
1 | streetName);
129 | unset($this->streetNumber);
130 | unset($this->addressAddition);
131 | unset($this->dispatchingInfo);
132 | unset($this->zip);
133 | unset($this->location);
134 | unset($this->country);
135 | unset($this->countryISOCode);
136 | unset($this->state);
137 | }
138 |
139 | /**
140 | * Get the Street name
141 | *
142 | * @return string - Street name
143 | */
144 | public function getStreetName() {
145 | return $this->streetName;
146 | }
147 |
148 | /**
149 | * Set the Street name
150 | *
151 | * @param string $streetName - Street name
152 | */
153 | public function setStreetName($streetName) {
154 | $this->streetName = $streetName;
155 | }
156 |
157 | /**
158 | * Get the Street number
159 | *
160 | * @return string - Street Number
161 | */
162 | public function getStreetNumber() {
163 | return $this->streetNumber;
164 | }
165 |
166 | /**
167 | * Set the Street number
168 | *
169 | * @param string $streetNumber - Street Number
170 | */
171 | public function setStreetNumber($streetNumber) {
172 | $this->streetNumber = $streetNumber;
173 | }
174 |
175 | /**
176 | * Get the Address addition
177 | *
178 | * @return null|string - Address addition or null for none
179 | */
180 | public function getAddressAddition() {
181 | return $this->addressAddition;
182 | }
183 |
184 | /**
185 | * Set the Address addition
186 | *
187 | * @param null|string $addressAddition - Address addition or null for none
188 | */
189 | public function setAddressAddition($addressAddition) {
190 | $this->addressAddition = $addressAddition;
191 | }
192 |
193 | /**
194 | * Get the Dispatching-Info
195 | *
196 | * @return null|string - Dispatching-Info or null for none
197 | */
198 | public function getDispatchingInfo() {
199 | return $this->dispatchingInfo;
200 | }
201 |
202 | /**
203 | * Set the Dispatching-Info
204 | *
205 | * @param null|string $dispatchingInfo - Dispatching-Info or null for none
206 | */
207 | public function setDispatchingInfo($dispatchingInfo) {
208 | $this->dispatchingInfo = $dispatchingInfo;
209 | }
210 |
211 | /**
212 | * Get the ZIP
213 | *
214 | * @return string - ZIP
215 | */
216 | public function getZip() {
217 | return $this->zip;
218 | }
219 |
220 | /**
221 | * Set the ZIP
222 | *
223 | * @param string $zip - ZIP
224 | */
225 | public function setZip($zip) {
226 | $this->zip = $zip;
227 | }
228 |
229 | /**
230 | * Get the Location
231 | *
232 | * @return string - Location
233 | */
234 | public function getLocation() {
235 | return $this->location;
236 | }
237 |
238 | /**
239 | * Set the Location
240 | *
241 | * @param string $location - Location
242 | */
243 | public function setLocation($location) {
244 | $this->location = $location;
245 | }
246 |
247 | /**
248 | * Alias for $this->getLocation
249 | *
250 | * @return string - Location
251 | */
252 | public function getCity() {
253 | return $this->location;
254 | }
255 |
256 | /**
257 | * Alias for $this->setLocation
258 | *
259 | * @param string $city - Location
260 | */
261 | public function setCity($city) {
262 | $this->location = $city;
263 | }
264 |
265 | /**
266 | * Get the Country
267 | *
268 | * @return string|null - Country or null for none
269 | */
270 | public function getCountry() {
271 | return $this->country;
272 | }
273 |
274 | /**
275 | * Set the Country
276 | *
277 | * @param string|null $country - Country or null for none
278 | */
279 | public final function setCountry($country) {
280 | if($country !== null)
281 | $this->country = mb_strtolower($country);
282 | else
283 | $this->country = null;
284 | }
285 |
286 | /**
287 | * Get the Country-ISO-Code
288 | *
289 | * @return string|null - Country-ISO-Code or null for none
290 | */
291 | public function getCountryISOCode() {
292 | return $this->countryISOCode;
293 | }
294 |
295 | /**
296 | * Set the Country-ISO-Code
297 | *
298 | * @param string|null $countryISOCode - Country-ISO-Code or null for none
299 | */
300 | public final function setCountryISOCode($countryISOCode) {
301 | if($countryISOCode !== null)
302 | $this->countryISOCode = mb_strtoupper($countryISOCode);
303 | else
304 | $this->countryISOCode = null;
305 | }
306 |
307 | /**
308 | * Get the State (Geo-Location)
309 | *
310 | * @return null|string - State (Geo-Location) or null for none
311 | */
312 | public function getState() {
313 | return $this->state;
314 | }
315 |
316 | /**
317 | * Set the State (Geo-Location)
318 | *
319 | * @param null|string $state - State (Geo-Location) or null for none
320 | */
321 | public function setState($state) {
322 | $this->state = $state;
323 | }
324 |
325 | /**
326 | * Sets Street-Name and Number by Address String
327 | *
328 | * Found here: https://www.tricd.de/php/php-strassenname-und-hausnummer-mit-php-parsen/
329 | *
330 | * @param string $street - Address (Street plus number)
331 | *
332 | * @deprecated - Buggy on some addresses, please separate the number and street by yourself
333 | */
334 | public final function setFullStreet($street) {
335 | trigger_error('[DHL-PHP-SDK]: Called deprecated method ' . __METHOD__ . ': Buggy on some addresses, please separate the number and street by yourself. This method will removed in the future!', E_USER_DEPRECATED);
336 |
337 | $match = array();
338 |
339 | preg_match('/^([^\d]*[^\d\s]) *(\d.*)$/', $street, $match);
340 |
341 | if(count($match) == 0) return;
342 |
343 | $this->setStreetName($match[1]);
344 | $this->setStreetNumber($match[2]);
345 | }
346 | }
347 |
--------------------------------------------------------------------------------
/includes/ShipmentOrder.php:
--------------------------------------------------------------------------------
1 | Url
89 | * BusinessShipment::RESPONSE_TYPE_B64 -> Base64
90 | *
91 | * @var string|null $labelResponseType - Label-Response-Type (Can use class constance's) (null uses default)
92 | */
93 | private $labelResponseType = null;
94 |
95 | /**
96 | * Clears Memory
97 | */
98 | public function __destruct() {
99 | unset($this->sequenceNumber);
100 | unset($this->shipmentDetails);
101 | unset($this->sender);
102 | unset($this->receiver);
103 | unset($this->returnReceiver);
104 | unset($this->exportDocument);
105 | unset($this->printOnlyIfReceiverIsValid);
106 | unset($this->labelResponseType);
107 | }
108 |
109 | /**
110 | * Get the Sequence-Number
111 | *
112 | * @return string - Sequence-Number
113 | */
114 | public function getSequenceNumber() {
115 | return $this->sequenceNumber;
116 | }
117 |
118 | /**
119 | * Set the Sequence-Number
120 | *
121 | * @param string $sequenceNumber - Sequence-Number
122 | */
123 | public function setSequenceNumber($sequenceNumber) {
124 | $this->sequenceNumber = $sequenceNumber;
125 | }
126 |
127 | /**
128 | * Get Shipment-Details-Object
129 | *
130 | * @return ShipmentDetails - Shipment-Details-Object
131 | */
132 | public function getShipmentDetails() {
133 | return $this->shipmentDetails;
134 | }
135 |
136 | /**
137 | * Set Shipment-Details-Object
138 | *
139 | * @param ShipmentDetails $shipmentDetails - Shipment-Details-Object
140 | */
141 | public function setShipmentDetails($shipmentDetails) {
142 | $this->shipmentDetails = $shipmentDetails;
143 | }
144 |
145 | /**
146 | * Get the Sender-Object
147 | *
148 | * @return Sender - Sender-Object
149 | */
150 | public function getSender() {
151 | return $this->sender;
152 | }
153 |
154 | /**
155 | * Set the Sender-Object
156 | *
157 | * @param Sender $sender - Sender-Object
158 | */
159 | public function setSender($sender) {
160 | $this->sender = $sender;
161 | }
162 |
163 | /**
164 | * Get the Receiver-Object
165 | *
166 | * @return Receiver|PackStation|Filial - Receiver-Object
167 | */
168 | public function getReceiver() {
169 | return $this->receiver;
170 | }
171 |
172 | /**
173 | * Set the Receiver-Object
174 | *
175 | * @param Receiver|PackStation|Filial $receiver - Receiver-Object
176 | */
177 | public function setReceiver($receiver) {
178 | $this->receiver = $receiver;
179 | }
180 |
181 | /**
182 | * Get the ReturnReceiver-Object
183 | *
184 | * Usually only used for Re-Tour (In most cases the same Address like the Sender)
185 | *
186 | * @return ReturnReceiver|null - ReturnReceiver-Object or null if none
187 | */
188 | public function getReturnReceiver() {
189 | return $this->returnReceiver;
190 | }
191 |
192 | /**
193 | * Set the ReturnReceiver-Object
194 | *
195 | * Usually only used for Re-Tour (In most cases the same Address like the Sender)
196 | *
197 | * @param ReturnReceiver|null $returnReceiver - ReturnReceiver-Object or null for none
198 | */
199 | public function setReturnReceiver($returnReceiver) {
200 | $this->returnReceiver = $returnReceiver;
201 | }
202 |
203 | /**
204 | * Get the ExportDocument-Object
205 | *
206 | * @return ExportDocument|null - ExportDocument-Object or null if none
207 | */
208 | public function getExportDocument() {
209 | return $this->exportDocument;
210 | }
211 |
212 | /**
213 | * Set the ExportDocument-Object
214 | *
215 | * @param ExportDocument|null $exportDocument - ExportDocument-Object or null for none
216 | */
217 | public function setExportDocument($exportDocument) {
218 | $this->exportDocument = $exportDocument;
219 | }
220 |
221 | /**
222 | * Get if the label should only printed if the Receiver-Address is valid
223 | *
224 | * @return bool|null - Should the label only printed on a valid Address | null means DHL-Default
225 | */
226 | public function getPrintOnlyIfReceiverIsValid() {
227 | return $this->printOnlyIfReceiverIsValid;
228 | }
229 |
230 | /**
231 | * Set if the label should only printed if the Receiver-Address is valid
232 | *
233 | * WARNING: The Address-Validation can fail sometimes also on existing Addresses (for example new streets) use with care!
234 | *
235 | * @param bool|null $printOnlyIfReceiverIsValid - Should the label only printed on a valid Address | null uses default from DHL
236 | */
237 | public function setPrintOnlyIfReceiverIsValid($printOnlyIfReceiverIsValid) {
238 | $this->printOnlyIfReceiverIsValid = $printOnlyIfReceiverIsValid;
239 | }
240 |
241 | /**
242 | * Get the Label-Response type
243 | *
244 | * @return null|string - Label-Response type | null means DHL-Default
245 | */
246 | public function getLabelResponseType() {
247 | return $this->labelResponseType;
248 | }
249 |
250 | /**
251 | * Set the Label-Response type
252 | *
253 | * @param null|string $labelResponseType - Label-Response type | null uses DHL-Default
254 | */
255 | public function setLabelResponseType($labelResponseType) {
256 | $this->labelResponseType = $labelResponseType;
257 | }
258 |
259 | /**
260 | * Returns an DHL-Class of this Object for DHL-Shipment Order
261 | *
262 | * @return stdClass - DHL-ShipmentOrder-Class
263 | */
264 | public function getShipmentOrderClass_v2() {
265 | $class = new StdClass;
266 | $class->sequenceNumber = $this->getSequenceNumber();
267 |
268 | // Shipment
269 | $class->Shipment = new StdClass;
270 | $class->Shipment->ShipmentDetails = $this->getShipmentDetails()->getShipmentDetailsClass_v2();
271 |
272 | // Shipper
273 | $class->Shipment->Shipper = $this->getSender()->getClass_v2();
274 |
275 | // Receiver
276 | $class->Shipment->Receiver = $this->getReceiver()->getClass_v2();
277 |
278 | // Return-Receiver
279 | if($this->getReturnReceiver() !== null)
280 | $class->Shipment->ReturnReceiver = $this->getReturnReceiver()->getClass_v2();
281 |
282 | // Export-Document
283 | if($this->getExportDocument() !== null) {
284 | try {
285 | $class->Shipment->ExportDocument = $this->getExportDocument()->getExportDocumentClass_v2();
286 | } catch(Exception $e) {
287 | trigger_error('[DHL-PHP-SDK]: Exception in method ' . __METHOD__ . ':' . $e->getMessage(), E_USER_WARNING);
288 | }
289 | }
290 |
291 | // Other Settings
292 | if($this->getPrintOnlyIfReceiverIsValid() !== null) {
293 | $class->PrintOnlyIfCodeable = new StdClass;
294 | $class->PrintOnlyIfCodeable->active = (int) $this->getPrintOnlyIfReceiverIsValid();
295 | }
296 | if($this->getLabelResponseType() !== null)
297 | $class->labelResponseType = $this->getLabelResponseType();
298 |
299 | return $class;
300 | }
301 | }
302 |
--------------------------------------------------------------------------------
/includes/ProductInfo.php:
--------------------------------------------------------------------------------
1 | 'Wunschnachbar',
35 | 'preferredLocationEnabled' => 'Wunschort',
36 | 'visualCheckOfAgeEnabled' => 'Alterssichtprüfung',
37 | 'personalHandover' => 'Eigenhändig',
38 | 'namedPersonOnly' => 'persönliche Übergabe',
39 | 'identCheckEnabled' => 'Ident-Check',
40 | 'endorsementEnabled' => 'Vorausverfügung',
41 | 'returnReceipt' => 'Rückschein',
42 | 'preferredDayEnabled' => 'Wunschtag',
43 | 'preferredTimeEnabled' => 'Wunschzeit',
44 | 'disableNeighbourDelivery' => 'keine Nachbarschaftszustellung',
45 | 'goGreen' => 'GoGreen',
46 | 'additionalInsuranceEnabled' => 'Transportversicherung',
47 | 'bulkyGoods' => 'Sperrgut',
48 | 'cashOnDeliveryEnabled' => 'Nachnahme',
49 | 'dayOfDeliveryEnabled' => 'Zustelldatum',
50 | 'deliveryTimeframeEnabled' => 'Zustellzeitfenster',
51 | 'shipmentHandlingEnabled' => 'Sendungshandling',
52 | 'perishables' => 'verderbliche Ware',
53 | 'individualSenderRequiredmentsEnabled' => 'Individuelle Senderhinweise',
54 | 'premium' => 'Premium',
55 | 'packagingReturn' => 'Verpackungsrücknahme',
56 | 'noticeNonDeliverability' => 'Unzustellbarkeitsnachricht',
57 | 'returnImmediatlyIfShipmentFailed' => 'ReturnImmediately'
58 | );
59 |
60 | /**
61 | * Contains all Products
62 | *
63 | * @var Product[] $dhlProducts - Products
64 | */
65 | private static $dhlProducts = array();
66 |
67 | /**
68 | * Disabled Clone-Function
69 | */
70 | private function __clone() { /* VOID */ }
71 |
72 | /**
73 | * Disabled ProductInfo constructor.
74 | */
75 | private function __construct() { /* VOID */ }
76 |
77 | /**
78 | * Initiates the Class
79 | */
80 | private static function init() {
81 | self::setInit(true);
82 |
83 | // Initiates Products
84 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE);
85 | $obj->setName('DHL Paket');
86 | $obj->setMinLength(15);
87 | $obj->setMaxLength(200);
88 | $obj->setMinWidth(11);
89 | $obj->setMaxWidth(200);
90 | $obj->setMinHeight(1);
91 | $obj->setMaxHeight(200);
92 | $obj->setMaxWeight(31.5);
93 | $obj->setServices(array(
94 | 'preferredNeighbourEnabled',
95 | 'preferredLocationEnabled',
96 | 'visualCheckOfAgeEnabled',
97 | 'personalHandover',
98 | 'namedPersonOnly',
99 | 'identCheckEnabled',
100 | 'preferredDayEnabled',
101 | 'preferredTimeEnabled',
102 | 'disableNeighbourDelivery',
103 | 'goGreen',
104 | 'additionalInsuranceEnabled',
105 | 'bulkyGoods',
106 | 'cashOnDeliveryEnabled',
107 | 'individualSenderRequiredmentsEnabled',
108 | 'packagingReturn',
109 | 'noticeNonDeliverability'
110 | ));
111 | self::addProduct($obj);
112 |
113 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE_PRIO);
114 | $obj->setName('DHL Paket PRIO');
115 | $obj->setMinLength(15);
116 | $obj->setMaxLength(200);
117 | $obj->setMinWidth(11);
118 | $obj->setMaxWidth(200);
119 | $obj->setMinHeight(1);
120 | $obj->setMaxHeight(200);
121 | $obj->setMaxWeight(31.5);
122 | $obj->setServices(array(
123 | 'preferredNeighbourEnabled',
124 | 'preferredLocationEnabled',
125 | 'visualCheckOfAgeEnabled',
126 | 'namedPersonOnly',
127 | 'identCheckEnabled',
128 | 'preferredDayEnabled',
129 | 'preferredTimeEnabled',
130 | 'disableNeighbourDelivery',
131 | 'goGreen',
132 | 'additionalInsuranceEnabled',
133 | 'cashOnDeliveryEnabled',
134 | 'individualSenderRequiredmentsEnabled',
135 | 'packagingReturn',
136 | 'noticeNonDeliverability'
137 | ));
138 | self::addProduct($obj);
139 |
140 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_SAME_DAY_PACKAGE);
141 | $obj->setName('DHL Paket Taggleich');
142 | $obj->setMinLength(15);
143 | $obj->setMaxLength(200);
144 | $obj->setMinWidth(11);
145 | $obj->setMaxWidth(200);
146 | $obj->setMinHeight(1);
147 | $obj->setMaxHeight(200);
148 | $obj->setMaxWeight(31.5);
149 | $obj->setServices(array(
150 | 'preferredNeighbourEnabled',
151 | 'preferredLocationEnabled',
152 | 'visualCheckOfAgeEnabled',
153 | 'namedPersonOnly',
154 | 'identCheckEnabled',
155 | 'preferredDayEnabled',
156 | 'preferredTimeEnabled',
157 | 'disableNeighbourDelivery',
158 | 'goGreen',
159 | 'additionalInsuranceEnabled',
160 | 'bulkyGoods',
161 | 'cashOnDeliveryEnabled',
162 | 'individualSenderRequiredmentsEnabled',
163 | 'packagingReturn',
164 | 'noticeNonDeliverability',
165 | 'returnImmediatlyIfShipmentFailed'
166 | ));
167 | self::addProduct($obj);
168 |
169 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_INTERNATIONAL_PACKAGE);
170 | $obj->setName('DHL Paket International');
171 | $obj->setMinLength(15);
172 | $obj->setMaxLength(120);
173 | $obj->setMinWidth(11);
174 | $obj->setMaxWidth(60);
175 | $obj->setMinHeight(1);
176 | $obj->setMaxHeight(60);
177 | $obj->setMaxWeight(31.5);
178 | $obj->setServices(array(
179 | 'endorsementEnabled',
180 | 'returnReceipt',
181 | 'goGreen',
182 | 'additionalInsuranceEnabled',
183 | 'bulkyGoods',
184 | 'cashOnDeliveryEnabled',
185 | 'premium'
186 | ));
187 | self::addProduct($obj);
188 |
189 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_EUROPA_PACKAGE);
190 | $obj->setName('DHL Europapaket');
191 | $obj->setMinLength(15);
192 | $obj->setMaxLength(120);
193 | $obj->setMinWidth(11);
194 | $obj->setMaxWidth(60);
195 | $obj->setMinHeight(3.5);
196 | $obj->setMaxHeight(60);
197 | $obj->setMaxWeight(31.5);
198 | $obj->setServices(array(
199 | 'goGreen',
200 | 'additionalInsuranceEnabled'
201 | ));
202 | self::addProduct($obj);
203 |
204 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_PACKED_CONNECT);
205 | $obj->setName('DHL Paket Connect');
206 | $obj->setMinLength(15);
207 | $obj->setMaxLength(120);
208 | $obj->setMinWidth(11);
209 | $obj->setMaxWidth(60);
210 | $obj->setMinHeight(3.5);
211 | $obj->setMaxHeight(60);
212 | $obj->setMaxWeight(31.5);
213 | $obj->setServices(array(
214 | 'goGreen',
215 | 'additionalInsuranceEnabled',
216 | 'bulkyGoods'
217 | ));
218 | self::addProduct($obj);
219 |
220 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_SAME_DAY_MESSENGER);
221 | $obj->setName('DHL Kurier Taggleich');
222 | $obj->setMinLength(15);
223 | $obj->setMaxLength(200);
224 | $obj->setMinWidth(11);
225 | $obj->setMaxWidth(200);
226 | $obj->setMinHeight(1);
227 | $obj->setMaxHeight(200);
228 | $obj->setMaxWeight(31.5);
229 | $obj->setServices(array(
230 | 'preferredNeighbourEnabled',
231 | 'visualCheckOfAgeEnabled',
232 | 'endorsementEnabled',
233 | 'goGreen',
234 | 'dayOfDeliveryEnabled',
235 | 'deliveryTimeframeEnabled',
236 | 'shipmentHandlingEnabled',
237 | 'perishables',
238 | 'individualSenderRequiredmentsEnabled'
239 | ));
240 | self::addProduct($obj);
241 |
242 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_WISH_TIME_MESSENGER);
243 | $obj->setName('DHL Kurier Wunschzeit');
244 | $obj->setMinLength(15);
245 | $obj->setMaxLength(200);
246 | $obj->setMinWidth(11);
247 | $obj->setMaxWidth(200);
248 | $obj->setMinHeight(1);
249 | $obj->setMaxHeight(200);
250 | $obj->setMaxWeight(31.5);
251 | $obj->setServices(array(
252 | 'preferredNeighbourEnabled',
253 | 'visualCheckOfAgeEnabled',
254 | 'endorsementEnabled',
255 | 'goGreen',
256 | 'dayOfDeliveryEnabled',
257 | 'deliveryTimeframeEnabled',
258 | 'shipmentHandlingEnabled',
259 | 'perishables',
260 | 'individualSenderRequiredmentsEnabled'
261 | ));
262 | self::addProduct($obj);
263 |
264 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_AUSTRIA_PACKAGE);
265 | $obj->setName('DHL Paket Austria');
266 | $obj->setAustria(true);
267 | $obj->setMinLength(15);
268 | $obj->setMaxLength(120);
269 | $obj->setMinWidth(11);
270 | $obj->setMaxWidth(60);
271 | $obj->setMinHeight(1);
272 | $obj->setMaxHeight(60);
273 | $obj->setMaxWeight(31.5);
274 | $obj->setServices(array(
275 | 'additionalInsuranceEnabled',
276 | 'bulkyGoods',
277 | 'cashOnDeliveryEnabled'
278 | ));
279 | self::addProduct($obj);
280 |
281 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_CONNECT_PACKAGE);
282 | $obj->setName('DHL Paket Connect');
283 | $obj->setAustria(true);
284 | $obj->setMinLength(15);
285 | $obj->setMaxLength(120);
286 | $obj->setMinWidth(11);
287 | $obj->setMaxWidth(60);
288 | $obj->setMinHeight(3.5);
289 | $obj->setMaxHeight(60);
290 | $obj->setMaxWeight(31.5);
291 | $obj->setServices(array(
292 | 'additionalInsuranceEnabled',
293 | 'bulkyGoods',
294 | 'cashOnDeliveryEnabled'
295 | ));
296 | self::addProduct($obj);
297 |
298 | $obj = new Product(ShipmentDetails::PRODUCT_TYPE_AUSTRIA_INTERNATIONAL_PACKAGE);
299 | $obj->setName('DHL Paket International');
300 | $obj->setAustria(true);
301 | $obj->setMinLength(15);
302 | $obj->setMaxLength(120);
303 | $obj->setMinWidth(11);
304 | $obj->setMaxWidth(60);
305 | $obj->setMinHeight(1);
306 | $obj->setMaxHeight(60);
307 | $obj->setMaxWeight(31.5);
308 | $obj->setServices(array(
309 | 'additionalInsuranceEnabled',
310 | 'bulkyGoods',
311 | 'cashOnDeliveryEnabled'
312 | ));
313 | self::addProduct($obj);
314 | }
315 |
316 | /**
317 | * Returns if the Object is initiated
318 | *
319 | * @return bool - Is this Object initiated
320 | */
321 | private static function isInit() {
322 | return self::$init;
323 | }
324 |
325 | /**
326 | * Set if the Object is initiated
327 | *
328 | * @param bool $init - Is this Object initiated
329 | */
330 | private static function setInit($init) {
331 | self::$init = $init;
332 | }
333 |
334 | /**
335 | * Get the DHL-Products
336 | *
337 | * @return Product[] - DHL-Product-Objects
338 | */
339 | public static function getDhlProducts() {
340 | if(! self::isInit())
341 | self::init();
342 |
343 | return self::$dhlProducts;
344 | }
345 |
346 | /**
347 | * Adds a Product to Info-Class
348 | *
349 | * @param Product $product - Product to add
350 | */
351 | private static function addProduct($product) {
352 | self::$dhlProducts[$product->getType()] = $product;
353 | }
354 |
355 | /**
356 | * Get the Product-Object by Type
357 | *
358 | * @param string $productType - ProductType
359 | * @return Product|null - DHL-Product Object or null if not exists in Info-Class
360 | */
361 | public static function getInfo($productType) {
362 | if(! self::isInit())
363 | self::init();
364 |
365 | if(! array_key_exists($productType, self::$dhlProducts))
366 | return null;
367 |
368 | return self::$dhlProducts[$productType];
369 | }
370 | }
371 |
--------------------------------------------------------------------------------
/includes/LabelData.php:
--------------------------------------------------------------------------------
1 | Status-Code was not set
26 | * - Response::DHL_ERROR_NO_ERROR (0) -> No Error occurred
27 | * - Response::DHL_ERROR_WEAK_WARNING (1) -> A week warning has occurred
28 | * - Response::DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE (500) -> DHL-API Service is not available
29 | * - Response::DHL_ERROR_GENERAL (1000)-> General Error
30 | * - Response::DHL_ERROR_AUTH_FAILED (1001) -> Authentication has failed
31 | * - Response::DHL_ERROR_HARD_VAL_ERROR (1101) -> A hard-validation Error has occurred
32 | * - Response::DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER (2000) -> Given Shipment-Number is unknown
33 | *
34 | * @var int $statusCode - Status-Code
35 | */
36 | private $statusCode = Response::DHL_ERROR_NOT_SET;
37 |
38 | /**
39 | * Contains the Status-Text
40 | *
41 | * @var string|null $statusText - Status-Text | null if not set
42 | */
43 | private $statusText = null;
44 |
45 | /**
46 | * Contains the Status-Message (Mostly more detailed, but longer)
47 | *
48 | * @var string|null $statusMessage - Status-Message | null if not set
49 | */
50 | private $statusMessage = null;
51 |
52 | /**
53 | * Sequence-Number (Useful for AJAX-Requests)
54 | *
55 | * @var string|null $sequenceNumber - Sequence-Number of the Request | null for none
56 | */
57 | private $sequenceNumber = null;
58 |
59 | /**
60 | * Shipment-Number
61 | *
62 | * @var null|string $shipmentNumber - Shipment-Number | null if not set
63 | */
64 | private $shipmentNumber = null;
65 |
66 | /**
67 | * Label URL/Base64-Data - Can also have the return label in one
68 | *
69 | * @var null|string $label - Label-URL or Base64-Label-Data | null if not set
70 | */
71 | private $label = null;
72 |
73 | /**
74 | * Return Label URL/Base64-Data
75 | *
76 | * @var null|string $returnLabel - Return Label-URL/Base64-Label-Data or null if not requested
77 | */
78 | private $returnLabel = null;
79 |
80 | /**
81 | * Export-Document-Label-URL/Base64-Data
82 | *
83 | * @var null|string $exportDoc - Export-Document Label-URL/Base64-Label-Data or null if not requested
84 | */
85 | private $exportDoc = null;
86 |
87 | /**
88 | * Cod-Label-URL/Base64-Data
89 | *
90 | * @var null|string $codLabel - Cod-Label-URL/Base64-Data or null if not requested
91 | */
92 | private $codLabel = null;
93 |
94 | /**
95 | * LabelData constructor.
96 | *
97 | * @param string $version - Current DHL-Version
98 | * @param object $labelData - LabelData-Object from DHL-Response
99 | */
100 | public function __construct($version, $labelData) {
101 | parent::__construct($version);
102 |
103 | if($labelData !== null) {
104 | switch($this->getMayor()) {
105 | case 1:
106 | trigger_error('[DHL-PHP-SDK]: Called Version 1 Method ' .__CLASS__ . '->' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
107 | break;
108 | case 2:
109 | default:
110 | $this->loadLabelData_v2($labelData);
111 | }
112 | }
113 | }
114 |
115 | /**
116 | * Clears Memory
117 | */
118 | public function __destruct() {
119 | unset($this->statusCode);
120 | unset($this->statusText);
121 | unset($this->statusMessage);
122 | unset($this->sequenceNumber);
123 | unset($this->shipmentNumber);
124 | unset($this->label);
125 | unset($this->returnLabel);
126 | unset($this->exportDoc);
127 | unset($this->codLabel);
128 | }
129 |
130 | /**
131 | * Getter for Status-Code
132 | *
133 | * - Response::DHL_ERROR_NOT_SET (-1) -> Status-Code was not set
134 | * - Response::DHL_ERROR_NO_ERROR (0) -> No Error occurred
135 | * - Response::DHL_ERROR_WEAK_WARNING (1) -> A week warning has occurred
136 | * - Response::DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE (500) -> DHL-API Service is not available
137 | * - Response::DHL_ERROR_GENERAL (1000)-> General Error
138 | * - Response::DHL_ERROR_AUTH_FAILED (1001) -> Authentication has failed
139 | * - Response::DHL_ERROR_HARD_VAL_ERROR (1101) -> A hard-validation Error has occurred
140 | * - Response::DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER (2000) -> Given Shipment-Number is unknown
141 | *
142 | * @return int - Status-Code
143 | */
144 | public function getStatusCode() {
145 | return $this->statusCode;
146 | }
147 |
148 | /**
149 | * Setter for Status-Code
150 | *
151 | * - Response::DHL_ERROR_NOT_SET (-1) -> Status-Code was not set
152 | * - Response::DHL_ERROR_NO_ERROR (0) -> No Error occurred
153 | * - Response::DHL_ERROR_WEAK_WARNING (1) -> A week warning has occurred
154 | * - Response::DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE (500) -> DHL-API Service is not available
155 | * - Response::DHL_ERROR_GENERAL (1000)-> General Error
156 | * - Response::DHL_ERROR_AUTH_FAILED (1001) -> Authentication has failed
157 | * - Response::DHL_ERROR_HARD_VAL_ERROR (1101) -> A hard-validation Error has occurred
158 | * - Response::DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER (2000) -> Given Shipment-Number is unknown
159 | *
160 | * @param int $statusCode - Status-Code
161 | */
162 | private function setStatusCode($statusCode) {
163 | $this->statusCode = $statusCode;
164 | }
165 |
166 | /**
167 | * Getter for Status-Text
168 | *
169 | * @return string|null - Status-Text or null if not set
170 | */
171 | public function getStatusText() {
172 | return $this->statusText;
173 | }
174 |
175 | /**
176 | * Setter for Status-Text
177 | *
178 | * @param string|null $statusText - Status-Text or null for not set
179 | */
180 | private function setStatusText($statusText) {
181 | $this->statusText = $statusText;
182 | }
183 |
184 | /**
185 | * Getter for Status-Message
186 | *
187 | * @return string|null - Status-Message or null if not set
188 | */
189 | public function getStatusMessage() {
190 | return $this->statusMessage;
191 | }
192 |
193 | /**
194 | * Setter for Status-Message
195 | *
196 | * @param string|null $statusMessage - Status-Message or null for not set
197 | */
198 | private function setStatusMessage($statusMessage) {
199 | $this->statusMessage = $statusMessage;
200 | }
201 |
202 | /**
203 | * Getter for Sequence-Number
204 | *
205 | * @return string|null - Sequence-Number of the Request or null if not set
206 | */
207 | public function getSequenceNumber() {
208 | return $this->sequenceNumber;
209 | }
210 |
211 | /**
212 | * Setter for Sequence-Number
213 | *
214 | * @param string|null $sequenceNumber - Sequence-Number of the Request or null for not set
215 | */
216 | private function setSequenceNumber($sequenceNumber) {
217 | $this->sequenceNumber = $sequenceNumber;
218 | }
219 |
220 | /**
221 | * Getter for Shipment-Number
222 | *
223 | * @return null|string - Shipment-Number or null if not set
224 | */
225 | public function getShipmentNumber() {
226 | return $this->shipmentNumber;
227 | }
228 |
229 | /**
230 | * Setter for Shipment-Number
231 | *
232 | * @param null|string $shipment_number - Shipment-Number or null for not set
233 | */
234 | private function setShipmentNumber($shipment_number) {
235 | $this->shipmentNumber = $shipment_number;
236 | }
237 |
238 | /**
239 | * Getter for Label
240 | *
241 | * @return null|string - Label URL/Base64-Data (Can also contain the return label) or null if not set
242 | */
243 | public function getLabel() {
244 | return $this->label;
245 | }
246 |
247 | /**
248 | * Setter for Label
249 | *
250 | * @param null|string $label - Label URL/Base64-Data (Can also contain the return label) or null for not set
251 | */
252 | private function setLabel($label) {
253 | $this->label = $label;
254 | }
255 |
256 | /**
257 | * Getter for ReturnLabel
258 | *
259 | * @return null|string - Return Label-URL/Base64-Label-Data or null if not requested/set
260 | */
261 | public function getReturnLabel() {
262 | return $this->returnLabel;
263 | }
264 |
265 | /**
266 | * Setter for ReturnLabel
267 | *
268 | * @param null|string $returnLabel - Return Label-URL/Base64-Label-Data or null for not requested/set
269 | */
270 | private function setReturnLabel($returnLabel) {
271 | $this->returnLabel = $returnLabel;
272 | }
273 |
274 | /**
275 | * Getter for Export-Document
276 | *
277 | * @return null|string - Export-Document Label-URL/Base64-Label-Data or null if not requested/set
278 | */
279 | public function getExportDoc() {
280 | return $this->exportDoc;
281 | }
282 |
283 | /**
284 | * Setter for Export-Document
285 | *
286 | * @param null|string $exportDoc - Export-Document Label-URL/Base64-Label-Data or null for not requested/set
287 | */
288 | private function setExportDoc($exportDoc) {
289 | $this->exportDoc = $exportDoc;
290 | }
291 |
292 | /**
293 | * Getter for Cod-Label
294 | *
295 | * @return null|string - Cod-Label-URL/Base64-Data or null if not requested/set
296 | */
297 | public function getCodLabel() {
298 | return $this->codLabel;
299 | }
300 |
301 | /**
302 | * Setter for Cod-Label
303 | *
304 | * @param null|string $codLabel - Cod-Label-URL/Base64-Data or null if not requested/set
305 | */
306 | private function setCodLabel($codLabel) {
307 | $this->codLabel = $codLabel;
308 | }
309 |
310 | /**
311 | * Check if the current Status-Code is correct and set the correct one if not
312 | */
313 | private function validateStatusCode() {
314 | if($this->getStatusCode() === 0 && $this->getStatusText() !== 'ok')
315 | $this->setStatusCode(Response::DHL_ERROR_WEAK_WARNING);
316 | }
317 |
318 | /**
319 | * Set all Values of the LabelResponse to this Object
320 | *
321 | * @param Object $response - LabelData-Response
322 | */
323 | private function loadLabelData_v2($response) {
324 | $labelResponse = $response;
325 | // Check if the tree is correct (and may reconfigure it)
326 | if(isset($response->LabelData))
327 | $labelResponse = $response->LabelData;
328 |
329 | // Get Sequence-Number
330 | if(isset($response->sequenceNumber))
331 | $this->setSequenceNumber((string) $response->sequenceNumber);
332 | else if(isset($labelResponse->sequenceNumber))
333 | $this->setSequenceNumber((string) $labelResponse->sequenceNumber);
334 |
335 | // Get Status
336 | if(isset($labelResponse->Status)) {
337 | if(isset($labelResponse->Status->statusCode))
338 | $this->setStatusCode((int) $labelResponse->Status->statusCode);
339 | if(isset($labelResponse->Status->statusText)) {
340 | if(is_array($labelResponse->Status->statusText))
341 | $this->setStatusText(implode(';', $labelResponse->Status->statusText));
342 | else
343 | $this->setStatusText($labelResponse->Status->statusText);
344 | }
345 | if(isset($labelResponse->Status->statusMessage)) {
346 | if(is_array($labelResponse->Status->statusMessage))
347 | $this->setStatusMessage(implode(';', $labelResponse->Status->statusMessage));
348 | else
349 | $this->setStatusMessage($labelResponse->Status->statusMessage);
350 | }
351 |
352 | $this->validateStatusCode();
353 | }
354 |
355 | // Get Shipment-Number
356 | if(isset($response->shipmentNumber))
357 | $this->setShipmentNumber((string) $response->shipmentNumber);
358 | else if(isset($labelResponse->shipmentNumber))
359 | $this->setShipmentNumber((string) $labelResponse->shipmentNumber);
360 |
361 | // Get Label-Data
362 | if(isset($labelResponse->labelUrl))
363 | $this->setLabel($labelResponse->labelUrl);
364 | else if(isset($labelResponse->labelData))
365 | $this->setLabel($labelResponse->labelData);
366 |
367 | // Get Return-Label
368 | if(isset($labelResponse->returnLabelUrl))
369 | $this->setReturnLabel($labelResponse->returnLabelUrl);
370 | else if(isset($labelResponse->returnLabelData))
371 | $this->setReturnLabel($labelResponse->returnLabelData);
372 |
373 | // Get Export-Doc
374 | if(isset($labelResponse->exportLabelUrl))
375 | $this->setExportDoc($labelResponse->exportLabelUrl);
376 | else if(isset($labelResponse->exportLabelData))
377 | $this->setExportDoc($labelResponse->exportLabelData);
378 | else if(isset($labelResponse->exportDocURL))
379 | $this->setExportDoc($labelResponse->exportDocURL);
380 | else if(isset($labelResponse->exportDocData))
381 | $this->setExportDoc($labelResponse->exportDocData);
382 |
383 | if(isset($labelResponse->codLabelUrl))
384 | $this->setCodLabel($labelResponse->codLabelUrl);
385 | else if(isset($labelResponse->codLabelData))
386 | $this->setCodLabel($labelResponse->codLabelData);
387 | }
388 | }
389 |
--------------------------------------------------------------------------------
/includes/ExportDocument.php:
--------------------------------------------------------------------------------
1 | only mandatory for international, non EU shipments).
56 | *
57 | * Note: Required! (Even if just mandatory for international shipments)
58 | *
59 | * Possible values:
60 | * OTHER
61 | * PRESENT
62 | * COMMERCIAL_SAMPLE
63 | * DOCUMENT
64 | * RETURN_OF_GOODS
65 | *
66 | * @var string $exportType - Export-Type (Can assigned with ExportDocument::EXPORT_TYPE_{TYPE} or as value)
67 | */
68 | private $exportType;
69 |
70 | /**
71 | * Description for Export-Type (especially needed if Export-Type is OTHER)
72 | *
73 | * Note: Optional|Required if "EXPORT_TYPE" is OTHER
74 | * Min-Len: 1
75 | * Max-Len: 256
76 | *
77 | * @var string|null $exportTypeDescription - Export-Description or null for none
78 | */
79 | private $exportTypeDescription = null;
80 |
81 | /**
82 | * Element provides terms of trades
83 | *
84 | * Note: Optional
85 | * Min-Len: 3
86 | * Max-Len: 3
87 | *
88 | * Possible values:
89 | * DDP - Delivery Duty Paid
90 | * DXV - Delivery duty paid (excl. VAT )
91 | * DDU - DDU - Delivery Duty Paid
92 | * DDX - Delivery duty paid (excl. Duties, taxes and VAT)
93 | *
94 | * @var string|null $termsOfTrade - Terms of trades (Can assigned with ExportDocument::TERMS_OF_TRADE_{TYPE})
95 | * or null for none
96 | */
97 | private $termsOfTrade = null;
98 |
99 | /**
100 | * Place of committal
101 | *
102 | * Note: Required
103 | * Min-Len: -
104 | * Max-Len: 35
105 | *
106 | * @var string $placeOfCommittal - Place of committal is a Location
107 | */
108 | private $placeOfCommittal;
109 |
110 | /**
111 | * Additional custom fees to be payed
112 | *
113 | * Note: Required
114 | *
115 | * @var float $additionalFee - Additional fee
116 | */
117 | private $additionalFee;
118 |
119 | /**
120 | * Permit-Number
121 | *
122 | * Note: Optional
123 | * Min-Len: -
124 | * Max-Len: 10
125 | *
126 | * // todo/fixme: is this just an int or float?
127 | * @var string|int|float|null $permitNumber - Permit number or null for none
128 | */
129 | private $permitNumber = null;
130 |
131 | /**
132 | * Attestation number
133 | *
134 | * Note: Optional
135 | * Min-Len: -
136 | * Max-Len: 35
137 | *
138 | * // todo/fixme: is this just an int or float?
139 | * @var string|int|float|null $attestationNumber - The attestation number or null for none
140 | */
141 | private $attestationNumber = null;
142 |
143 | /**
144 | * Is with Electronic Export Notification
145 | *
146 | * Note: Optional
147 | *
148 | * @var bool|null $withElectronicExportNotification - Is with Electronic Export Notification or null for default
149 | */
150 | private $withElectronicExportNotification = null;
151 |
152 | /**
153 | * Contains the ExportDocPosition-Class(es)
154 | *
155 | * Note: Optional
156 | *
157 | * @var ExportDocPosition|ExportDocPosition[]|null $exportDocPosition - ExportDocPosition-Class or an array with ExportDocPosition-Objects or null if not needed
158 | */
159 | private $exportDocPosition = null;
160 |
161 | /**
162 | * Clears Memory
163 | */
164 | public function __destruct() {
165 | unset($this->invoiceNumber);
166 | unset($this->exportType);
167 | unset($this->exportTypeDescription);
168 | unset($this->termsOfTrade);
169 | unset($this->placeOfCommittal);
170 | unset($this->additionalFee);
171 | unset($this->permitNumber);
172 | unset($this->attestationNumber);
173 | unset($this->withElectronicExportNotification);
174 | unset($this->exportDocPosition);
175 | }
176 |
177 | /**
178 | * Get the Invoice-Number
179 | *
180 | * @return float|int|null|string - Invoice-Number or null if none
181 | */
182 | public function getInvoiceNumber() {
183 | return $this->invoiceNumber;
184 | }
185 |
186 | /**
187 | * Set the Invoice-Number
188 | *
189 | * @param float|int|null|string $invoiceNumber - Invoice-Number or null for none
190 | */
191 | public function setInvoiceNumber($invoiceNumber) {
192 | $this->invoiceNumber = $invoiceNumber;
193 | }
194 |
195 | /**
196 | * Get the Export-Type
197 | *
198 | * @return string - Export-Type
199 | */
200 | public function getExportType() {
201 | return $this->exportType;
202 | }
203 |
204 | /**
205 | * Set the Export-Type
206 | *
207 | * @param string $exportType - Export-Type
208 | */
209 | public function setExportType($exportType) {
210 | $this->exportType = $exportType;
211 | }
212 |
213 | /**
214 | * Get the Export-Type-Description
215 | *
216 | * @return null|string - Export-Type-Description or null if none
217 | */
218 | public function getExportTypeDescription() {
219 | return $this->exportTypeDescription;
220 | }
221 |
222 | /**
223 | * Set the Export-Type-Description
224 | *
225 | * @param null|string $exportTypeDescription - Export-Type-Description or null for none
226 | */
227 | public function setExportTypeDescription($exportTypeDescription) {
228 | $this->exportTypeDescription = $exportTypeDescription;
229 | }
230 |
231 | /**
232 | * Get the Terms of Trade
233 | *
234 | * @return null|string - Terms of Trade or null if none
235 | */
236 | public function getTermsOfTrade() {
237 | return $this->termsOfTrade;
238 | }
239 |
240 | /**
241 | * Set the Terms of Trade
242 | *
243 | * @param null|string $termsOfTrade - Terms of Trade or null for none
244 | */
245 | public function setTermsOfTrade($termsOfTrade) {
246 | $this->termsOfTrade = $termsOfTrade;
247 | }
248 |
249 | /**
250 | * Get the Place of Committal
251 | *
252 | * @return string - Place of Committal
253 | */
254 | public function getPlaceOfCommittal() {
255 | return $this->placeOfCommittal;
256 | }
257 |
258 | /**
259 | * Set the Place of Committal
260 | *
261 | * @param string $placeOfCommittal - Place of Committal
262 | */
263 | public function setPlaceOfCommittal($placeOfCommittal) {
264 | $this->placeOfCommittal = $placeOfCommittal;
265 | }
266 |
267 | /**
268 | * Get the additional Fee
269 | *
270 | * @return float - Additional Fee
271 | */
272 | public function getAdditionalFee() {
273 | return $this->additionalFee;
274 | }
275 |
276 | /**
277 | * Sets the additional Fee
278 | *
279 | * @param float $additionalFee - Additional Fee
280 | */
281 | public function setAdditionalFee($additionalFee) {
282 | $this->additionalFee = $additionalFee;
283 | }
284 |
285 | /**
286 | * Get the Permit-Number
287 | *
288 | * @return float|int|null|string - Permit-Number or null if none
289 | */
290 | public function getPermitNumber() {
291 | return $this->permitNumber;
292 | }
293 |
294 | /**
295 | * Set the Permit-Number
296 | *
297 | * @param float|int|null|string $permitNumber - Permit-Number or null for none
298 | */
299 | public function setPermitNumber($permitNumber) {
300 | $this->permitNumber = $permitNumber;
301 | }
302 |
303 | /**
304 | * Get the Attestation-Number
305 | *
306 | * @return float|int|null|string - Attestation-Number or null if none
307 | */
308 | public function getAttestationNumber() {
309 | return $this->attestationNumber;
310 | }
311 |
312 | /**
313 | * Set the Attestation-Number
314 | *
315 | * @param float|int|null|string $attestationNumber - Attestation-Number or null for none
316 | */
317 | public function setAttestationNumber($attestationNumber) {
318 | $this->attestationNumber = $attestationNumber;
319 | }
320 |
321 | /**
322 | * Get if it is with Electronic Export Notifications
323 | *
324 | * @return bool|null - Is it with Electronic Export Notifications or null if default
325 | */
326 | public function getWithElectronicExportNotification() {
327 | return $this->withElectronicExportNotification;
328 | }
329 |
330 | /**
331 | * Set if it is with Electronic Export Notifications
332 | *
333 | * @param bool|null $withElectronicExportNotification - Is it with Electronic Export Notifications or null for default
334 | */
335 | public function setWithElectronicExportNotification($withElectronicExportNotification) {
336 | $this->withElectronicExportNotification = $withElectronicExportNotification;
337 | }
338 |
339 | /**
340 | * Get the ExportDocPosition(s) class(es)
341 | *
342 | * @return ExportDocPosition|ExportDocPosition[]|null - ExportDocPosition(s) class(es) or null if none
343 | */
344 | public function getExportDocPosition() {
345 | return $this->exportDocPosition;
346 | }
347 |
348 | /**
349 | * Set the ExportDocPosition(s) class(es)
350 | *
351 | * @param ExportDocPosition|ExportDocPosition[]|null $exportDocPosition - ExportDocPosition(s) class(es) or null for none
352 | */
353 | public function setExportDocPosition($exportDocPosition) {
354 | $this->exportDocPosition = $exportDocPosition;
355 | }
356 |
357 | /**
358 | * Adds an ExportDocPosition-Object to the current Object
359 | *
360 | * If the ExportDocPosition was null before, then it will add the entry normal (backwards compatibility)
361 | * If the ExportDocPosition was an array before, it just add it to the array
362 | * If the ExportDocPosition was just 1 entry before, it will converted to an array with both entries
363 | *
364 | * @param ExportDocPosition $exportDocPosition - Object to add
365 | */
366 | public function addExportDocPosition($exportDocPosition) {
367 | if($this->getExportDocPosition() === null)
368 | $this->setExportDocPosition($exportDocPosition);
369 | else if(is_array($this->getExportDocPosition()))
370 | $this->exportDocPosition[] = $exportDocPosition;
371 | else {
372 | // Convert the first existing entry to an array
373 | $this->setExportDocPosition(array($this->getExportDocPosition(), $exportDocPosition));
374 | }
375 | }
376 |
377 | /**
378 | * Returns a Class for Export-Document
379 | *
380 | * @return StdClass - DHL-ExportDocument-Class
381 | *
382 | * @deprecated - DHL-API-Version 1 Method
383 | */
384 | public function getExportDocumentClass_v1() {
385 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
386 | trigger_error('[DHL-PHP-SDK]: Called Version 1 Method: ' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
387 |
388 | $class = new StdClass;
389 |
390 | return $class;
391 | }
392 |
393 | /**
394 | * Returns a Class for Export-Document
395 | *
396 | * @return StdClass - DHL-ExportDocument-Class
397 | * @throws Exception - Invalid Data-Exception
398 | */
399 | public function getExportDocumentClass_v2() {
400 | $class = new StdClass;
401 |
402 | // Standard-Export-Stuff
403 | if($this->getInvoiceNumber() !== null)
404 | $class->invoiceNumber = $this->getInvoiceNumber();
405 |
406 | $class->exportType = $this->getExportType();
407 |
408 | if($this->getExportTypeDescription() !== null)
409 | $class->exportTypeDescription = $this->getExportTypeDescription();
410 | else if($this->getExportType() === self::EXPORT_TYPE_OTHER)
411 | throw new Exception('ExportTypeDescription must filled out if Export-Type is OTHER! - ' .
412 | 'Export-Class will not generated now');
413 |
414 | if($this->getTermsOfTrade() !== null)
415 | $class->termsOfTrade = $this->getTermsOfTrade();
416 |
417 | $class->placeOfCommital = $this->getPlaceOfCommittal();
418 | $class->additionalFee = $this->getAdditionalFee();
419 |
420 | if($this->getPermitNumber() !== null)
421 | $class->permitNumber = $this->getPermitNumber();
422 |
423 | if($this->getAttestationNumber() !== null)
424 | $class->attestationNumber = $this->getAttestationNumber();
425 |
426 | // Add rest (Elements)
427 | if($this->getWithElectronicExportNotification() !== null) {
428 | $class->WithElectronicExportNtfctn = new StdClass;
429 | $class->WithElectronicExportNtfctn->active = (int) $this->getWithElectronicExportNotification();
430 | }
431 |
432 | // Check if child-class is being used
433 | if($this->getExportDocPosition() !== null) {
434 | // Handle non-arrays... (Backward compatibility)
435 | if(! is_array($this->getExportDocPosition()))
436 | $class->ExportDocPosition = $this->getExportDocPosition()->getExportDocPositionClass_v2();
437 | else {
438 | $pos = $this->getExportDocPosition();
439 | foreach($pos as $key => &$exportDoc)
440 | $class->ExportDocPosition[$key] = $exportDoc->getExportDocPositionClass_v2();
441 | }
442 | }
443 |
444 | return $class;
445 | }
446 | }
447 |
--------------------------------------------------------------------------------
/includes/Response.php:
--------------------------------------------------------------------------------
1 | Status-Code was not set
26 | * - Response::DHL_ERROR_NO_ERROR -> No Error occurred
27 | * - Response::DHL_ERROR_WEAK_WARNING -> A week warning has occurred
28 | * - Response::DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE -> DHL-API Service is not available
29 | * - Response::DHL_ERROR_GENERAL -> General Error
30 | * - Response::DHL_ERROR_AUTH_FAILED -> Authentication has failed
31 | * - Response::DHL_ERROR_HARD_VAL_ERROR -> A hard-validation Error has occurred
32 | * - Response::DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER -> Given Shipment-Number is unknown
33 | */
34 | const DHL_ERROR_NOT_SET = -1;
35 | const DHL_ERROR_NO_ERROR = 0;
36 | const DHL_ERROR_WEAK_WARNING = 1;
37 | const DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE = 500;
38 | const DHL_ERROR_GENERAL = 1000;
39 | const DHL_ERROR_AUTH_FAILED = 1001;
40 | const DHL_ERROR_HARD_VAL_ERROR = 1101;
41 | const DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER = 2000;
42 |
43 | /**
44 | * Manifest PDF-Data as Base64-String
45 | *
46 | * @var null|string $manifestData - Manifest PDF-Data as Base64 String or null if not requested
47 | */
48 | private $manifestData = null;
49 |
50 | /**
51 | * Contains the Status-Code
52 | *
53 | * - Response::DHL_ERROR_NOT_SET (-1) -> Status-Code was not set
54 | * - Response::DHL_ERROR_NO_ERROR (0) -> No Error occurred
55 | * - Response::DHL_ERROR_WEAK_WARNING (1) -> A week warning has occurred
56 | * - Response::DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE (500) -> DHL-API Service is not available
57 | * - Response::DHL_ERROR_GENERAL (1000)-> General Error
58 | * - Response::DHL_ERROR_AUTH_FAILED (1001) -> Authentication has failed
59 | * - Response::DHL_ERROR_HARD_VAL_ERROR (1101) -> A hard-validation Error has occurred
60 | * - Response::DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER (2000) -> Given Shipment-Number is unknown
61 | *
62 | * @var int $statusCode - Status-Code
63 | */
64 | private $statusCode = self::DHL_ERROR_NOT_SET;
65 |
66 | /**
67 | * Contains the Status-Text
68 | *
69 | * @var string|null $statusText - Status-Text | null if not set
70 | */
71 | private $statusText = null;
72 |
73 | /**
74 | * Contains the Status-Message (Mostly more detailed, but longer)
75 | *
76 | * @var string|null $statusMessage - Status-Message | null if not set
77 | */
78 | private $statusMessage = null;
79 |
80 | /**
81 | * Contains all LabelData Objects
82 | *
83 | * @var LabelData[] - LabelData Object-Array
84 | */
85 | private $labelData = array();
86 |
87 | /**
88 | * Response constructor.
89 | *
90 | * Loads the correct Version and loads the Response if not null into this Object
91 | *
92 | * @param string $version - Current DHL-Version
93 | * @param null|Object $response - DHL-Response or null for none
94 | */
95 | public function __construct($version, $response = null) {
96 | parent::__construct($version);
97 |
98 | if($response !== null) {
99 | switch($this->getMayor()) {
100 | case 1:
101 | trigger_error('[DHL-PHP-SDK]: Called Version 1 Method ' .__CLASS__ . '->' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
102 | break;
103 | case 2:
104 | default:
105 | $this->loadResponse_v2($response);
106 | }
107 | }
108 | }
109 |
110 | /**
111 | * Clears Memory
112 | */
113 | public function __destruct() {
114 | parent::__destruct();
115 | unset($this->manifestData);
116 | unset($this->statusCode);
117 | unset($this->statusText);
118 | unset($this->statusMessage);
119 | unset($this->labelData);
120 | }
121 |
122 | /**
123 | * Getter for Shipment-Number
124 | *
125 | * @return null|string - Shipment-Number or null if not set
126 | */
127 | public function getShipmentNumber() {
128 | if($this->countLabelData() > 0)
129 | return $this->getLabelData(0)->getShipmentNumber();
130 |
131 | return null;
132 | }
133 |
134 | /**
135 | * Getter for pieceNumber
136 | *
137 | * @return null|string - null if not set else pieceNumber (just used in API-Version 1)
138 | *
139 | * @deprecated - DHL-API-Version 1 Method
140 | */
141 | public function getPieceNumber() {
142 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
143 |
144 | return null;
145 | }
146 |
147 | /**
148 | * Getter for Label
149 | *
150 | * @return null|string - Label URL/Base64-Data (Can also contain the return label) or null if not set
151 | */
152 | public function getLabel() {
153 | if($this->countLabelData() > 0)
154 | return $this->getLabelData(0)->getLabel();
155 |
156 | return null;
157 | }
158 |
159 | /**
160 | * Getter for ReturnLabel
161 | *
162 | * @return null|string - Return Label-URL/Base64-Label-Data or null if not requested/set
163 | */
164 | public function getReturnLabel() {
165 | if($this->countLabelData() > 0)
166 | return $this->getLabelData(0)->getReturnLabel();
167 |
168 | return null;
169 | }
170 |
171 | /**
172 | * Getter for Export-Document
173 | *
174 | * @return null|string - Export-Document Label-URL/Base64-Label-Data or null if not requested/set
175 | */
176 | public function getExportDoc() {
177 | if($this->countLabelData() > 0)
178 | return $this->getLabelData(0)->getExportDoc();
179 |
180 | return null;
181 | }
182 |
183 | /**
184 | * Get the Manifest PDF-Data as Base64-String
185 | *
186 | * @return null|string - PDF-Data as Base64-String or null if empty/not requested
187 | */
188 | public function getManifestData() {
189 | return $this->manifestData;
190 | }
191 |
192 | /**
193 | * Set the Manifest PDF-Data as Base64-String
194 | *
195 | * @param null|string $manifestData - PDF-Data as Base64-String or null for none
196 | */
197 | private function setManifestData($manifestData) {
198 | $this->manifestData = $manifestData;
199 | }
200 |
201 | /**
202 | * Getter for Sequence-Number
203 | *
204 | * @return string|null - Sequence-Number of the Request or null if not set
205 | */
206 | public function getSequenceNumber() {
207 | if($this->countLabelData() > 0)
208 | return $this->getLabelData(0)->getSequenceNumber();
209 |
210 | return null;
211 | }
212 |
213 | /**
214 | * Getter for Status-Code
215 | *
216 | * - Response::DHL_ERROR_NOT_SET (-1) -> Status-Code was not set
217 | * - Response::DHL_ERROR_NO_ERROR (0) -> No Error occurred
218 | * - Response::DHL_ERROR_WEAK_WARNING (1) -> A week warning has occurred
219 | * - Response::DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE (500) -> DHL-API Service is not available
220 | * - Response::DHL_ERROR_GENERAL (1000)-> General Error
221 | * - Response::DHL_ERROR_AUTH_FAILED (1001) -> Authentication has failed
222 | * - Response::DHL_ERROR_HARD_VAL_ERROR (1101) -> A hard-validation Error has occurred
223 | * - Response::DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER (2000) -> Given Shipment-Number is unknown
224 | *
225 | * @return int - Status-Code
226 | */
227 | public function getStatusCode() {
228 | return $this->statusCode;
229 | }
230 |
231 | /**
232 | * Setter for Status-Code
233 | *
234 | * - Response::DHL_ERROR_NOT_SET (-1) -> Status-Code was not set
235 | * - Response::DHL_ERROR_NO_ERROR (0) -> No Error occurred
236 | * - Response::DHL_ERROR_WEAK_WARNING (1) -> A week warning has occurred
237 | * - Response::DHL_ERROR_SERVICE_TMP_NOT_AVAILABLE (500) -> DHL-API Service is not available
238 | * - Response::DHL_ERROR_GENERAL (1000)-> General Error
239 | * - Response::DHL_ERROR_AUTH_FAILED (1001) -> Authentication has failed
240 | * - Response::DHL_ERROR_HARD_VAL_ERROR (1101) -> A hard-validation Error has occurred
241 | * - Response::DHL_ERROR_UNKNOWN_SHIPMENT_NUMBER (2000) -> Given Shipment-Number is unknown
242 | *
243 | * @param int $statusCode - Status-Code
244 | */
245 | private function setStatusCode($statusCode) {
246 | $this->statusCode = $statusCode;
247 | }
248 |
249 | /**
250 | * Getter for Status-Text
251 | *
252 | * @return string|null - Status-Text or null if not set
253 | */
254 | public function getStatusText() {
255 | return $this->statusText;
256 | }
257 |
258 | /**
259 | * Setter for Status-Text
260 | *
261 | * @param string|null $statusText - Status-Text or null for not set
262 | */
263 | private function setStatusText($statusText) {
264 | $this->statusText = $statusText;
265 | }
266 |
267 | /**
268 | * Getter for Status-Message
269 | *
270 | * @return string|null - Status-Message or null if not set
271 | */
272 | public function getStatusMessage() {
273 | return $this->statusMessage;
274 | }
275 |
276 | /**
277 | * Setter for Status-Message
278 | *
279 | * @param string|null $statusMessage - Status-Message or null for not set
280 | */
281 | private function setStatusMessage($statusMessage) {
282 | $this->statusMessage = $statusMessage;
283 | }
284 |
285 | /**
286 | * Getter for LabelData-Objects
287 | *
288 | * @param null|int $index - Index of the LabelData-Object or null for the array
289 | * @return LabelData[]|LabelData - LabelData-Object(-Array)
290 | */
291 | public function getLabelData($index = null) {
292 | if($index === null)
293 | return $this->labelData;
294 | else
295 | return $this->labelData[$index];
296 | }
297 |
298 | /**
299 | * Adds a LabelData-Object to the LabelData-Object-Array
300 | *
301 | * @param LabelData $labelData - LabelData-Object to add
302 | */
303 | private function addLabelData($labelData) {
304 | $this->labelData[] = $labelData;
305 | }
306 |
307 | /**
308 | * Returns how many LabelData-Objects are in this List
309 | *
310 | * @return int - LabelData Count
311 | */
312 | public function countLabelData() {
313 | return count($this->getLabelData());
314 | }
315 |
316 | /**
317 | * Check if the current Status-Code is correct and set the correct one if not
318 | */
319 | private function validateStatusCode() {
320 | if($this->getStatusCode() === self::DHL_ERROR_NO_ERROR && $this->getStatusText() !== 'ok')
321 | $this->setStatusCode(self::DHL_ERROR_WEAK_WARNING);
322 |
323 | // Fix the DHL-Error Weak-Warning-Bug
324 | if($this->countLabelData() === 1) {
325 | // ALWAYS uses the Shipment-Response when only 1
326 | $this->setStatusCode($this->getLabelData(0)->getStatusCode());
327 | $this->setStatusText($this->getLabelData(0)->getStatusText());
328 | $this->setStatusMessage($this->getLabelData(0)->getStatusMessage());
329 | } else if($this->getStatusCode() === self::DHL_ERROR_WEAK_WARNING) {
330 | $noError = true;
331 |
332 | // Search in all shipments if an error/warning exists
333 | foreach($this->getLabelData() as &$labelData) {
334 | /**
335 | * @var LabelData $labelData
336 | */
337 | if($labelData->getStatusCode() !== self::DHL_ERROR_NO_ERROR) {
338 | $noError = false;
339 | break;
340 | }
341 | }
342 |
343 | if($noError) {
344 | $this->setStatusCode(self::DHL_ERROR_NO_ERROR);
345 | $this->setStatusText('ok');
346 | $this->setStatusMessage('Der Webservice wurde ohne Fehler ausgeführt.');
347 | }
348 | }
349 | }
350 |
351 | /**
352 | * Getter for Cod-Label
353 | *
354 | * @return null|string - Cod-Label-URL/Base64-Data or null if not requested/set
355 | */
356 | public function getCodLabel() {
357 | if($this->countLabelData() > 0)
358 | return $this->getLabelData(0)->getCodLabel();
359 |
360 | return null;
361 | }
362 |
363 | /**
364 | * Handles all Multi-Shipment Object/Arrays and add them to Label-Data
365 | *
366 | * @param Object|array $possibleMultiLabelObject - Object or array, which should be added to LabelData
367 | */
368 | private function handleMultiShipments($possibleMultiLabelObject) {
369 | if(is_array($possibleMultiLabelObject)) {
370 | $multiLabelArray = $possibleMultiLabelObject;
371 |
372 | foreach($multiLabelArray as &$singleLabel)
373 | $this->addLabelData(new LabelData($this->getVersion(), $singleLabel));
374 | } else
375 | $this->addLabelData(new LabelData($this->getVersion(), $possibleMultiLabelObject));
376 | }
377 |
378 | /**
379 | * Loads a DHL-Response into this Object
380 | *
381 | * @param Object $response - DHL-Response
382 | */
383 | private function loadResponse_v2($response) {
384 | // Set global Status-Values first
385 | if(isset($response->Status)) {
386 | if(isset($response->Status->statusCode))
387 | $this->setStatusCode((int) $response->Status->statusCode);
388 | if(isset($response->Status->statusText)) {
389 | if(is_array($response->Status->statusText))
390 | $this->setStatusText(implode(';', $response->Status->statusText));
391 | else
392 | $this->setStatusText($response->Status->statusText);
393 | }
394 | if(isset($response->Status->statusMessage)) {
395 | if(is_array($response->Status->statusMessage))
396 | $this->setStatusMessage(implode(';', $response->Status->statusMessage));
397 | else
398 | $this->setStatusMessage($response->Status->statusMessage);
399 | }
400 | }
401 |
402 | // Set Manifest if exists (getManifest)
403 | if(isset($response->manifestData)) {
404 | $this->setManifestData($response->manifestData);
405 |
406 | return;
407 | }
408 |
409 | /*
410 | * Handle Shipment(s) | Calls on:
411 | * 1 -> createShipmentOrder
412 | * 2 -> deleteShipmentOrder
413 | * 3 -> updateShipmentOrder [Only Single]
414 | * 3 -> getLabel
415 | * 4 -> validateShipment
416 | * 5 -> getExportDoc
417 | * 6 -> doManifest
418 | */
419 | if(isset($response->CreationState)) // 1
420 | $this->handleMultiShipments($response->CreationState);
421 | else if(isset($response->DeletionState)) // 2
422 | $this->handleMultiShipments($response->DeletionState);
423 | else if(isset($response->LabelData)) // 3
424 | $this->handleMultiShipments($response->LabelData);
425 | else if(isset($response->ValidationState)) // 4
426 | $this->handleMultiShipments($response->ValidationState);
427 | else if(isset($response->ExportDocData)) // 5
428 | $this->handleMultiShipments($response->ExportDocData);
429 | else if(isset($response->ManifestState)) // 6
430 | $this->handleMultiShipments($response->ManifestState);
431 |
432 | // Validate the status to fix errors on the Main-Status and show weak-warnings
433 | if($this->getStatusCode() !== self::DHL_ERROR_NOT_SET)
434 | $this->validateStatusCode();
435 | }
436 | }
437 |
--------------------------------------------------------------------------------
/lib/2.0/geschaeftskundenversand-api-2.0.wsdl:
--------------------------------------------------------------------------------
1 |
2 |
6 |
17 |
18 |
19 |
21 |
23 |
24 |
25 |
26 | The authentication data.
27 |
28 |
29 |
30 | The shipmentdata for creating a shipment.
31 |
32 |
33 |
34 | The status of the createShipment operation and the identifier for the
35 | shipment.
36 |
37 |
38 |
39 | The shipmentdata for validating a shipment.
40 |
41 |
42 |
43 | The status of the validateShipment operation and the identifier for the
44 | shipment.
45 |
46 |
47 |
48 | The identifier for the shipment which should be
49 | deleted.
50 |
51 |
52 |
53 | The status of the deletion operation.
54 |
55 |
56 |
57 | The identifier for the shipment which should be
58 | manifested.
59 |
60 |
61 |
62 | The status of the manifest operation.
63 |
64 |
65 |
66 | The identifier for the DD shipment for which the label url is
67 | requested.
68 |
69 |
70 |
71 | The status of the operation and the label url (if
72 | available).
73 |
74 |
75 |
76 | The version of webservice implementation.
77 |
78 |
79 |
80 | The version of webservice implementation.
81 |
82 |
83 |
84 | The identifier for the DD shipment for which the label url is
85 | requested.
86 |
87 |
88 |
89 | The status of the operation and the label url (if
90 | available).
91 |
92 |
93 |
94 | Request a manifest of the given date / date range.
95 |
96 |
97 |
98 | The status of the operation and the manifest url (if
99 | available).
100 |
101 |
102 |
103 | Request a manifest of the given date / date range.
104 |
105 |
106 |
107 | The status of the operation and the manifest url (if
108 | available).
109 |
110 |
111 |
112 | The status of the operation and the manifest url (if
113 | available).
114 |
115 |
116 |
117 |
118 | Creates shipments.
119 |
120 | The shipment data.
121 |
122 |
123 | The status of the createShipment operation and the identifier for the
124 | shipment.
125 |
126 |
127 |
128 | Creates shipments.
129 |
130 | The shipment data.
131 |
132 |
133 | The status of the validateShipment operation and the identifier for the
134 | shipment.
135 |
136 |
137 |
138 | Deletes the requested shipments.
139 |
140 | The identifier for the shipment which should be
141 | deleted.
142 |
143 |
144 | The status of the deletion operation.
145 |
146 |
147 |
148 | Manifest the requested DD shipments.
149 |
150 | The identifier for the shipment which should be
151 | manifested.
152 |
153 |
154 | The status of the manifest operation.
155 |
156 |
157 |
158 | Returns the request-url for getting a label.
159 |
160 | The identifier for the shipment for which the label url is
161 | requested.
162 |
163 |
164 | The status of the operation and the label url (if
165 | available).
166 |
167 |
168 |
169 | Returns the actual version of the implementation of the whole ISService
170 | webservice.
171 |
172 |
173 | The version of webservice implementation.
174 |
175 |
176 |
177 | Returns the request-url for getting a export
178 | document.
179 |
180 | The identifier for the shipment for which the export document url is
181 | requested.
182 |
183 |
184 | The status of the operation and the export document url (if
185 | available).
186 |
187 |
188 |
189 | Request the manifest.
190 |
191 | The request data.
192 |
193 |
194 | The status of the getManifest operation and the manifest
195 | url.
196 |
197 |
198 |
199 | Updates a shipment order.
200 |
201 | The shipment data.
202 |
203 |
204 | The status of the updateShipment operation and the identifier for the
205 | shipment.
206 |
207 |
208 |
209 |
210 |
211 |
212 | Creates shipments.
213 |
214 |
215 | The authentication data and the shipment data.
216 |
217 |
218 |
219 |
220 | The status of the operation and the shipment
221 | identifier.
222 |
223 |
224 |
225 |
226 | Validates shipments.
227 |
228 |
229 | The authentication data and the shipment data.
230 |
231 |
232 |
233 |
234 | The status of the operation and the shipment
235 | identifier.
236 |
237 |
238 |
239 |
240 | Deletes the requested shipments.
241 |
242 |
243 | The authentication data and the shipment
244 | identifier.
245 |
246 |
247 |
248 |
249 | The status of the operation.
250 |
251 |
252 |
253 |
254 | Manifest the requested shipments.
255 |
256 |
257 | The authentication data and the shipment
258 | identifier.
259 |
260 |
261 |
262 |
263 | The status of the operation.
264 |
265 |
266 |
267 |
268 | Returns the request-url for getting a label.
269 |
270 |
271 | The authentication data and the shipment
272 | identifier.
273 |
274 |
275 |
276 |
277 | The status of the operation and the url for requesting the
278 | label.
279 |
280 |
281 |
282 |
283 | Returns the actual version of the implementation of the whole ISService
284 | webservice.
285 |
286 |
287 |
288 |
289 |
290 | The version of the implementation.
291 |
292 |
293 |
294 |
295 | Returns the request-url for getting a export
296 | document.
297 |
298 |
299 | The authentication data and the shipment
300 | identifier.
301 |
302 |
303 |
304 |
305 | The status of the operation and the url for requesting the export
306 | document.
307 |
308 |
309 |
310 |
311 | Requests the manifest.
312 |
313 |
314 | The authentication data and the shipment data.
315 |
316 |
317 |
318 |
319 | The status of the operation and the manifest url.
320 |
321 |
322 |
323 |
324 | Updates a shipment order.
325 |
326 |
327 | The authentication data and the shipment data.
328 |
329 |
330 |
331 |
332 | The status of the operation
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
--------------------------------------------------------------------------------
/lib/2.1/geschaeftskundenversand-api-2.1.wsdl:
--------------------------------------------------------------------------------
1 |
2 |
6 |
17 |
18 |
19 |
21 |
23 |
24 |
25 |
26 | The authentication data.
27 |
28 |
29 |
30 | The shipmentdata for creating a shipment.
31 |
32 |
33 |
34 | The status of the createShipment operation and the identifier for the
35 | shipment.
36 |
37 |
38 |
39 | The shipmentdata for validating a shipment.
40 |
41 |
42 |
43 | The status of the validateShipment operation and the identifier for the
44 | shipment.
45 |
46 |
47 |
48 | The identifier for the shipment which should be
49 | deleted.
50 |
51 |
52 |
53 | The status of the deletion operation.
54 |
55 |
56 |
57 | The identifier for the shipment which should be
58 | manifested.
59 |
60 |
61 |
62 | The status of the manifest operation.
63 |
64 |
65 |
66 | The identifier for the DD shipment for which the label url is
67 | requested.
68 |
69 |
70 |
71 | The status of the operation and the label url (if
72 | available).
73 |
74 |
75 |
76 | The version of webservice implementation.
77 |
78 |
79 |
80 | The version of webservice implementation.
81 |
82 |
83 |
84 | The identifier for the DD shipment for which the label url is
85 | requested.
86 |
87 |
88 |
89 | The status of the operation and the label url (if
90 | available).
91 |
92 |
93 |
94 | Request a manifest of the given date / date range.
95 |
96 |
97 |
98 | The status of the operation and the manifest url (if
99 | available).
100 |
101 |
102 |
103 | Request a manifest of the given date / date range.
104 |
105 |
106 |
107 | The status of the operation and the manifest url (if
108 | available).
109 |
110 |
111 |
112 | The status of the operation and the manifest url (if
113 | available).
114 |
115 |
116 |
117 |
118 | Creates shipments.
119 |
120 | The shipment data.
121 |
122 |
123 | The status of the createShipment operation and the identifier for the
124 | shipment.
125 |
126 |
127 |
128 | Creates shipments.
129 |
130 | The shipment data.
131 |
132 |
133 | The status of the validateShipment operation and the identifier for the
134 | shipment.
135 |
136 |
137 |
138 | Deletes the requested shipments.
139 |
140 | The identifier for the shipment which should be
141 | deleted.
142 |
143 |
144 | The status of the deletion operation.
145 |
146 |
147 |
148 | Manifest the requested DD shipments.
149 |
150 | The identifier for the shipment which should be
151 | manifested.
152 |
153 |
154 | The status of the manifest operation.
155 |
156 |
157 |
158 | Returns the request-url for getting a label.
159 |
160 | The identifier for the shipment for which the label url is
161 | requested.
162 |
163 |
164 | The status of the operation and the label url (if
165 | available).
166 |
167 |
168 |
169 | Returns the actual version of the implementation of the whole ISService
170 | webservice.
171 |
172 |
173 | The version of webservice implementation.
174 |
175 |
176 |
177 | Returns the request-url for getting a export
178 | document.
179 |
180 | The identifier for the shipment for which the export document url is
181 | requested.
182 |
183 |
184 | The status of the operation and the export document url (if
185 | available).
186 |
187 |
188 |
189 | Request the manifest.
190 |
191 | The request data.
192 |
193 |
194 | The status of the getManifest operation and the manifest
195 | url.
196 |
197 |
198 |
199 | Updates a shipment order.
200 |
201 | The shipment data.
202 |
203 |
204 | The status of the updateShipment operation and the identifier for the
205 | shipment.
206 |
207 |
208 |
209 |
210 |
211 |
212 | Creates shipments.
213 |
214 |
215 | The authentication data and the shipment data.
216 |
217 |
218 |
219 |
220 | The status of the operation and the shipment
221 | identifier.
222 |
223 |
224 |
225 |
226 | Validates shipments.
227 |
228 |
229 | The authentication data and the shipment data.
230 |
231 |
232 |
233 |
234 | The status of the operation and the shipment
235 | identifier.
236 |
237 |
238 |
239 |
240 | Deletes the requested shipments.
241 |
242 |
243 | The authentication data and the shipment
244 | identifier.
245 |
246 |
247 |
248 |
249 | The status of the operation.
250 |
251 |
252 |
253 |
254 | Manifest the requested shipments.
255 |
256 |
257 | The authentication data and the shipment
258 | identifier.
259 |
260 |
261 |
262 |
263 | The status of the operation.
264 |
265 |
266 |
267 |
268 | Returns the request-url for getting a label.
269 |
270 |
271 | The authentication data and the shipment
272 | identifier.
273 |
274 |
275 |
276 |
277 | The status of the operation and the url for requesting the
278 | label.
279 |
280 |
281 |
282 |
283 | Returns the actual version of the implementation of the whole ISService
284 | webservice.
285 |
286 |
287 |
288 |
289 |
290 | The version of the implementation.
291 |
292 |
293 |
294 |
295 | Returns the request-url for getting a export
296 | document.
297 |
298 |
299 | The authentication data and the shipment
300 | identifier.
301 |
302 |
303 |
304 |
305 | The status of the operation and the url for requesting the export
306 | document.
307 |
308 |
309 |
310 |
311 | Requests the manifest.
312 |
313 |
314 | The authentication data and the shipment data.
315 |
316 |
317 |
318 |
319 | The status of the operation and the manifest url.
320 |
321 |
322 |
323 |
324 | Updates a shipment order.
325 |
326 |
327 | The authentication data and the shipment data.
328 |
329 |
330 |
331 |
332 | The status of the operation
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
--------------------------------------------------------------------------------
/lib/2.2/geschaeftskundenversand-api-2.2.wsdl:
--------------------------------------------------------------------------------
1 |
2 |
6 |
17 |
18 |
19 |
21 |
23 |
24 |
25 |
26 | The authentication data.
27 |
28 |
29 |
30 | The shipmentdata for creating a shipment.
31 |
32 |
33 |
34 | The status of the createShipment operation and the identifier for the
35 | shipment.
36 |
37 |
38 |
39 | The shipmentdata for validating a shipment.
40 |
41 |
42 |
43 | The status of the validateShipment operation and the identifier for the
44 | shipment.
45 |
46 |
47 |
48 | The identifier for the shipment which should be
49 | deleted.
50 |
51 |
52 |
53 | The status of the deletion operation.
54 |
55 |
56 |
57 | The identifier for the shipment which should be
58 | manifested.
59 |
60 |
61 |
62 | The status of the manifest operation.
63 |
64 |
65 |
66 | The identifier for the DD shipment for which the label url is
67 | requested.
68 |
69 |
70 |
71 | The status of the operation and the label url (if
72 | available).
73 |
74 |
75 |
76 | The version of webservice implementation.
77 |
78 |
79 |
80 | The version of webservice implementation.
81 |
82 |
83 |
84 | The identifier for the DD shipment for which the label url is
85 | requested.
86 |
87 |
88 |
89 | The status of the operation and the label url (if
90 | available).
91 |
92 |
93 |
94 | Request a manifest of the given date / date range.
95 |
96 |
97 |
98 | The status of the operation and the manifest url (if
99 | available).
100 |
101 |
102 |
103 | Request a manifest of the given date / date range.
104 |
105 |
106 |
107 | The status of the operation and the manifest url (if
108 | available).
109 |
110 |
111 |
112 | The status of the operation and the manifest url (if
113 | available).
114 |
115 |
116 |
117 |
118 | Creates shipments.
119 |
120 | The shipment data.
121 |
122 |
123 | The status of the createShipment operation and the identifier for the
124 | shipment.
125 |
126 |
127 |
128 | Creates shipments.
129 |
130 | The shipment data.
131 |
132 |
133 | The status of the validateShipment operation and the identifier for the
134 | shipment.
135 |
136 |
137 |
138 | Deletes the requested shipments.
139 |
140 | The identifier for the shipment which should be
141 | deleted.
142 |
143 |
144 | The status of the deletion operation.
145 |
146 |
147 |
148 | Manifest the requested DD shipments.
149 |
150 | The identifier for the shipment which should be
151 | manifested.
152 |
153 |
154 | The status of the manifest operation.
155 |
156 |
157 |
158 | Returns the request-url for getting a label.
159 |
160 | The identifier for the shipment for which the label url is
161 | requested.
162 |
163 |
164 | The status of the operation and the label url (if
165 | available).
166 |
167 |
168 |
169 | Returns the actual version of the implementation of the whole ISService
170 | webservice.
171 |
172 |
173 | The version of webservice implementation.
174 |
175 |
176 |
177 | Returns the request-url for getting a export
178 | document.
179 |
180 | The identifier for the shipment for which the export document url is
181 | requested.
182 |
183 |
184 | The status of the operation and the export document url (if
185 | available).
186 |
187 |
188 |
189 | Request the manifest.
190 |
191 | The request data.
192 |
193 |
194 | The status of the getManifest operation and the manifest
195 | url.
196 |
197 |
198 |
199 | Updates a shipment order.
200 |
201 | The shipment data.
202 |
203 |
204 | The status of the updateShipment operation and the identifier for the
205 | shipment.
206 |
207 |
208 |
209 |
210 |
211 |
212 | Creates shipments.
213 |
214 |
215 | The authentication data and the shipment data.
216 |
217 |
218 |
219 |
220 | The status of the operation and the shipment
221 | identifier.
222 |
223 |
224 |
225 |
226 | Validates shipments.
227 |
228 |
229 | The authentication data and the shipment data.
230 |
231 |
232 |
233 |
234 | The status of the operation and the shipment
235 | identifier.
236 |
237 |
238 |
239 |
240 | Deletes the requested shipments.
241 |
242 |
243 | The authentication data and the shipment
244 | identifier.
245 |
246 |
247 |
248 |
249 | The status of the operation.
250 |
251 |
252 |
253 |
254 | Manifest the requested shipments.
255 |
256 |
257 | The authentication data and the shipment
258 | identifier.
259 |
260 |
261 |
262 |
263 | The status of the operation.
264 |
265 |
266 |
267 |
268 | Returns the request-url for getting a label.
269 |
270 |
271 | The authentication data and the shipment
272 | identifier.
273 |
274 |
275 |
276 |
277 | The status of the operation and the url for requesting the
278 | label.
279 |
280 |
281 |
282 |
283 | Returns the actual version of the implementation of the whole ISService
284 | webservice.
285 |
286 |
287 |
288 |
289 |
290 | The version of the implementation.
291 |
292 |
293 |
294 |
295 | Returns the request-url for getting a export
296 | document.
297 |
298 |
299 | The authentication data and the shipment
300 | identifier.
301 |
302 |
303 |
304 |
305 | The status of the operation and the url for requesting the export
306 | document.
307 |
308 |
309 |
310 |
311 | Requests the manifest.
312 |
313 |
314 | The authentication data and the shipment data.
315 |
316 |
317 |
318 |
319 | The status of the operation and the manifest url.
320 |
321 |
322 |
323 |
324 | Updates a shipment order.
325 |
326 |
327 | The authentication data and the shipment data.
328 |
329 |
330 |
331 |
332 | The status of the operation
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
--------------------------------------------------------------------------------
/includes/ShipmentDetails.php:
--------------------------------------------------------------------------------
1 | National-Package
42 | * - ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE_PRIO -> National-Package-Prio
43 | * - ShipmentDetails::PRODUCT_TYPE_INTERNATIONAL_PACKAGE -> International-Package
44 | * - ShipmentDetails::PRODUCT_TYPE_EUROPA_PACKAGE -> Europa-Package
45 | * - ShipmentDetails::PRODUCT_TYPE_PACKED_CONNECT -> Packed Connect
46 | * - ShipmentDetails::PRODUCT_TYPE_SAME_DAY_PACKAGE -> Same-Day Package
47 | * - ShipmentDetails::PRODUCT_TYPE_SAME_DAY_MESSENGER -> Same Day Messenger
48 | * - ShipmentDetails::PRODUCT_TYPE_WISH_TIME_MESSENGER -> Wish Time Messenger
49 | * - ShipmentDetails::PRODUCT_TYPE_AUSTRIA_PACKAGE -> Austria Package
50 | * - ShipmentDetails::PRODUCT_TYPE_AUSTRIA_INTERNATIONAL_PACKAGE -> Austria International Package
51 | * - ShipmentDetails::PRODUCT_TYPE_CONNECT_PACKAGE -> Connect Package
52 | */
53 | const PRODUCT_TYPE_NATIONAL_PACKAGE = 'V01PAK';
54 | const PRODUCT_TYPE_NATIONAL_PACKAGE_PRIO = 'V01PRIO';
55 | const PRODUCT_TYPE_INTERNATIONAL_PACKAGE = 'V53WPAK';
56 | const PRODUCT_TYPE_EUROPA_PACKAGE = 'V54EPAK';
57 | const PRODUCT_TYPE_PACKED_CONNECT = 'V55PAK';
58 | const PRODUCT_TYPE_SAME_DAY_PACKAGE = 'V06PAK';
59 | const PRODUCT_TYPE_SAME_DAY_MESSENGER = 'V06TG';
60 | const PRODUCT_TYPE_WISH_TIME_MESSENGER = 'V06WZ';
61 | const PRODUCT_TYPE_AUSTRIA_PACKAGE = 'V86PARCEL';
62 | const PRODUCT_TYPE_AUSTRIA_INTERNATIONAL_PACKAGE = 'V82PARCEL';
63 | const PRODUCT_TYPE_CONNECT_PACKAGE = 'V87PARCEL';
64 |
65 | /**
66 | * Contains which Product is used
67 | *
68 | * Allowed values: (Use PRODUCT_TYPE_* constants - See above)
69 | * 'V01PAK' or ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE -> National-Package
70 | * 'V01PRIO' or ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE_PRIO -> National-Package-Prio
71 | * 'V53WPAK' or ShipmentDetails::PRODUCT_TYPE_INTERNATIONAL_PACKAGE -> International-Package
72 | * 'V54EPAK' or ShipmentDetails::PRODUCT_TYPE_EUROPA_PACKAGE -> Europa-Package
73 | * 'V55PAK' or ShipmentDetails::PRODUCT_TYPE_PACKED_CONNECT -> Packed Connect
74 | * 'V06PAK' or ShipmentDetails::PRODUCT_TYPE_SAME_DAY_PACKAGE -> Same-Day Package
75 | * 'V06TG' or ShipmentDetails::PRODUCT_TYPE_SAME_DAY_MESSENGER -> Same Day Messenger
76 | * 'V06WZ' or ShipmentDetails::PRODUCT_TYPE_WISH_TIME_MESSENGER -> Wish Time Messenger
77 | * 'V86PARCEL' or ShipmentDetails::PRODUCT_TYPE_AUSTRIA_PACKAGE -> Austria Package
78 | * 'V82PARCEL' or ShipmentDetails::PRODUCT_TYPE_AUSTRIA_INTERNATIONAL_PACKAGE -> Austria International Package
79 | * 'V87PARCEL' or ShipmentDetails::PRODUCT_TYPE_CONNECT_PACKAGE -> Connect Package
80 | *
81 | * @var string $product - Product to use (Default: National Package)
82 | */
83 | private $product = self::PRODUCT_TYPE_NATIONAL_PACKAGE;
84 |
85 | /**
86 | * Contains the
87 | * EKP Account Number (10 Digits) Example 123457890
88 | * concat Product Type Number (2 Digits) Example 01 for V01PAK or 53 for V53WPAK or 07 for Retoure Online
89 | * concat Process Type Number (2 Digits) Example 01 for default or 02 for block pricing/flat fee
90 | * = 1234578900101
91 | *
92 | * More Information: https://entwickler.dhl.de/group/ep/wsapis/geschaeftskundenversand/authentifizierung
93 | *
94 | * Min-Len: 14
95 | * Max-Len: 14
96 | *
97 | * @var string $accountNumber - Account-Number plus Product Type Number plus Process Type Number
98 | */
99 | private $accountNumber;
100 |
101 | /**
102 | * Contains the Customer-Reference
103 | *
104 | * Note: Optional
105 | *
106 | * Min-Len: -
107 | * Max-Len: 35
108 | *
109 | * @var string|null $customerReference - Customer Reference or null for none
110 | */
111 | private $customerReference = null;
112 |
113 | /**
114 | * Contains the Shipment-Date
115 | *
116 | * Note: ISO-Date-Format (YYYY-MM-DD)
117 | *
118 | * Min-Len: 10
119 | * Max-Len: 10
120 | *
121 | * @var string|null $shipmentDate - Shipment-Date or null for today (+1 Day if Sunday)
122 | */
123 | private $shipmentDate = null;
124 |
125 | /**
126 | * Contains the Return-Account-Number (EKP)
127 | *
128 | * Note: Optional
129 | *
130 | * Min-Len: 14
131 | * Max-Len: 14
132 | *
133 | * @var string|null $returnAccountNumber - Return-Account-Number or null for none
134 | */
135 | private $returnAccountNumber = null;
136 |
137 | /**
138 | * Contains the Return-Reference
139 | *
140 | * Note: Optional
141 | *
142 | * Min-Len: -
143 | * Max-Len: 35
144 | *
145 | * @var string|null $returnReference - Return-Reference or null for none
146 | */
147 | private $returnReference = null;
148 |
149 | /**
150 | * Weight of the Shipment-Object in KG
151 | *
152 | * @var float $weight - Weight in KG
153 | */
154 | private $weight = 5.0;
155 |
156 | /**
157 | * Length of the Shipment-Object in CM
158 | *
159 | * Note: Optional
160 | *
161 | * @var int|null $length - Length in CM
162 | */
163 | private $length = null;
164 |
165 | /**
166 | * Width of the Shipment-Object in CM
167 | *
168 | * Note: Optional
169 | *
170 | * @var int|null $width - Width in CM
171 | */
172 | private $width = null;
173 |
174 | /**
175 | * Height of the Shipment-Object in CM
176 | *
177 | * Note: Optional
178 | *
179 | * @var int|null $height - Height in CM
180 | */
181 | private $height = null;
182 |
183 | /**
184 | * Contains the Service Object (Many settings for the Shipment)
185 | *
186 | * Note: Optional
187 | *
188 | * @var Service|null $service - Service Object | null for none
189 | */
190 | private $service = null;
191 |
192 | /**
193 | * Type of the Package
194 | *
195 | * Note: Optional
196 | *
197 | * Allowed values:
198 | * 'PK' or ShipmentDetails::PACKAGE -> DHL-Package-Type "Package"
199 | * 'PL' or ShipmentDetails::PALETTE -> DHL-Package-Type "Palette"
200 | *
201 | * @var string $packageType - Package-Type
202 | *
203 | * @deprecated - DHL-API-Version 1 Field
204 | */
205 | private $packageType = self::PACKAGE;
206 |
207 | /**
208 | * E-mail address for shipping notification
209 | *
210 | * Note: Optional
211 | *
212 | * @var string|null $notificationEmail - Notification E-Mail or null for none
213 | */
214 | private $notificationEmail = null;
215 |
216 | /**
217 | * Contains the Bank-Object
218 | *
219 | * Note: Optional
220 | *
221 | * @var BankData|null $bank - Bank-Object | null for none
222 | */
223 | private $bank = null;
224 |
225 | /**
226 | * ShipmentDetails constructor.
227 | *
228 | * @param string $accountNumber - Account-Number
229 | */
230 | public function __construct($accountNumber) {
231 | $this->setAccountNumber($accountNumber);
232 | }
233 |
234 | /**
235 | * Clears the Memory
236 | */
237 | public function __destruct() {
238 | unset($this->product);
239 | unset($this->accountNumber);
240 | unset($this->customerReference);
241 | unset($this->shipmentDate);
242 | unset($this->returnAccountNumber);
243 | unset($this->returnReference);
244 | unset($this->weight);
245 | unset($this->length);
246 | unset($this->width);
247 | unset($this->height);
248 | unset($this->service);
249 | unset($this->packageType);
250 | unset($this->notificationEmail);
251 | unset($this->bank);
252 | }
253 |
254 | /**
255 | * Get which Product is used
256 | *
257 | * Return values: (Use PRODUCT_TYPE_* constants - See above)
258 | * 'V01PAK' or ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE -> National-Package
259 | * 'V01PRIO' or ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE_PRIO -> National-Package-Prio
260 | * 'V53WPAK' or ShipmentDetails::PRODUCT_TYPE_INTERNATIONAL_PACKAGE -> International-Package
261 | * 'V54EPAK' or ShipmentDetails::PRODUCT_TYPE_EUROPA_PACKAGE -> Europa-Package
262 | * 'V55PAK' or ShipmentDetails::PRODUCT_TYPE_PACKED_CONNECT -> Packed Connect
263 | * 'V06PAK' or ShipmentDetails::PRODUCT_TYPE_SAME_DAY_PACKAGE -> Same-Day Package
264 | * 'V06TG' or ShipmentDetails::PRODUCT_TYPE_SAME_DAY_MESSENGER -> Same Day Messenger
265 | * 'V06WZ' or ShipmentDetails::PRODUCT_TYPE_WISH_TIME_MESSENGER -> Wish Time Messenger
266 | * 'V86PARCEL' or ShipmentDetails::PRODUCT_TYPE_AUSTRIA_PACKAGE -> Austria Package
267 | * 'V82PARCEL' or ShipmentDetails::PRODUCT_TYPE_AUSTRIA_INTERNATIONAL_PACKAGE -> Austria International Package
268 | * 'V87PARCEL' or ShipmentDetails::PRODUCT_TYPE_CONNECT_PACKAGE -> Connect Package
269 | *
270 | * @return string - Used Product
271 | */
272 | public function getProduct() {
273 | return $this->product;
274 | }
275 |
276 | /**
277 | * Set which Product is used
278 | *
279 | * Allowed values: (Use PRODUCT_TYPE_* constants - See above)
280 | * 'V01PAK' or ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE -> National-Package
281 | * 'V01PRIO' or ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE_PRIO -> National-Package-Prio
282 | * 'V53WPAK' or ShipmentDetails::PRODUCT_TYPE_INTERNATIONAL_PACKAGE -> International-Package
283 | * 'V54EPAK' or ShipmentDetails::PRODUCT_TYPE_EUROPA_PACKAGE -> Europa-Package
284 | * 'V55PAK' or ShipmentDetails::PRODUCT_TYPE_PACKED_CONNECT -> Packed Connect
285 | * 'V06PAK' or ShipmentDetails::PRODUCT_TYPE_SAME_DAY_PACKAGE -> Same-Day Package
286 | * 'V06TG' or ShipmentDetails::PRODUCT_TYPE_SAME_DAY_MESSENGER -> Same Day Messenger
287 | * 'V06WZ' or ShipmentDetails::PRODUCT_TYPE_WISH_TIME_MESSENGER -> Wish Time Messenger
288 | * 'V86PARCEL' or ShipmentDetails::PRODUCT_TYPE_AUSTRIA_PACKAGE -> Austria Package
289 | * 'V82PARCEL' or ShipmentDetails::PRODUCT_TYPE_AUSTRIA_INTERNATIONAL_PACKAGE -> Austria International Package
290 | * 'V87PARCEL' or ShipmentDetails::PRODUCT_TYPE_CONNECT_PACKAGE -> Connect Package
291 | *
292 | * @param string $product - Product, which should be used
293 | */
294 | public function setProduct($product) {
295 | $this->product = $product;
296 | }
297 |
298 | /**
299 | * Get the
300 | * EKP Account Number (10 Digits) Example 123457890
301 | * concat Product Type Number (2 Digits) Example 01 for V01PAK or 53 for V53WPAK or 07 for Retoure Online
302 | * concat Process Type Number (2 Digits) Example 01 for default or 02 for block pricing/flat fee
303 | * = 1234578900101
304 | *
305 | * @return string - Account-Number plus Product Type Number plus Process Type Number
306 | */
307 | private function getAccountNumber() {
308 | return $this->accountNumber;
309 | }
310 |
311 | /**
312 | * Set the
313 | * EKP Account Number (10 Digits) Example 123457890
314 | * concat Product Type Number (2 Digits) Example 01 for V01PAK or 53 for V53WPAK or 07 for Retoure Online
315 | * concat Process Type Number (2 Digits) Example 01 for default or 02 for block pricing/flat fee
316 | * = 1234578900101
317 | *
318 | * @param string $accountNumber - Account-Number plus Product Type Number plus Process Type Number
319 | */
320 | private function setAccountNumber($accountNumber) {
321 | $this->accountNumber = $accountNumber;
322 | }
323 |
324 | /**
325 | * Get the Customer-Reference
326 | *
327 | * @return null|string - Customer Reference or null for none
328 | */
329 | public function getCustomerReference() {
330 | return $this->customerReference;
331 | }
332 |
333 | /**
334 | * Set the Customer-Reference
335 | *
336 | * @param null|string $customerReference - Customer Reference or null for none
337 | */
338 | public function setCustomerReference($customerReference) {
339 | $this->customerReference = $customerReference;
340 | }
341 |
342 | /**
343 | * Get the Shipment-Date (and set the default one -today- if none was set)
344 | *
345 | * @return string - Shipment-Date as ISO-Date String YYYY-MM-DD
346 | */
347 | public function getShipmentDate() {
348 | if($this->shipmentDate === null)
349 | $this->setShipmentDate($this->createDefaultShipmentDate());
350 |
351 | return $this->shipmentDate;
352 | }
353 |
354 | /**
355 | * Set the Shipment-Date
356 | *
357 | * @param string|int|null $shipmentDate - Shipment-Date as String YYYY-MM-DD or the int value time() of the date | null for today (+1 Day on Sunday)
358 | * @param bool $useIntTime - Use the int Time Value instead of a String
359 | */
360 | public function setShipmentDate($shipmentDate, $useIntTime = false) {
361 | if($useIntTime) {
362 | // Convert Time-Stamp to Date
363 | $shipmentDate = date('Y-m-d', $shipmentDate);
364 |
365 | if($shipmentDate === false)
366 | $shipmentDate = null;
367 | }
368 |
369 | $this->shipmentDate = $shipmentDate;
370 | }
371 |
372 | /**
373 | * Get the Return-Account-Number (EKP)
374 | *
375 | * @return null|string - Return-Account-Number or null for none
376 | */
377 | public function getReturnAccountNumber() {
378 | return $this->returnAccountNumber;
379 | }
380 |
381 | /**
382 | * Set the Return-Account-Number (EKP)
383 | *
384 | * @param null|string $returnAccountNumber - Return-Account-Number or null for none
385 | */
386 | public function setReturnAccountNumber($returnAccountNumber) {
387 | $this->returnAccountNumber = $returnAccountNumber;
388 | }
389 |
390 | /**
391 | * Get the Return-Reference
392 | *
393 | * @return null|string - Return-Reference or null for none
394 | */
395 | public function getReturnReference() {
396 | return $this->returnReference;
397 | }
398 |
399 | /**
400 | * Set the Return-Reference
401 | *
402 | * @param null|string $returnReference - Return-Reference or null for none
403 | */
404 | public function setReturnReference($returnReference) {
405 | $this->returnReference = $returnReference;
406 | }
407 |
408 | /**
409 | * Get the Weight
410 | *
411 | * @return float - Weight in KG
412 | */
413 | public function getWeight() {
414 | return $this->weight;
415 | }
416 |
417 | /**
418 | * Set the Weight
419 | *
420 | * @param float $weight - Weight in KG
421 | */
422 | public function setWeight($weight) {
423 | $this->weight = $weight;
424 | }
425 |
426 | /**
427 | * Get the Length
428 | *
429 | * @return int|null - Length in CM or null for none
430 | */
431 | public function getLength() {
432 | return $this->length;
433 | }
434 |
435 | /**
436 | * Set the Length
437 | *
438 | * @param int|null $length - Length in CM or null for none
439 | */
440 | public function setLength($length) {
441 | $this->length = $length;
442 | }
443 |
444 | /**
445 | * Get the Width
446 | *
447 | * @return int|null - Width in CM or null for none
448 | */
449 | public function getWidth() {
450 | return $this->width;
451 | }
452 |
453 | /**
454 | * Set the Width
455 | *
456 | * @param int|null $width - Width in CM or null for none
457 | */
458 | public function setWidth($width) {
459 | $this->width = $width;
460 | }
461 |
462 | /**
463 | * Get the Height
464 | *
465 | * @return int|null - Height in CM or null for none
466 | */
467 | public function getHeight() {
468 | return $this->height;
469 | }
470 |
471 | /**
472 | * Set the Height
473 | *
474 | * @param int|null $height - Height in CM or null for none
475 | */
476 | public function setHeight($height) {
477 | $this->height = $height;
478 | }
479 |
480 | /**
481 | * Get the Service-Object
482 | *
483 | * @return Service|null - Service-Object or null if none
484 | */
485 | public function getService() {
486 | return $this->service;
487 | }
488 |
489 | /**
490 | * Set the Service-Object
491 | *
492 | * @param Service|null $service - Service-Object or null for none
493 | */
494 | public function setService($service) {
495 | $this->service = $service;
496 | }
497 |
498 | /**
499 | * Get the Type of the Package
500 | *
501 | * Return values:
502 | * 'PK' or ShipmentDetails::PACKAGE -> DHL-Package-Type "Package"
503 | * 'PL' or ShipmentDetails::PALETTE -> DHL-Package-Type "Palette"
504 | *
505 | * @return string - Type of the Package
506 | *
507 | * @deprecated - DHL-API-Version 1 Method
508 | */
509 | public function getPackageType() {
510 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
511 |
512 | return $this->packageType;
513 | }
514 |
515 | /**
516 | * Set the Type of the Package
517 | *
518 | * Allowed values:
519 | * 'PK' or ShipmentDetails::PACKAGE -> DHL-Package-Type "Package"
520 | * 'PL' or ShipmentDetails::PALETTE -> DHL-Package-Type "Palette"
521 | *
522 | * @param string $packageType - Type of the Package
523 | *
524 | * @deprecated - DHL-API-Version 1 Method
525 | */
526 | public function setPackageType($packageType) {
527 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
528 |
529 | $this->packageType = $packageType;
530 | }
531 |
532 | /**
533 | * Get the Notification E-Mail
534 | *
535 | * @return string|null - Notification E-Mail or null for none
536 | */
537 | public function getNotificationEmail() {
538 | return $this->notificationEmail;
539 | }
540 |
541 | /**
542 | * Set the Notification E-Mail
543 | *
544 | * @param string|null $notificationEmail - Notification E-Mail or null for none
545 | */
546 | public function setNotificationEmail($notificationEmail) {
547 | $this->notificationEmail = $notificationEmail;
548 | }
549 |
550 | /**
551 | * Get the Bank-Object
552 | *
553 | * @return BankData|null - Bank-Object or null if none
554 | */
555 | public function getBank() {
556 | return $this->bank;
557 | }
558 |
559 | /**
560 | * Set the Bank-Object
561 | *
562 | * @param BankData|null $bank - Bank-Object or null for none
563 | */
564 | public function setBank($bank) {
565 | $this->bank = $bank;
566 | }
567 |
568 | /**
569 | * Creates a Default Shipment-Date (Today or if Sunday the next Day)
570 | *
571 | * @return string - Default-Date as ISO-Date String
572 | */
573 | private function createDefaultShipmentDate() {
574 | $now = time();
575 | $weekDay = date('w', $now);
576 |
577 | if($weekDay === 0)
578 | $now += 86400; // Increase Day by 1 if Sunday
579 |
580 | return date('Y-m-d', $now);
581 | }
582 |
583 | /**
584 | * Returns an DHL-Class of this Object for DHL-Shipment Details
585 | *
586 | * @return StdClass - ShipmentDetailsClass
587 | *
588 | * @deprecated - DHL-API-Version 1 Method
589 | */
590 | public function getShipmentDetailsClass_v1() {
591 | trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
592 | trigger_error('[DHL-PHP-SDK]: Called Version 1 Method: ' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
593 |
594 | return new StdClass;
595 | }
596 |
597 | /**
598 | * Returns an DHL-Class of this Object for DHL-Shipment Details
599 | *
600 | * @return StdClass - DHL-ShipmentDetails-Class
601 | */
602 | public function getShipmentDetailsClass_v2() {
603 | $class = new StdClass;
604 |
605 | $class->product = $this->getProduct();
606 | $class->accountNumber = $this->getAccountNumber();
607 | if($this->getCustomerReference() !== null)
608 | $class->customerReference = $this->getCustomerReference();
609 | $class->shipmentDate = $this->getShipmentDate();
610 | if($this->getReturnAccountNumber() !== null)
611 | $class->returnShipmentAccountNumber = $this->getReturnAccountNumber();
612 | if($this->getReturnReference() !== null)
613 | $class->returnShipmentReference = $this->getReturnReference();
614 |
615 | $class->ShipmentItem = new StdClass;
616 | $class->ShipmentItem->weightInKG = $this->getWeight();
617 | if($this->getLength() !== null)
618 | $class->ShipmentItem->lengthInCM = $this->getLength();
619 | if($this->getWidth() !== null)
620 | $class->ShipmentItem->widthInCM = $this->getWidth();
621 | if($this->getHeight() !== null)
622 | $class->ShipmentItem->heightInCM = $this->getHeight();
623 |
624 | if($this->getService() !== null)
625 | $class->Service = $this->getService()->getServiceClass_v2($this->getProduct());
626 |
627 | if($this->getNotificationEmail() !== null) {
628 | $class->Notification = new StdClass;
629 | $class->Notification->recipientEmailAddress = $this->getNotificationEmail();
630 | }
631 |
632 | if($this->getBank() !== null)
633 | $class->BankData = $this->getBank()->getBankClass_v2();
634 |
635 | return $class;
636 | }
637 | }
638 |
--------------------------------------------------------------------------------