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