Skip to content

Commit 4e5ca9c

Browse files
committed
readme authorization
1 parent c7016aa commit 4e5ca9c

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@ $accessToken = $authorization->getAccessToken('YOUR_CLIENT_ID', 'YOUR_CLIENT_SEC
3030
// Configure access token for authorization
3131
$config = DocPlanner\Client\Configuration::getDefaultConfiguration()->setAccessToken($accessToken);
3232

33-
$apiInstance = new DocPlanner\Client\Api\AddressesApi(
33+
$apiInstance = new DocPlanner\Client\Api\DoctorsApi(
3434
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
3535
// This is optional, `GuzzleHttp\Client` will be used as default.
3636
new GuzzleHttp\Client(),
3737
$config
3838
);
3939
$facility_id = 56; // int | ID of the Facility
40-
$doctor_id = 56; // int | ID of a doctor in a facility
41-
$address_id = 56; // int | ID of a doctor`s address in a facility
42-
$with = array(\DocPlanner\Client\Model\AddressScopes::VISIT_PAYMENT); // string[] |
40+
$with = array(\DocPlanner\Client\Model\DoctorsScopes::SPECIALIZATIONS); // string[] |
4341

4442
try {
45-
$result = $apiInstance->getAddress($facility_id, $doctor_id, $address_id, $with);
43+
$result = $apiInstance->getDoctors($facility_id, $with);
4644
print_r($result);
4745
} catch (Exception $e) {
48-
echo 'Exception when calling AddressesApi->getAddress: ', $e->getMessage(), PHP_EOL;
46+
echo 'Exception when calling DoctorsApi->getDoctors: ', $e->getMessage(), PHP_EOL;
4947
}
5048

5149
// Configure access token for authorization
@@ -59,20 +57,39 @@ $apiInstance = new DocPlanner\Client\Api\AddressesApi(
5957
);
6058
$facility_id = 56; // int | ID of the Facility
6159
$doctor_id = 56; // int | ID of a doctor in a facility
62-
$with = DocPlanner\Client\Model\AddressesScopes::getAllowableEnumValues(); // string[] |
6360

6461
try {
65-
$result = $apiInstance->getAddresses($facility_id, $doctor_id, $with);
62+
$result = $apiInstance->getAddresses($facility_id, $doctor_id);
6663
print_r($result);
6764
} catch (Exception $e) {
6865
echo 'Exception when calling AddressesApi->getAddresses: ', $e->getMessage(), PHP_EOL;
6966
}
7067
?>
7168
```
7269

70+
## Authorization
71+
72+
To get access to API you need to make request to `https://www.{domain}/oauth/v2/token` for access token using your client credentials (`client_id` and `client_secret`).
73+
Then it could be injected to `Configuration` which is used to instantiate API clients.
74+
Whole authorization process is based on OAuth2 protocol with `grant_type = client_credentials` and `scope = integration`.
75+
Obtained token is valid for the next 24h, so it is good practice to cache it for that period.
76+
77+
###Example
78+
```php
79+
//Get OAuth2 access token
80+
$authorization = new DocPlanner\Client\Authorization('AUTHORIZATION_URL');
81+
$accessToken = $authorization->getAccessToken('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
82+
83+
// Configure access token for authorization
84+
$config = DocPlanner\Client\Configuration::getDefaultConfiguration()->setAccessToken($accessToken);
85+
86+
$apiInstance = new DocPlanner\Client\Api\AddressesApi(null, $config);
87+
```
88+
89+
7390
## Documentation for API Endpoints
7491

75-
All URIs are relative to *https://www.znanylekarz.pl/api/v3/integration*
92+
All URIs are relative to `https://www.{domain}/api/v3/integration`
7693

7794
Class | Method | HTTP request | Description
7895
------------ | ------------- | ------------- | -------------

0 commit comments

Comments
 (0)