1. Go to this page and download the library: Download otis22/vetmanager-rest-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
otis22 / vetmanager-rest-api example snippets
use GuzzleHttp\Client;
use function Otis22\VetmanagerUrl\url;
use function Otis22\VetmanagerRestApi\uri;
use function Otis22\VetmanagerRestApi\byApiKey;
use Otis22\VetmanagerRestApi\Query\Builder;
$client = new Client([
'base_uri' => url("myclinic")->asString()
]);
$top = (new Builder())
->where('client_id', 'in', [1, 2])
->orderBy('invoice_date', 'desc')
->top(1);
$response = $client->request(
'GET',
uri("invoice")->asString(),
[
'headers' => byApiKey("myapikey")->asKeyValue(),
'query' => $top->asKeyValue()
]
);
use Otis22\VetmanagerRestApi\Headers;
use Otis22\VetmanagerRestApi\Headers\Auth\ApiKey;
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
$authHeaders = new Headers\WithAuth(
new Headers\Auth\ByApiKey(
new ApiKey('test-key')
)
);
$client->request(
'GET',
'/rest/api/user/1',
['headers' => $authHeaders->asKeyValue()]
);
$authHeaders = Otis22\VetmanagerRestApi\byApiKey('test-key');
# use this after ['headers' => $authHeaders->asKeyValue()]
use Otis22\VetmanagerRestApi\Headers;
use Otis22\VetmanagerRestApi\Headers\Auth\ApiKey;
$myHeaders = [
'X-REST-TIME-ZONE' => '+02:00'
];
$allHeaders = new Headers\WithAuthAndParams(
new Headers\Auth\ByApiKey(
new ApiKey('test-key')
),
$myHeaders
);
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
$client->request(
'GET',
'/rest/api/user/1',
['headers' => $allHeaders->asKeyValue()]
);
use Otis22\VetmanagerRestApi\Headers;
use Otis22\VetmanagerToken;
$authHeaders = new Headers\WithAuth(
new Headers\Auth\ByToken(
new Credentials\AppName("myapp"),
new Token\Concrete("mytoken")
)
);
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
$client->request(
'GET',
'/rest/api/user/1',
['headers' => $authHeaders->asKeyValue()]
);
$authHeaders = Otis22\VetmanagerRestApi\byToken('myapp', 'mytoken');
# use this after ['headers' => $authHeaders->asKeyValue()]
use Otis22\VetmanagerRestApi\Headers;
use Otis22\VetmanagerRestApi\Headers\Auth\ServiceName;
use Otis22\VetmanagerRestApi\Headers\Auth\ApiKey;
$authHeaders = new Headers\WithAuth(
new Headers\Auth\ByServiceApiKey(
new ServiceName('name')
new ApiKey('key')
)
);
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
$client->request(
'GET',
'/rest/api/user/1',
['headers' => $authHeaders->asKeyValue()]
);
$authHeaders = Otis22\VetmanagerRestApi\byServiceApiKey('service', 'api key');
# use this after ['headers' => $authHeaders->asKeyValue()]
use Otis22\VetmanagerRestApi\URI;
use Otis22\VetmanagerRestApi\Model;
$uri = new URI\OnlyModel(
new Model('invoice')
);
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
// request to /rest/api/invoice
$client->request('GET', $uri->asString());
use Otis22\VetmanagerRestApi\URI;
use Otis22\VetmanagerRestApi\Model;
$uri = new URI\WithId(
new Model('invoice'),
5
);
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
// request to /rest/api/invoice/5
$client->request('GET', $uri->asString());
use Otis22\VetmanagerRestApi\Query\Filters;
use Otis22\VetmanagerRestApi\Query\Filter\EqualTo;
use Otis22\VetmanagerRestApi\Model\Property;
use Otis22\VetmanagerRestApi\Query\Filter\Value\StringValue;
$filters = new Filters(
new EqualTo(
new Property('propertyName'),
new StringValue('propertyValue')
)
# ... we can use mach more filters new Filters($filterOne, $filterTwo, ... );
);
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
$client->request(
'GET',
'/rest/api/user/1',
[
'headers' => $authHeaders->asKeyValue(),
'query' => $filters->asKeyValue()
]
);
use Otis22\VetmanagerRestApi\Query\Sorts;
use Otis22\VetmanagerRestApi\Query\Sort\AscBy;
use Otis22\VetmanagerRestApi\Query\Sort\DescBy;
use Otis22\VetmanagerRestApi\Model\Property;
$sorts = new Sorts(
new AscBy(
new Property('propertyName')
),
new DescBy(
new Property('property2Name')
)
);
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
$client->request(
'GET',
'/rest/api/user/1',
[
'headers' => $authHeaders->asKeyValue(),
'query' => $sorts->asKeyValue()
]
);
use Otis22\VetmanagerRestApi\Query\Query;
...
$query = new Query(
new Filters(...),
new Sorts(...)
);
$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);
$client->request(
'GET',
'/rest/api/user/1',
[
'headers' => $authHeaders->asKeyValue(),
'query' => $query->asKeyValue()
]
);