CaptureRequest::getData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Empatix\OmnipaySwedbank\Messages;
4
5
use Empatix\OmnipaySwedbank\Gateway;
6
use Empatix\OmnipaySwedbank\Messages\Response;
7
use Empatix\OmnipaySwedbank\Messages\PurchaseRequest;
8
9
class CaptureRequest extends PurchaseRequest
10
{
11
    public function setPaymentId($value)
12
    {
13
        $this->setParameter('paymentId', $value);
14
    }
15
16
    public function getPaymentId()
17
    {
18
        return $this->getParameter('paymentId');
19
    }
20
21
    public function setPurchaseId($value)
22
    {
23
        $this->setParameter('purchaseId', $value);
24
    }
25
26
    public function getPurchaseId()
27
    {
28
        return $this->getParameter('purchaseId');
29
    }
30
31
    public function getData()
32
    {
33
        return [
34
            'transaction' => [
35
                'amount' => $this->getAmount(),
36
                'vatAmount' => $this->getVatAmount(),
37
                'description' => $this->getDescription(),
38
                'payeeReference' => $this->getPayeeReference(),
39
            ],
40
        ];
41
    }
42
43
    public function sendData($data)
44
    {
45
        $result = $this->httpClient->request(
46
            'POST',
47
            $this->getEndpoint() . $this->resource,
48
            [
49
                'Authorization' => 'Bearer ' . $this->getPassword(),
50
                'Content-Type' => 'application/json; charset=utf-8',
51
                'Accept' => 'application/problem+json; q=1.0, application/json; q=0.9',
52
            ],
53
            json_encode($data)
54
        );
55
56
        return $this->response = new Response(
57
            $this,
58
            $result->getBody()->getContents()
59
        );
60
    }
61
}
62