ReversalRequest::sendData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 16
rs 9.9332
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 ReversalRequest extends PurchaseRequest
10
{
11
    public function getData()
12
    {
13
        return [
14
            'transaction' => [
15
                'amount' => $this->getAmount(),
16
                'vatAmount' => $this->getVatAmount(),
17
                'description' => $this->getDescription(),
18
                'payeeReference' => $this->getPayeeReference(),
19
            ],
20
        ];
21
    }
22
23
    public function sendData($data)
24
    {
25
            $result = $this->httpClient->request(
26
                'POST',
27
                $this->getEndpoint() . $this->resource,
28
                [
29
                    'Authorization' => 'Bearer ' . $this->getPassword(),
30
                    'Content-Type' => 'application/json; charset=utf-8',
31
                    'Accept' => 'application/problem+json; q=1.0, application/json; q=0.9',
32
                ],
33
                json_encode($data)
34
            );
35
36
        return $this->response = new Response(
37
            $this,
38
            $result->getBody()->getContents()
39
        );
40
    }
41
}
42