Test Failed
Pull Request — master (#3)
by
unknown
07:33
created

BaseRequest::getPassword()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Omnipay\Komerci;
4
5
use Omnipay\Common\Message\AbstractRequest;
6
7
/**
8
 * Komerci Authorize Request
9
 */
10
abstract class BaseRequest extends AbstractRequest
11
{
12
    protected $endpoint = 'https://ecommerce.userede.com.br/pos_virtual/wskomerci/cap.asmx/';
13
    protected $endpointTest = 'https://ecommerce.userede.com.br/pos_virtual/wskomerci/cap_teste.asmx/';
14
15
    public function getEndpoint($method)
16
    {
17
        return $this->getTestMode() ? $this->endpointTest . $method . "Tst" : $this->endpoint . $method;
18
    }
19
20
    public function getApiKey()
21
    {
22
        return $this->getParameter('apikey');
23
    }
24
25
    public function setApiKey($value)
26
    {
27
        return $this->setParameter('apikey', $value);
28
    }
29
30
    public function getTestMode()
31
    {
32
        return $this->getParameter('testMode');
33
    }
34
35
    public function setTestMode($value)
36
    {
37
        return $this->setParameter('testMode', $value);
38
    }
39
40
    public function getUsername()
41
    {
42
        if ($this->getTestMode()) {
43
            return 'testews';
44
        }
45
        return $this->getParameter('username');
46
    }
47
48
    public function setUsername($value)
49
    {
50
        return $this->setParameter('username', $value);
51
    }
52
53
    public function getPassword()
54
    {
55
        if ($this->getTestMode()) {
56
            return 'testews';
57
        }
58
        return $this->getParameter('password');
59
    }
60
61
    public function setPassword($value)
62
    {
63
        return $this->setParameter('password', $value);
64
    }
65
66
    public function getTransactionReference()
67
    {
68
        return $this->getParameter('transactionReference');
69
    }
70
71
    public function setTransactionReference($value)
72
    {
73
        return $this->setParameter('transactionReference', $value);
74
    }
75
76
    public function getNumAutor()
77
    {
78
        return $this->getParameter('numautor');
79
    }
80
81
    public function setNumAutor($value)
82
    {
83
        return $this->setParameter('numautor', $value);
84
    }
85
86
    public function getDate()
87
    {
88
        return $this->getParameter('date');
89
    }
90
91
    public function getFormattedDate()
92
    {
93
        return date('Ymd', strtotime($this->getParameter('date')));
94
    }
95
96
    public function setDate($value)
97
    {
98
        return $this->setParameter('date', $value);
99
    }
100
101
    /**
102
     *
103
     * @param type $data
104
     * @param string $method
105
     * @return \Omnipay\Common\Message\RequestInterface
106
     */
107
    protected function prepareSendData($data, $method)
108
    {
109
        if (!is_array($data)) {
110
            $data = array();
111
        }
112
113
        $httpResponse = $this->httpClient->post($this->getEndpoint($method), null, $data)->send();
114
115
        return $httpResponse;
116
    }
117
118
}
119