1 | <?php |
||
16 | class Client implements HttpContract |
||
17 | { |
||
18 | use ConfigurationTrait, |
||
19 | HttpTrait; |
||
20 | |||
21 | /** |
||
22 | * Consumer key |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $consumerKey; |
||
27 | |||
28 | /** |
||
29 | * Consumer secret |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $consumerSecret; |
||
34 | |||
35 | /** |
||
36 | * Access token |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $token; |
||
41 | |||
42 | /** |
||
43 | * Access token secret |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $tokenSecret; |
||
48 | |||
49 | /** |
||
50 | * Default search term |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $defaultTerm = 'bar'; |
||
55 | |||
56 | /** |
||
57 | * Default location |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $defaultLocation = 'Chicago, IL'; |
||
62 | |||
63 | /** |
||
64 | * Default search limit |
||
65 | * |
||
66 | * @var integer |
||
67 | */ |
||
68 | protected $searchLimit = 3; |
||
69 | |||
70 | /** |
||
71 | * Create new client |
||
72 | * |
||
73 | * @param array $options |
||
74 | */ |
||
75 | 16 | public function __construct(array $options = array()) |
|
92 | |||
93 | /** |
||
94 | * Creates default http client with appropriate authorization configuration. |
||
95 | * |
||
96 | * @return HttpClient |
||
97 | */ |
||
98 | 16 | public function createDefaultHttpClient() |
|
115 | |||
116 | /** |
||
117 | * Fetches a specific business by id. |
||
118 | * |
||
119 | * @param string $businessId |
||
120 | * @param array $parameters |
||
121 | * |
||
122 | * @return stdClass |
||
123 | * @throws Stevenmaguire\Yelp\Exception\HttpException |
||
124 | */ |
||
125 | 4 | public function getBusiness($businessId, $parameters = []) |
|
132 | |||
133 | /** |
||
134 | * Sends a request instance and returns a response instance. |
||
135 | * |
||
136 | * WARNING: This method does not attempt to catch exceptions caused by HTTP |
||
137 | * errors! It is recommended to wrap this method in a try/catch block. |
||
138 | * |
||
139 | * @param RequestInterface $request |
||
140 | * @return ResponseInterface |
||
141 | * @throws Stevenmaguire\Yelp\Exception\HttpException |
||
142 | */ |
||
143 | 10 | public function getResponse(RequestInterface $request) |
|
153 | |||
154 | /** |
||
155 | * Provides a hook that handles the response before returning to the consumer. |
||
156 | * |
||
157 | * @param ResponseInterface $response |
||
158 | * |
||
159 | * @return ResponseInterface |
||
160 | */ |
||
161 | 8 | protected function handleResponse(ResponseInterface $response) |
|
165 | |||
166 | /** |
||
167 | * Fetches results from the Business Search API. |
||
168 | * |
||
169 | * @param array $parameters |
||
170 | * |
||
171 | * @return stdClass |
||
172 | * @throws Stevenmaguire\Yelp\Exception\HttpException |
||
173 | */ |
||
174 | 4 | public function search($parameters = []) |
|
187 | |||
188 | /** |
||
189 | * Fetches results from the Business Search API by Phone. |
||
190 | * |
||
191 | * @param array $parameters |
||
192 | * |
||
193 | * @return stdClass |
||
194 | * @throws Stevenmaguire\Yelp\Exception\HttpException |
||
195 | */ |
||
196 | 2 | public function searchByPhone($parameters = []) |
|
203 | |||
204 | /** |
||
205 | * Set default location |
||
206 | * |
||
207 | * @param string $location |
||
208 | * |
||
209 | * @return Client |
||
210 | */ |
||
211 | 2 | public function setDefaultLocation($location) |
|
217 | |||
218 | /** |
||
219 | * Set default term |
||
220 | * |
||
221 | * @param string $term |
||
222 | * |
||
223 | * @return Client |
||
224 | */ |
||
225 | 2 | public function setDefaultTerm($term) |
|
231 | |||
232 | /** |
||
233 | * Set search limit |
||
234 | * |
||
235 | * @param integer $limit |
||
236 | * |
||
237 | * @return Client |
||
238 | */ |
||
239 | 2 | public function setSearchLimit($limit) |
|
247 | } |
||
248 |