1 | <?php |
||
12 | class CommunicationAdapter |
||
13 | { |
||
14 | const RESPONSE_NEW_LINE = 0; |
||
15 | const RESPONSE_URL_ENCODED = 1; |
||
16 | |||
17 | /** |
||
18 | * @var Client |
||
19 | */ |
||
20 | protected $client; |
||
21 | |||
22 | /** |
||
23 | * @var Account |
||
24 | */ |
||
25 | protected $account; |
||
26 | |||
27 | /** |
||
28 | * @param \Checkdomain\Comodo\Model\Account $account |
||
29 | * |
||
30 | * @return CommunicationAdapter |
||
31 | */ |
||
32 | public function setAccount($account) |
||
33 | { |
||
34 | $this->account = $account; |
||
35 | |||
36 | return $this; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return \Checkdomain\Comodo\Model\Account |
||
41 | */ |
||
42 | public function getAccount() |
||
43 | { |
||
44 | return $this->account; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Constructs a communication adapter with an account |
||
49 | * |
||
50 | * @param Account $account |
||
51 | */ |
||
52 | public function __construct(Account $account = null) |
||
56 | |||
57 | /** |
||
58 | * @param \GuzzleHttp\Client $client |
||
59 | * |
||
60 | * @return CommunicationAdapter |
||
61 | */ |
||
62 | public function setClient($client) |
||
68 | |||
69 | /** |
||
70 | * @return \GuzzleHttp\Client |
||
71 | */ |
||
72 | public function getClient() |
||
80 | |||
81 | /** |
||
82 | * Sends a query to the provided url and return the response body. |
||
83 | * |
||
84 | * @param string $url |
||
85 | * @param array $params |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | public function sendToWebsite($url, array $params) |
||
103 | |||
104 | /** |
||
105 | * Send a request to the comodo API, and decodes the response as given |
||
106 | * |
||
107 | * @param string $url |
||
108 | * @param array $params |
||
109 | * @param int $responseType |
||
110 | * @param array|null $notDecode |
||
111 | * @param array $forceArray |
||
112 | * |
||
113 | * @return array|bool |
||
114 | */ |
||
115 | public function sendToApi($url, array $params, $responseType = self::RESPONSE_NEW_LINE, array $notDecode = null, $forceArray = array()) |
||
145 | |||
146 | /** |
||
147 | * Checks, if a valid account has been provided |
||
148 | * |
||
149 | * @return bool |
||
150 | * @throws \Exception |
||
151 | */ |
||
152 | protected function preSendToApiCheck() |
||
164 | |||
165 | /** |
||
166 | * Decodes a responseString, separated by new lines and returns an response array |
||
167 | * |
||
168 | * @param string $responseString |
||
169 | * @param string $requestQuery |
||
170 | * @param array $forceArray |
||
171 | * |
||
172 | * @return array |
||
173 | */ |
||
174 | protected function decodeNewLineEncodedResponse($responseString, $requestQuery, array $forceArray = array()) |
||
232 | |||
233 | /** |
||
234 | * Decodes a responseString, encoded in query-string-format and returns an response array |
||
235 | * |
||
236 | * @param string $responseString |
||
237 | * @param string $requestQuery |
||
238 | * @param array $notDecode |
||
239 | * @param string[] $forceArray |
||
240 | * |
||
241 | * @return mixed |
||
242 | */ |
||
243 | protected function decodeUrlEncodedResponse( |
||
284 | } |
||
285 |