Test Failed
Push — master ( abfce3...8036ce )
by
unknown
04:53 queued 10s
created

src/Services/LabelService.php (4 issues)

Labels
Severity
1
<?php
2
3
/*
4
 * This file is part of PHP CS Fixer.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *     Dariusz Rumiński <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Etrias\PaazlConnector\Services;
14
15
use Etrias\PaazlConnector\Client\PaazlClientInterface;
16
use Etrias\PaazlConnector\SoapTypes\ExistingLabelType;
17
use Etrias\PaazlConnector\SoapTypes\GenerateExtraImageLabelRequest;
18
use Etrias\PaazlConnector\SoapTypes\GenerateExtraImageReturnLabelRequest;
19
use Etrias\PaazlConnector\SoapTypes\GenerateExtraPdfLabelRequest;
20
use Etrias\PaazlConnector\SoapTypes\GenerateExtraPdfReturnLabelRequest;
21
use Etrias\PaazlConnector\SoapTypes\GenerateImageLabelsRequest;
22
use Etrias\PaazlConnector\SoapTypes\GenerateImageReturnLabelsRequest;
23
use Etrias\PaazlConnector\SoapTypes\GeneratePdfLabelsRequest;
24
use Etrias\PaazlConnector\SoapTypes\GeneratePdfReturnLabelsRequest;
25
use Etrias\PaazlConnector\SoapTypes\GenerateZplLabelsRequest;
26
use Etrias\PaazlConnector\SoapTypes\GetExistingImageLabelRequest;
27
use Etrias\PaazlConnector\SoapTypes\GetExistingImageLabelsRequest;
28
use Etrias\PaazlConnector\SoapTypes\GetExistingPdfLabelRequest;
29
use Etrias\PaazlConnector\SoapTypes\GetExistingPdfLabelsRequest;
30
use Etrias\PaazlConnector\SoapTypes\LabelProduct;
31
use Etrias\PaazlConnector\SoapTypes\OrderDetailsRequest;
32
use Etrias\PaazlConnector\SoapTypes\OrderType;
33
use Etrias\PaazlConnector\SoapTypes\Product;
34
use Etrias\PaazlConnector\SoapTypes\ReturnLabelsOrderType;
35
36
class LabelService implements LabelServiceInterface
37
{
38
    /**
39
     * @var PaazlClientInterface
40
     */
41
    protected $client;
42
    /**
43
     * @var SecurityServiceInterface
44
     */
45
    protected $security;
46
47
    /**
48
     * DocumentService constructor.
49
     *
50
     * @param PaazlClientInterface     $client
51
     * @param SecurityServiceInterface $security
52
     */
53
    public function __construct(PaazlClientInterface $client, SecurityServiceInterface $security)
