1 | <?php |
||
15 | abstract class Service |
||
16 | { |
||
17 | const HTTP_GET = 'GET'; |
||
18 | const HTTP_POST = 'POST'; |
||
19 | const HTTP_PUT = 'PUT'; |
||
20 | const HTTP_DELETE = 'DELETE'; |
||
21 | const HTTP_PATCH = 'PATCH'; |
||
22 | |||
23 | protected $baseUrl; |
||
24 | protected $userid; |
||
25 | protected $password; |
||
26 | protected $parameters = array(); |
||
27 | protected $headers = array(); |
||
28 | |||
29 | public function __construct($baseUrl, $userid, $password) |
||
35 | |||
36 | public function setLanguage($value) |
||
40 | |||
41 | public function setHeader($name, $value) |
||
46 | |||
47 | public function hasParameter($name) |
||
51 | |||
52 | public function setParameter($name, $value) |
||
57 | |||
58 | public function getParameter($name, $default=null) |
||
63 | |||
64 | public function getBaseUrl() |
||
68 | |||
69 | /** |
||
70 | * @return RequestInterface |
||
71 | */ |
||
72 | abstract protected function buildRequest(); |
||
73 | |||
74 | /** |
||
75 | * @return Response |
||
76 | */ |
||
77 | public function send() |
||
92 | |||
93 | /** |
||
94 | * @param RequestInterface $request |
||
95 | */ |
||
96 | private function applyHeaders(RequestInterface $request) |
||
102 | } |
||
103 |