1 | <?php |
||
16 | abstract class Service |
||
17 | { |
||
18 | const HTTP_GET = 'GET'; |
||
19 | const HTTP_POST = 'POST'; |
||
20 | const HTTP_PUT = 'PUT'; |
||
21 | const HTTP_DELETE = 'DELETE'; |
||
22 | const HTTP_PATCH = 'PATCH'; |
||
23 | |||
24 | protected $baseUrl; |
||
25 | protected $userid; |
||
26 | protected $password; |
||
27 | protected $parameters = array(); |
||
28 | protected $headers = array( |
||
29 | 'Accept-language'=> 'en-CA' |
||
30 | ); |
||
31 | |||
32 | 5 | public function __construct($baseUrl, $userid, $password) |
|
38 | |||
39 | 1 | public function setLanguage($value) |
|
44 | |||
45 | 4 | public function setHeader($name, $value) |
|
50 | |||
51 | 4 | public function hasParameter($name) |
|
55 | |||
56 | 4 | public function setParameter($name, $value) |
|
61 | |||
62 | 4 | public function getParameter($name, $default=null) |
|
67 | |||
68 | 4 | public function getBaseUrl() |
|
72 | |||
73 | /** |
||
74 | * @return Request |
||
75 | */ |
||
76 | abstract protected function buildRequest(); |
||
77 | |||
78 | /** |
||
79 | * @return Response |
||
80 | */ |
||
81 | 4 | public function send() |
|
98 | } |
||
99 |