54
    {
55
        $this->security = $security;
56
        $this->client = $client;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function generatePdfLabels(array $orderReferences, $printer = null, $includeMetaData = null, $batch = null, $targetWebShop = null)
63
    {
64
        $orders = [];
65
66
        foreach ($orderReferences as $orderReference) {
67
68
            $labelProducts = [];
69
70
            $request = new OrderDetailsRequest(
71
                $this->security->getHash($orderReference),
72
                $this->client->getWebShopId(),
73
                $targetWebShop,
74
                $orderReference,
75
                true
76
            );
77
            $orderDetails = $this->client->orderDetails($request);
78
79
            /** @var Product $product */
80
            foreach ($orderDetails->getProducts() as $product) {
81
                $labelProducts[] = new LabelProduct(
82
                    $product->getQuantity(),
83
                    $product->getWeight(),
84
                    $product->getWidth(),
85
                    $product->getHeight(),
86
                    $product->getLength(),
87
                    $product->getVolume(),
88
                    $product->getCode(),
89
                    $product->getDescription()
90
                );
91
            }
92
93
            $orders[] = new OrderType(
94
                $this->security->getHash($orderReference),
95
                $targetWebShop,
96
                $orderReference,
97
                $labelProducts,
98
                $batch
99
            );
100
        }
101
102
        $request = new GeneratePdfLabelsRequest(
103
            $this->client->getWebShopId(),
104
            $printer,
105
            $orders,
106
            $includeMetaData
107
        );
108
109
        return $this->client->generatePdfLabels($request);
110
    }
111
112
    /**
113
     * {@inheritdoc}
114
     */
115
    public function generateExtraPdfLabel($orderReference, $printer = null, $includeMetaData = null, $batch = null, $targetWebShop = null)
116
    {
117
        $request = new GenerateExtraPdfLabelRequest(
118
            $this->security->getHash($orderReference),
119
            $this->client->getWebShopId(),
120
            $targetWebShop,
121
            $orderReference,
122
            null,
123
            $printer,
124
            $batch,
125
            $includeMetaData
126
        );
127
128
        return $this->client->generateExtraPdfLabel($request);
129
    }
130
131
    /**
132
     * {@inheritdoc}
133
     */
134
    public function generatePdfReturnLabels(array $orderReferences, $shippingOption = null, $printer = null, $targetWebShop = null)
135
    {
136
        $orders = [];
137
138
        foreach ($orderReferences as $orderReference) {
139
            $orders[] = new ReturnLabelsOrderType(
140
                $this->security->getHash($orderReference),
141
                $targetWebShop,
142
                $orderReference,
143
                null,
144
                $shippingOption
145
            );
146
        }
147
148
        $request = new GeneratePdfReturnLabelsRequest(
149
            $this->client->getWebShopId(),
0 ignored issues
show
$this->client->getWebShopId() of type string is incompatible with the type integer expected by parameter $webShop of Etrias\PaazlConnector\So...sRequest::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

149
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
150
            $orders,
151
            $printer
152
        );
153
154
        return $this->client->generatePdfReturnLabels($request);
155
    }
156
157
    /**
158
     * {@inheritdoc}
159
     */
160
    public function generateExtraPdfReturnLabel($orderReference, $shippingOption, $printer = null, $targetWebShop = null)
161
    {
162
        $request = new GenerateExtraPdfReturnLabelRequest(
163
            $this->security->getHash($orderReference),
164
            $this->client->getWebShopId(),
0 ignored issues
show
$this->client->getWebShopId() of type string is incompatible with the type integer expected by parameter $webShop of Etrias\PaazlConnector\So...lRequest::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

164
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
165
            $targetWebShop,
166
            $orderReference,
167
            null,
168
            $shippingOption,
169
            $printer
170
        );
171
172
        return $this->client->generateExtraPdfReturnLabel($request);
173
    }
174
175
    /**
176
     * {@inheritdoc}
177
     */
178
    public function generateImageLabels(array $orderReferences, $includeMetaData = null, $batch = null, $targetWebShop = null)
179
    {
180
        $orders = [];
181
182
        foreach ($orderReferences as $orderReference) {
183
            $orders[] = new OrderType(
184
                $this->security->getHash($orderReference),
185
                $targetWebShop,
186
                $orderReference,
187
                [],
188
                $batch
189
            );
190
        }
191
192
        $request = new GenerateImageLabelsRequest(
193
            $this->client->getWebShopId(),
194
            $orders,
195
            $includeMetaData
196
        );
197
198
        return $this->client->generateImageLabels($request);
199
    }
200
201
    /**
202
     * {@inheritdoc}
203
     */
204
    public function generateImageReturnLabels(array $orderReferences, $shippingOption, $printer = null, $targetWebShop = null)
205
    {
206
        $orders = [];
207
208
        foreach ($orderReferences as $orderReference) {
209
            $orders[] = new ReturnLabelsOrderType(
210
                $this->security->getHash($orderReference),
211
                $targetWebShop,
212
                $orderReference,
213
                null,
214
                $shippingOption
215
            );
216
        }
217
218
        $request = new GenerateImageReturnLabelsRequest(
219
            $this->client->getWebShopId(),
220
            $orders
221
        );
222
223
        return $this->client->generateImageReturnLabels($request);
224
    }
225
226
    /**
227
     * {@inheritdoc}
228
     */
229
    public function generateExtraImageReturnLabel($orderReference, $shippingOption, $targetWebShop = null)
230
    {
231
        $request = new GenerateExtraImageReturnLabelRequest(
232
            $this->security->getHash($orderReference),
233
            $this->client->getWebShopId(),
234
            $targetWebShop,
235
            $orderReference,
236
            null,
237
            $shippingOption
238
        );
239
240
        return $this->client->generateExtraImageReturnLabel($request);
241
    }
242
243
    /**
244
     * {@inheritdoc}
245
     */
246
    public function generateExtraImageLabel($orderReference, $includeMetaData = null, $batch = null, $targetWebShop = null)
247
    {
248
        $request = new GenerateExtraImageLabelRequest(
249
            $this->security->getHash($orderReference),
250
            $this->client->getWebShopId(),
251
            $targetWebShop,
252
            $orderReference,
253
            null,
254
            $batch,
255
            $includeMetaData
256
        );
257
258
        return $this->client->generateExtraImageLabel($request);
259
    }
260
261
    /**
262
     * {@inheritdoc}
263
     */
264
    public function generateZplLabels(array $orderReferences, $printer = null, $includeMetaData = null, $batch = null, $targetWebShop = null)
265
    {
266
        $orders = [];
267
268
        foreach ($orderReferences as $orderReference) {
269
            $orders[] = new OrderType(
270
                $this->security->getHash($orderReference),
271
                $targetWebShop,
272
                $orderReference,
273
                null,
274
                $batch
275
            );
276
        }
277
278
        $request = new GenerateZplLabelsRequest(
279
            $this->client->getWebShopId(),
280
            $printer,
281
            $orders,
282
            $includeMetaData
283
        );
284
285
        return $this->client->generateZplLabels($request);
286
    }
287
288
    /**
289
     * {@inheritdoc}
290
     */
291
    public function getExistingPdfLabel($orderReference, $barCode, $printer = null, $includeMetaData = null, $targetWebShop = null)
292
    {
293
        $request = new GetExistingPdfLabelRequest(
294
            $this->security->getHash($orderReference),
295
            $this->client->getWebShopId(),
0 ignored issues
show
$this->client->getWebShopId() of type string is incompatible with the type integer expected by parameter $webShop of Etrias\PaazlConnector\So...lRequest::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

295
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
296
            $targetWebShop,
297
            $orderReference,
298
            $barCode,
299
            $includeMetaData,
300
            $printer
301
        );
302
303
        return $this->client->getExistingPdfLabel($request);
304
    }
305
306
    /**
307
     * {@inheritdoc}
308
     */
309
    public function getExistingPdfLabels(array $labelTypes, $printer = null, $includeMetaData = null)
310
    {
311
        $labels = [];
312
313
        foreach ($labelTypes as $label) {
314
            $labels[] = new ExistingLabelType(
315
                $this->security->getHash($label->getOrderReference()),
316
                $this->client->getWebShopId(),
317
                $label->getOrderReference(),
318
                $label->getBarcode()
319
            );
320
        }
321
322
        $request = new GetExistingPdfLabelsRequest(
323
            $this->client->getWebShopId(),
0 ignored issues
show
$this->client->getWebShopId() of type string is incompatible with the type integer expected by parameter $webshop of Etrias\PaazlConnector\So...sRequest::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

323
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
324
            $labels,
325
            $includeMetaData,
326
            $printer);
327
328
        return $this->client->getExistingPdfLabels($request);
329
    }
330
331
    /**
332
     * {@inheritdoc}
333
     */
334
    public function getExistingImageLabel($orderReference, $barCode, $includeMetaData = null, $targetWebShop = null)
335
    {
336
        $request = new GetExistingImageLabelRequest(
337
            $this->security->getHash($orderReference),
338
            $this->client->getWebShopId(),
339
            $targetWebShop,
340
            $orderReference,
341
            $barCode,
342
            $includeMetaData);
343
344
        return $this->client->getExistingImageLabel($request);
345
    }
346
347
    /**
348
     * {@inheritdoc}
349
     */
350
    public function getExistingImageLabels(array $labelTypes, $includeMetaData = null)
351
    {
352
        $labels = [];
353
354
        foreach ($labelTypes as $label) {
355
            $labels[] = new ExistingLabelType(
356
                $this->security->getHash($label->getOrderReference()),
357
                $this->client->getWebShopId(),
358
                $label->getOrderReference(),
359
                $label->getBarcode()
360
            );
361
        }
362
363
        $request = new GetExistingImageLabelsRequest(
364
            $this->client->getWebShopId(),
365
            $labels,
366
            $includeMetaData
367
        );
368
369
        return $this->client->getExistingImageLabels($request);
370
    }
371
}
372