1 | <?php |
||
10 | class ApiClient implements ApiClientInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var string Airtable Api |
||
14 | */ |
||
15 | protected $apiUrl = 'https://api.airtable.com'; |
||
16 | |||
17 | /** |
||
18 | * @var string Airtable API Version |
||
19 | */ |
||
20 | protected $apiVersion = 'v0'; |
||
21 | |||
22 | /** |
||
23 | * @var string Airtable base project |
||
24 | */ |
||
25 | protected $base = ''; |
||
26 | |||
27 | /** |
||
28 | * @var string Table in base project |
||
29 | */ |
||
30 | protected $table = ''; |
||
31 | |||
32 | /** |
||
33 | * @var int Max numbers of records to return |
||
34 | */ |
||
35 | protected $limit = 10; |
||
36 | |||
37 | /** |
||
38 | * @var string Page offset if records > limit |
||
39 | */ |
||
40 | protected $offset = ''; |
||
41 | |||
42 | /** |
||
43 | * @var string Airtable API key |
||
44 | */ |
||
45 | private $apiKey = ''; |
||
46 | |||
47 | /** |
||
48 | * @var Service\HttpInterface |
||
49 | */ |
||
50 | private $service; |
||
51 | |||
52 | |||
53 | /** |
||
54 | * @param HttpInterface $service |
||
55 | * @param array<mixed> $config |
||
56 | * |
||
57 | * @throws MissingConfigException |
||
58 | */ |
||
59 | 6 | public function __construct(HttpInterface $service, array $config) |
|
74 | |||
75 | /** |
||
76 | * @param string $base |
||
77 | * @param string $table |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | 1 | public function listRecords(string $base, string $table): string |
|
86 | |||
87 | /** |
||
88 | * @param string $base Airtable base id |
||
89 | * @param string $table Airtable table id |
||
90 | * @param string $id Table record id |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | 1 | public function listRecord(string $base, string $table, string $id): string |
|
98 | |||
99 | /** |
||
100 | * @param string $base Airtable base id |
||
101 | * @param string $table Airtable table id |
||
102 | * |
||
103 | * @param array<string> $fields Array containing data for the new record |
||
104 | * @return string |
||
105 | * |
||
106 | * @throws \FondOf\Airtable\Exception\NoWriteDataException |
||
107 | * @throws \FondOf\Airtable\Exception\MarshalFieldsException |
||
108 | */ |
||
109 | 2 | public function createRecord(string $base, string $table, array $fields): string |
|
127 | |||
128 | /** |
||
129 | * @param int $limit Max number of records to return |
||
130 | */ |
||
131 | public function setLimit(int $limit): void |
||
135 | |||
136 | /** |
||
137 | * @return string |
||
138 | */ |
||
139 | 3 | private function apiUrl(): string |
|
143 | } |
||
144 |