-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMindeeApi.php
More file actions
63 lines (57 loc) · 1.8 KB
/
Copy pathMindeeApi.php
File metadata and controls
63 lines (57 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
declare(strict_types=1);
/**
* Settings and variables linked to endpoint calling & API usage.
*/
namespace Mindee\V1\Http;
use Mindee\Error\ErrorCode;
use Mindee\Error\MindeeException;
use Mindee\V1\Client;
/**
* Data class containing settings for endpoints.
*/
class MindeeApi extends BaseApi
{
/**
* @var string Name of the endpoint.
*/
public string $endpointName;
/**
* @var string Version of the endpoint.
*/
public string $version;
/**
* @var string Name of the owner of an endpoint. Is equals to 'mindee' for off-the-shelf APIs.
*/
public string $accountName;
/**
* @param string|null $apiKey API key.
* @param string $endpointName Name of the endpoint.
* @param string|null $accountName Name of the endpoint's owner.
* @param string|null $version Version of the endpoint.
* @throws MindeeException Throws if the API key specified is invalid.
*/
public function __construct(
?string $apiKey,
string $endpointName,
?string $accountName = Client::DEFAULT_OWNER,
?string $version = "1"
) {
parent::__construct($apiKey);
if (empty($this->apiKey)) {
throw new MindeeException(
"Missing API key for '$endpointName v$version' (belonging to $accountName),"
. " check your Client configuration.You can set this using the "
. API_KEY_ENV_NAME . ' environment variable.',
ErrorCode::USER_INPUT_ERROR
);
}
$this->endpointName = $endpointName;
$this->accountName = $accountName;
$this->version = $version;
$this->urlRoot = rtrim(
$this->baseUrl,
"/"
) . "/v1/products/$this->accountName/$this->endpointName/v$this->version";
}
}