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\OrderType;
31
use Etrias\PaazlConnector\SoapTypes\ReturnLabelsOrderType;
32
33
class LabelService implements LabelServiceInterface
34
{
35
    /**
36
     * @var PaazlClientInterface
37
     */
38
    protected $client;
39
    /**
40
     * @var SecurityServiceInterface
41
     */
42
    protected $security;
43
44
    /**
45
     * DocumentService constructor.
46
     *
47
     * @param PaazlClientInterface     $client
48
     * @param SecurityServiceInterface $security
49
     */
50
    public function __construct(PaazlClientInterface $client, SecurityServiceInterface $security)
51
    {
52
        $this->security = $security;
53
        $this->client = $client;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function generatePdfLabels(array $orderReferences, $printer = null, $includeMetaData = null, $batch = null, $targetWebShop = null)
60
    {
61
        $orders = [];
62
63
        foreach ($orderReferences as $orderReference) {
64
            $orders[] = new OrderType(
65
                $this->security->getHash($orderReference),
66
                $targetWebShop,
67
                $orderReference,
68
                [],
69
                $batch
70
            );
71
        }
72
73
        $request = new GeneratePdfLabelsRequest(
74
            $this->client->getWebShopId(),
75
            $printer,
76
            $orders,
77
            $includeMetaData
78
        );
79
80
        return $this->client->generatePdfLabels($request);
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function generateExtraPdfLabel($orderReference, $printer = null, $includeMetaData = null, $batch = null, $targetWebShop = null)
87
    {
88
        $request = new GenerateExtraPdfLabelRequest(
89
            $this->security->getHash($orderReference),
90
            $this->client->getWebShopId(),
91
            $targetWebShop,
92
            $orderReference,
93
            null,
94
            $printer,
95
            $batch,
96
            $includeMetaData
97
        );
98
99
        return $this->client->generateExtraPdfLabel($request);
100
    }
101
102
    /**
103
     * {@inheritdoc}
104
     */
105
    public function generatePdfReturnLabels(array $orderReferences, $shippingOption = null, $printer = null, $targetWebShop = null)
106
    {
107
        $orders = [];
108
109
        foreach ($orderReferences as $orderReference) {
110
            $orders[] = new ReturnLabelsOrderType(
111
                $this->security->getHash($orderReference),
112
                $targetWebShop,
113
                $orderReference,
114
                null,
115
                $shippingOption
116
            );
117
        }
118
119
        $request = new GeneratePdfReturnLabelsRequest(
120
            $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

120
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
121
            $orders,
122
            $printer
123
        );
124
125
        return $this->client->generatePdfReturnLabels($request);
126
    }
127
128
    /**
129
     * {@inheritdoc}
130
     */
131
    public function generateExtraPdfReturnLabel($orderReference, $shippingOption, $printer = null, $targetWebShop = null)
132
    {
133
        $request = new GenerateExtraPdfReturnLabelRequest(
134
            $this->security->getHash($orderReference),
135
            $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

135
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
136
            $targetWebShop,
137
            $orderReference,
138
            null,
139
            $shippingOption,
140
            $printer
141
        );
142
143
        return $this->client->generateExtraPdfReturnLabel($request);
144
    }
145
146
    /**
147
     * {@inheritdoc}
148
     */
149
    public function generateImageLabels(array $orderReferences, $includeMetaData = null, $batch = null, $targetWebShop = null)
150
    {
151
        $orders = [];
152
153
        foreach ($orderReferences as $orderReference) {
154
            $orders[] = new OrderType(
155
                $this->security->getHash($orderReference),
156
                $targetWebShop,
157
                $orderReference,
158
                [],
159
                $batch
160
            );
161
        }
162
163
        $request = new GenerateImageLabelsRequest(
164
            $this->client->getWebShopId(),
165
            $orders,
166
            $includeMetaData
167
        );
168
169
        return $this->client->generateImageLabels($request);
170
    }
171
172
    /**
173
     * {@inheritdoc}
174
     */
175
    public function generateImageReturnLabels(array $orderReferences, $shippingOption, $printer = null, $targetWebShop = null)
176
    {
177
        $orders = [];
178
179
        foreach ($orderReferences as $orderReference) {
180
            $orders[] = new ReturnLabelsOrderType(
181
                $this->security->getHash($orderReference),
182
                $targetWebShop,
183
                $orderReference,
184
                null,
185
                $shippingOption
186
            );
187
        }
188
189
        $request = new GenerateImageReturnLabelsRequest(
190
            $this->client->getWebShopId(),
191
            $orders
192
        );
193
194
        return $this->client->generateImageReturnLabels($request);
195
    }
196
197
    /**
198
     * {@inheritdoc}
199
     */
200
    public function generateExtraImageReturnLabel($orderReference, $shippingOption, $targetWebShop = null)
201
    {
202
        $request = new GenerateExtraImageReturnLabelRequest(
203
            $this->security->getHash($orderReference),
204
            $this->client->getWebShopId(),
205
            $targetWebShop,
206
            $orderReference,
207
            null,
208
            $shippingOption
209
        );
210
211
        return $this->client->generateExtraImageReturnLabel($request);
212
    }
213
214
    /**
215
     * {@inheritdoc}
216
     */
217
    public function generateExtraImageLabel($orderReference, $includeMetaData = null, $batch = null, $targetWebShop = null)
218
    {
219
        $request = new GenerateExtraImageLabelRequest(
220
            $this->security->getHash($orderReference),
221
            $this->client->getWebShopId(),
222
            $targetWebShop,
223
            $orderReference,
224
            null,
225
            $batch,
226
            $includeMetaData
227
        );
228
229
        return $this->client->generateExtraImageLabel($request);
230
    }
231
232
    /**
233
     * {@inheritdoc}
234
     */
235
    public function generateZplLabels(array $orderReferences, $printer = null, $includeMetaData = null, $batch = null, $targetWebShop = null)
236
    {
237
        $orders = [];
238
239
        foreach ($orderReferences as $orderReference) {
240
            $orders[] = new OrderType(
241
                $this->security->getHash($orderReference),
242
                $targetWebShop,
243
                $orderReference,
244
                null,
245
                $batch
246
            );
247
        }
248
249
        $request = new GenerateZplLabelsRequest(
250
            $this->client->getWebShopId(),
251
            $printer,
252
            $orders,
253
            $includeMetaData
254
        );
255
256
        return $this->client->generateZplLabels($request);
257
    }
258
259
    /**
260
     * {@inheritdoc}
261
     */
262
    public function getExistingPdfLabel($orderReference, $barCode, $printer = null, $includeMetaData = null, $targetWebShop = null)
263
    {
264
        $request = new GetExistingPdfLabelRequest(
265
            $this->security->getHash($orderReference),
266
            $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

266
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
267
            $targetWebShop,
268
            $orderReference,
269
            $barCode,
270
            $includeMetaData,
271
            $printer
272
        );
273
274
        return $this->client->getExistingPdfLabel($request);
275
    }
276
277
    /**
278
     * {@inheritdoc}
279
     */
280
    public function getExistingPdfLabels(array $labelTypes, $printer = null, $includeMetaData = null)
281
    {
282
        $labels = [];
283
284
        foreach ($labelTypes as $label) {
285
            $labels[] = new ExistingLabelType(
286
                $this->security->getHash($label->getOrderReference()),
287
                $this->client->getWebShopId(),
288
                $label->getOrderReference(),
289
                $label->getBarcode()
290
            );
291
        }
292
293
        $request = new GetExistingPdfLabelsRequest(
294
            $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

294
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
295
            $labels,
296
            $includeMetaData,
297
            $printer);
298
299
        return $this->client->getExistingPdfLabels($request);
300
    }
301
302
    /**
303
     * {@inheritdoc}
304
     */
305
    public function getExistingImageLabel($orderReference, $barCode, $includeMetaData = null, $targetWebShop = null)
306
    {
307
        $request = new GetExistingImageLabelRequest(
308
            $this->security->getHash($orderReference),
309
            $this->client->getWebShopId(),
310
            $targetWebShop,
311
            $orderReference,
312
            $barCode,
313
            $includeMetaData);
314
315
        return $this->client->getExistingImageLabel($request);
316
    }
317
318
    /**
319
     * {@inheritdoc}
320
     */
321
    public function getExistingImageLabels(array $labelTypes, $includeMetaData = null)
322
    {
323
        $labels = [];
324
325
        foreach ($labelTypes as $label) {
326
            $labels[] = new ExistingLabelType(
327
                $this->security->getHash($label->getOrderReference()),
328
                $this->client->getWebShopId(),
329
                $label->getOrderReference(),
330
                $label->getBarcode()
331
            );
332
        }
333
334
        $request = new GetExistingImageLabelsRequest(
335
            $this->client->getWebShopId(),
336
            $labels,
337
            $includeMetaData
338
        );
339
340
        return $this->client->getExistingImageLabels($request);
341
    }
342
}
343