1 | <?php |
||
9 | abstract class AbstractRequest extends BaseAbstractRequest |
||
10 | { |
||
11 | use HasSpreedlyConfig; |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $endpoint = 'https://core.spreedly.com/v1/'; |
||
17 | |||
18 | /** |
||
19 | * Get HTTP Method. |
||
20 | * |
||
21 | * This is nearly always POST but can be over-ridden in sub classes. |
||
22 | * |
||
23 | * @return string |
||
24 | */ |
||
25 | 18 | public function getHttpMethod() |
|
26 | { |
||
27 | 18 | return 'POST'; |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @return array |
||
32 | */ |
||
33 | 36 | public function getHeaders() |
|
34 | { |
||
35 | $headers = array( |
||
36 | 'Content-Type' => 'application/json' |
||
37 | 36 | ); |
|
38 | |||
39 | 36 | return $headers; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | abstract public function getEndpoint(); |
||
46 | |||
47 | /** |
||
48 | * @param array|null $data |
||
49 | * @return \Omnipay\Common\Message\ResponseInterface|Response |
||
50 | */ |
||
51 | 36 | public function sendData($data) |
|
66 | |||
67 | /** |
||
68 | * Map data with existing parameters |
||
69 | * |
||
70 | * @param array $data |
||
71 | * @param array $map |
||
72 | * @return array |
||
73 | */ |
||
74 | 24 | protected function fillExistingParameters($data, $map) |
|
91 | |||
92 | 34 | protected function createResponse($data) |
|
96 | } |
||
97 |