DocumentGateway::getAvailableDocuments()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.2109

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 11
ccs 5
cts 8
cp 0.625
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2.2109
1
<?php
2
/*
3
 * This file is part of the PayBreak/paybreak-sdk-php package.
4
 *
5
 * (c) PayBreak <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PayBreak\Sdk\Gateways;
12
13
/**
14
 * Class DocumentGateway
15
 *
16
 * @author GK
17
 * @package PayBreak\Sdk\Gateways
18
 */
19
class DocumentGateway extends AbstractGateway
20
{
21
    /**
22
     * @author GK, EB
23
     * @param string $token
24
     * @param string $installation
25
     * @param int $application
26
     * @return array
27
     */
28 1
    public function getAvailableDocuments($token, $installation, $application)
29
    {
30
        try {
31 1
            return $this->fetchDocument(
32 1
                '/v4/installations/' . $installation . '/applications/' . $application . '/documents',
33 1
                $token,
34
                'Documents'
35 1
            );
36
        } catch (\Exception $e) {
37
            $this->logWarning('Could not fetch documents for [' . $application . ']: ' . $e->getMessage());
38
            return [];
39
        }
40
    }
41
42
    /**
43
     * @author GK
44
     * @param string $token
45
     * @param string $installation
46
     * @param int $application
47
     * @return array
48
     */
49 1
    public function getAgreementPdf($token, $installation, $application)
50
    {
51 1
        $document = $this->fetchDocument(
52 1
            '/v4/installations/' . $installation . '/applications/' . $application . '/agreement',
53 1
            $token,
54
            'Agreement Pdf'
55 1
        );
56
57 1
        return $document['pdf'];
58
    }
59
60
    /**
61
     * @author GK
62
     * @param string $token
63
     * @param string $installation
64
     * @param int $application
65
     * @return array
66
     */
67 1
    public function getPreAgreementPdf($token, $installation, $application)
68
    {
69 1
        $document = $this->fetchDocument(
70 1
            '/v4/installations/' . $installation . '/applications/' . $application . '/pre-agreement',
71 1
            $token,
72
            'Pre-agreement Pdf'
73 1
        );
74
75 1
        return $document['pdf'];
76
    }
77
78
    /**
79
     * @author GK
80
     * @param string $token
81
     * @param string $installation
82
     * @param int $application
83
     * @return array
84
     */
85 1
    public function getAdequateExplanation($token, $installation, $application)
86
    {
87 1
        $document = $this->fetchDocument(
88 1
            '/v4/installations/' . $installation . '/applications/' . $application . '/adequate-explanation',
89 1
            $token,
90
            'Adequate Explanation Pdf'
91 1
        );
92
93 1
        return $document['pdf'];
94
    }
95
}
96