RedirectCompleteFlowRequest::getData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Omnipay\GoCardless\Message;
4
5
/**
6
 * GoCardless Complete Redirect Flow
7
 */
8
class RedirectCompleteFlowRequest extends AbstractRequest
9
{
10
    public function getRedirectFlowId()
11
    {
12
        return $this->getParameter('redirectFlowId');
13
    }
14
15
    public function setRedirectFlowId($value)
16
    {
17
        return $this->setParameter('redirectFlowId', $value);
18
    }
19
20
    public function getSessionToken()
21
    {
22
        return $this->getParameter('sessionToken');
23
    }
24
25
    public function setSessionToken($value)
26
    {
27
        return $this->setParameter('sessionToken', $value);
28
    }
29
30
    public function getData()
31
    {
32
        $this->validate('redirectFlowId', 'sessionToken');
33
        $this->action = '/redirect_flows/'.$this->getRedirectFlowId().'/actions/complete';
34
        return ['session_token' => $this->getSessionToken()];
35
    }
36
37
    /**
38
     * Send the request with specified data
39
     *
40
     * @param  mixed $data The data to send
41
     *
42
     * @return RedirectCompleteFlowResponse
43
     */
44
    public function sendData($data)
45
    {
46
        $response = $this->sendRequest(['data' => $data]);
47
48
        return $this->response = new RedirectCompleteFlowResponse(
49
            $this,
50
            json_decode($response->getBody()->getContents(), true)
51
        );
52
    }
53
}
54