-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathAPIRequest.php
More file actions
56 lines (49 loc) · 1.08 KB
/
APIRequest.php
File metadata and controls
56 lines (49 loc) · 1.08 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
<?php
namespace Classifai\Providers\GoogleAI;
use Classifai\Providers\HTTPClient;
/**
* The APIRequest class is a low level class to make Google AI API
* requests.
*
* The returned response is parsed into JSON and returned as an
* associative array.
*
* Usage:
*
* $request = new Classifai\Providers\GoogleAI\APIRequest();
* $request->post( $googleai_url, $options );
*/
class APIRequest extends HTTPClient {
/**
* Get the filter prefix for this provider.
*
* @return string
*/
protected function get_filter_prefix(): string {
return 'classifai_googleai';
}
/**
* Add authentication header.
*
* @param array $options The header options, passed by reference.
*/
protected function add_auth_header( array &$options ) {
$options['headers']['x-goog-api-key'] = $this->get_auth_header();
}
/**
* Get the auth header.
*
* @return string
*/
public function get_auth_header(): string {
return $this->get_api_key();
}
/**
* Get the Google AI API key.
*
* @return string
*/
public function get_api_key(): string {
return $this->api_key;
}
}