Skip to content

Commit b4ae779

Browse files
committed
Nullable callback webhook, filter multipart fields
1 parent 02f0f53 commit b4ae779

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Geocodio.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function uploadList(
130130
string $file,
131131
GeocodeDirection $direction,
132132
string $format,
133-
string $callbackWebhook = '',
133+
?string $callbackWebhook = null,
134134
): array {
135135
if (! file_exists($file)) {
136136
throw GeocodioException::fileNotFound($file);
@@ -156,7 +156,7 @@ public function uploadInlineList(
156156
string $filename,
157157
GeocodeDirection $direction,
158158
string $format,
159-
string $callbackWebhook = '',
159+
?string $callbackWebhook = null,
160160
): array {
161161
$response = $this->uploadMultipartFile(
162162
$data,
@@ -295,14 +295,14 @@ protected function uploadMultipartFile(
295295
string $fileContents,
296296
GeocodeDirection $direction,
297297
string $format,
298-
string $callbackWebhook,
298+
?string $callbackWebhook = null,
299299
?string $filename = null
300300
): Response {
301301
if (is_file($fileContents) && ! file_exists($fileContents)) {
302302
throw GeocodioException::fileNotFound($fileContents);
303303
}
304304

305-
$multipart = [
305+
$multipart = array_filter([
306306
[
307307
'name' => 'file',
308308
'contents' => is_file($fileContents) ? fopen($fileContents, 'r') : $fileContents,
@@ -320,7 +320,7 @@ protected function uploadMultipartFile(
320320
'name' => 'callback',
321321
'contents' => $callbackWebhook,
322322
],
323-
];
323+
], fn ($block) => $block['contents']);
324324

325325
return $this->sendRequest('POST', 'lists', [RequestOptions::MULTIPART => $multipart]);
326326
}

tests/ListTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
expect($body)->toContain('name="file"');
5151
expect($body)->toContain('name="direction"');
5252
expect($body)->toContain('name="format"');
53-
expect($body)->toContain('name="callback"');
5453

5554
// Assert specific values
5655
expect($body)->toContain('filename="simple.csv"');
@@ -75,7 +74,8 @@
7574
$csvData,
7675
'coffee-shops.csv',
7776
GeocodeDirection::Forward,
78-
'{{B}} {{C}} {{D}} {{E}}'
77+
'{{B}} {{C}} {{D}} {{E}}',
78+
'https://example.com/callbacks/file-upload'
7979
);
8080

8181
$history = $http->history();

0 commit comments

Comments
 (0)