Skip to content

Commit adab3b7

Browse files
committed
readme
1 parent 31acc60 commit adab3b7

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

README.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,52 @@ PLHW API Client provides means to authenticate clients against with OAuth2 serve
66
## Installation
77

88
```bash
9-
composer require plhw/hf-api-client:^0.1
9+
composer require plhw/hf-api-client
1010
```
1111

12-
## Usage
1312

13+
14+
## Example API calls
15+
16+
Once you have succesfully installed the application, some example scripts are located at. To use them first copy an configuration file to your app root.
17+
18+
```bash
19+
cp ./vendor/plhw/hf-api-client/example/.hf-api-client-example.php-dist ./.hf-api-client-example.php
1420
```
21+
22+
Open `.hf-api-client-example.php` and configure it with credentials you got from us.
23+
24+
Now to can run the example scripts;
25+
26+
```bash
27+
php ./vendor/plhw/hf-api-client/example/practicesPos.php
28+
```
29+
30+
## Usage
31+
32+
To implement usage in your application you can have a look at the example scripts.
33+
34+
```php
1535
$options = \HF\ApiClient\Options\Options::fromArray(
1636
[
1737
'server_uri' => 'https://api.plhw.nl',
18-
'client_id' => $clientId,
19-
'client_secret' => $clientSecret,
38+
'client_id' => 'id',
39+
'client_secret' => 'secret',
2040
'scope' => 'customer_pos',
2141
'grant_type' => 'client_credentials',
2242
]
2343
);
2444

25-
$api = \HF\ApiClient\ApiClient::createClient($options, $cache);
45+
$api = \HF\ApiClient\ApiClient::createClient($options, /* $cache OPTIONAL */);
46+
```
47+
48+
The above is all that is nessesary to configure, though I recommend you tweak the caching meganism. Currently we use the [zendframework/zend-cache](https://docs.zendframework.com/zend-cache/) component. This might change when v3 is released to use the psr-7 caching FIG standard.
49+
50+
When you have `ApiClient` instance you can use it by calling methods as defined in `/vendor/plhw/hf-api-client/data/v1` on it. Additionally [API documentation](https://api.plhw.nl/docs) can be found here.
2651

52+
for example, search the published practices around a coordinate.
53+
54+
```php
2755
$results = $api->customer_posAroundCoordinate('52.3629882,4.8593175', 15000, 'insoles');
2856

2957
if ($api->isSuccess()) {
@@ -35,12 +63,17 @@ if ($api->isSuccess()) {
3563
} else {
3664
printf("Error (%d): %s\n", $api->getStatusCode(), $result);
3765
}
38-
3966
```
4067

41-
see api [documentation](https://api.plhw.nl/docs) for end points.
68+
## Under the hood
69+
70+
When you call any method on the APIClient instance an access token is requested from our OAuth2 server. This access token is then cached for aditional uses up to the moment it expires or is deleted. It will then get a new access token.
71+
72+
Any calls to our API are now `signed` with that access token and is used by our permission system to determain if you have access or not.
73+
74+
Our API will accept and return json payload with are automaticly (de)encoded.
4275

43-
## ClientCredentialsGrant
76+
### OAuth2 ClientCredentialsGrant
4477

4578
For machine to machine communication OAuth2 ClientCredentialGrant is appropiate.
4679
You must obtain the following information from us.

0 commit comments

Comments
 (0)