Issues (453)

src/Services/DocumentService.php (1 issue)

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\GenerateAdditionalDocumentType;
17
use Etrias\PaazlConnector\SoapTypes\GenerateAdditionalPdfDocumentRequest;
18
use Etrias\PaazlConnector\SoapTypes\GeneratePdfCustomsDocumentsRequest;
19
use Etrias\PaazlConnector\SoapTypes\OrderType;
20
use Etrias\PaazlConnector\SoapTypes\ProofOfDeliveryRequest;
21
22
class DocumentService implements DocumentServiceInterface
23
{
24
    /**
25
     * @var PaazlClientInterface
26
     */
27
    protected $client;
28
    /**
29
     * @var SecurityServiceInterface
30
     */
31
    protected $security;
32
33
    /**
34
     * DocumentService constructor.
35
     *
36
     * @param PaazlClientInterface     $client
37
     * @param SecurityServiceInterface $security
38
     */
39
    public function __construct(PaazlClientInterface $client, SecurityServiceInterface $security)
40
    {
41
        $this->security = $security;
42
        $this->client = $client;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function generateAdditionalPdfDocument($orderReference, $barcode, $documentType, $printer = null, $targetWebShop = null)
49
    {
50
        $request = new GenerateAdditionalPdfDocumentRequest(
51
            $this->security->getHash($orderReference),
52
            $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...tRequest::__construct(). ( Ignorable by Annotation )

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

52
            /** @scrutinizer ignore-type */ $this->client->getWebShopId(),
Loading history...
53
            $targetWebShop,
54
            $orderReference,
55
            $barcode,
56
            $documentType,
57
            $printer
58
        );
59
60
        return $this->client->generateAdditionalPdfDocument($request);
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function generateAdditionalImageDocument($orderReference, $barcode, $documentType, $targetWebShop = null)
67
    {
68
        $request = new GenerateAdditionalDocumentType(
69
            $this->security->getHash($orderReference),
70
            $this->client->getWebShopId(),
71
            $targetWebShop,
72
            $orderReference,
73
            $barcode,
74
            $documentType
75
        );
76
77
        return $this->client->generateAdditionalImageDocument($request);
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function generatePdfCustomsDocuments(array $orderReferences, $targetWebShop = null)
84
    {
85
        $orders = [];
86
87
        foreach ($orderReferences as $orderReference) {
88
            $orders[] = new OrderType(
89
                $this->security->getHash($orderReference),
90
                $targetWebShop,
91
                $orderReference
92
            );
93
        }
94
95
        $request = new GeneratePdfCustomsDocumentsRequest(
96
            $this->client->getWebShopId(),
97
            $orders
98
        );
99
100
        return $this->client->generatePdfCustomsDocuments($request);
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106
    public function getProofOfDelivery($barcode, $targetWebShop = null)
107
    {
108
        $request = new ProofOfDeliveryRequest(
109
            $this->security->getHash($barcode),
110
            $this->client->getWebShopId(),
111
            $targetWebShop,
112
            $barcode
113
        );
114
115
        return $this->client->proofOfDelivery($request);
116
    }
117
}
118