indielab / heartbeat-restclient
Heartbeat API Restclient
Installs: 340
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- curl/curl: ~1.0
Requires (Dev)
- phpunit/phpunit: ~5.0
- satooshi/php-coveralls: ~1.0
This package is not auto-updated.
Last update: 2017-03-30 13:44:30 UTC
README
In order to use the request client library install composer and require the indielab/heartbeat-restclient
library:
composer require indielab/heartbeat-restclient:^1.0@dev
API ENDPOINT NODES
The rest client covers the most commone uses cases for making the request to the api endpoint nodes. Below a list with all api endpoint nodes:
node | exampe | response |
---|---|---|
list/pois | - | |
list/eventdates | - | |
pois | - | |
events | - | |
eventdates | - | |
search/eventdates | search/eventdates?query=gem&page=1 |
|
search/pois | search/pois?query=b&page=0 { |
|
tags | - | |
countries | - | |
user | - | |
user/auth | - | |
klick/assign | - | |
klick/resolve | klick/resolve/12345.5678 |
id,time,user_id,klick_id,user={username,gender} |
The Heartbeat API Permissione ensures that you have only access to your region assigned tags. So for example when we have assigned the region
aarau
to your account, you will only able to query those pois and events.
Using the Request class
An example of how to find pois by tags:
// request $request = new Request('api.heartbeat-aarau.ch', 'aarau', 'access-token-access-token'); // find pois based on tags // The data contains a key `poi_id` you can generate from in order to get the pois data. $cacheableData = $request->queryPois(['bar', 'restaurant', 'club']); foreach ($cacheableData as $data) { $poi = $request->getPoi($data['poi_id']); print_r($poi); }
In order to make one request for multiples pois:
foreach ($request->getPois([1, 2, 3, 'alias1', 'alias2']) as $poi) { print_r($poi); }
You can also store the pois alias or id inside your application cache/database on fetch data for a single item:
$request = new Request('api.heartbeat-aarau.ch', 'aarau', 'access-token-access-token'); $poi = $request->getPoi(123); // or using string alias `heartbeat-gmbh` print_r($poi);
API Response reference
method | node | response |
queryPois(['tag1', 'tag2]) | list/pois |
Array ( [0] => Array ( [poi_id] => 1 [alias] => boilerclub [last_update] => 1481804885 )
) |
getPois([1, 'kiff-aarau']) | pois/items/$id1,$id2 |
Array ( [0] => Array ( [id] => 16 [alias] => kiff-aarau [title] => KiFF Aarau [teaser_description] => Der Kultur-Leuchtturm der Stadt [full_description] => Das KiFF in Aarau, der meistbesuchte Kulturort im Kanton, .... [street] => Tellistrasse [street_nr] => 118 [zip] => 5001 [city] => Aarau [cords_lat] => 47.3986917 [cords_long] => 8.0636967 [tel] => +4112345678 [email] => info@kiff.ch [website] => http://www.kiff.ch [logo] => https://s3.eu-central-1.amazonaws.com/hbgmbh/92791acc-logo-kiff-aarau.jpg [last_update] => 1481804148 [images] => Array ( [0] => Array ( [id] => 622 [original_name] => kiff3.jpg [name] => ea53039e-kiff-aarau.jpg [http_source] => https://s3.eu-central-1.amazonaws.com/hbgmbh/ea53039e-kiff-aarau.jpg )
) |
getPoi('kiff-aarau') | pois/$alias |
Array ( [id] => 16 [alias] => kiff-aarau [title] => KiFF Aarau [teaser_description] => Der Kultur-Leuchtturm der Stadt [full_description] => Das KiFF in Aarau, der meistbesuchte Kulturort im Kanton, .... [street] => Tellistrasse [street_nr] => 118 [zip] => 5001 [city] => Aarau [cords_lat] => 47.3986917 [cords_long] => 8.0636967 [tel] => +4112345678 [email] => info@kiff.ch [website] => http://www.kiff.ch [logo] => https://s3.eu-central-1.amazonaws.com/hbgmbh/92791acc-logo-kiff-aarau.jpg [last_update] => 1481804148 [images] => Array ( [0] => Array ( [id] => 622 [original_name] => kiff3.jpg [name] => ea53039e-kiff-aarau.jpg [http_source] => https://s3.eu-central-1.amazonaws.com/hbgmbh/ea53039e-kiff-aarau.jpg )
) |
Run tests
In order to run the php unit tests:
./vendor/bin/phpunit tests/