1 | <?php |
||
7 | class Response implements ResponseInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $response; |
||
13 | |||
14 | /** |
||
15 | * @var array|null |
||
16 | */ |
||
17 | protected $lastError; |
||
18 | |||
19 | /** |
||
20 | * Check if specified data exists in response |
||
21 | * @param $response |
||
22 | * @param null $key |
||
23 | * @return array|bool |
||
24 | */ |
||
25 | public function getData($response, $key = null) |
||
34 | |||
35 | /** |
||
36 | * Parse data from Pinterest Api response. |
||
37 | * Data stores in ['resource_response']['data'] array |
||
38 | * |
||
39 | * @param $response |
||
40 | * @param $key |
||
41 | * @return bool|array |
||
42 | */ |
||
43 | protected function parseData($response, $key) |
||
57 | |||
58 | /** |
||
59 | * Checks if response is not empty |
||
60 | * |
||
61 | * @param array $response |
||
62 | * @return bool |
||
63 | */ |
||
64 | public function notEmpty($response) |
||
68 | |||
69 | public function checkResponse($response) |
||
73 | |||
74 | /** |
||
75 | * Check for error info in api response and save |
||
76 | * it. |
||
77 | * |
||
78 | * @param array $response |
||
79 | * @return bool |
||
80 | */ |
||
81 | public function checkErrorInResponse($response) |
||
92 | |||
93 | /** |
||
94 | * Parse bookmarks from response |
||
95 | * @param array $response |
||
96 | * @return array|null |
||
97 | */ |
||
98 | public function getBookmarksFromResponse($response) |
||
109 | |||
110 | /** |
||
111 | * Checks Pinterest API paginated response, and parses data |
||
112 | * with bookmarks info from it. |
||
113 | * |
||
114 | * @param array $response |
||
115 | * @return array |
||
116 | */ |
||
117 | public function getPaginationData($response) |
||
130 | |||
131 | /** |
||
132 | * Parses Pinterest search API response for data and bookmarks |
||
133 | * for next pagination page |
||
134 | * |
||
135 | * @param array $response |
||
136 | * @param bool $bookmarksUsed |
||
137 | * @return array|null |
||
138 | */ |
||
139 | public function parseSearchResponse($response, $bookmarksUsed = true) |
||
147 | |||
148 | /** |
||
149 | * Parses simple Pinterest search API response |
||
150 | * on request with bookmarks |
||
151 | * |
||
152 | * @param $response |
||
153 | * @return array |
||
154 | */ |
||
155 | public function parseSimpledSearchResponse($response) |
||
168 | |||
169 | /** |
||
170 | * @return array |
||
171 | */ |
||
172 | public function getLastError() |
||
176 | } |