htmlForm
This commit is contained in:
@@ -22,22 +22,21 @@ class MultiDownloaderClient
|
||||
}
|
||||
}
|
||||
|
||||
public function downloadAsString(array $files)
|
||||
private function buildRequest(array $files): array
|
||||
{
|
||||
$files = array_map(function (FileRequest $file) {
|
||||
return array_map(function (FileRequest $file) {
|
||||
return $file->toArray();
|
||||
}, $files);
|
||||
|
||||
return $this->sendRequest($files);
|
||||
}
|
||||
|
||||
public function downloadTo(string $path, array $files)
|
||||
public function downloadAsString(array $files): string
|
||||
{
|
||||
$files = array_map(function (FileRequest $file) {
|
||||
return $file->toArray();
|
||||
}, $files);
|
||||
return $this->sendRequest($this->buildRequest($files));
|
||||
}
|
||||
|
||||
$response = $this->sendRequest($files, [
|
||||
public function downloadTo(string $path, array $files): string
|
||||
{
|
||||
$response = $this->sendRequest($this->buildRequest($files), [
|
||||
CURLOPT_RETURNTRANSFER => false,
|
||||
CURLOPT_FILE => fopen($path, 'w'),
|
||||
]);
|
||||
@@ -45,7 +44,14 @@ class MultiDownloaderClient
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function sendRequest(array $files, array $options = [])
|
||||
public function htmlForm(array $files): string
|
||||
{
|
||||
ob_start();
|
||||
include __DIR__ . '/htmlForm.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
private function sendRequest(array $request, array $options = []): string
|
||||
{
|
||||
$ch = curl_init();
|
||||
|
||||
@@ -53,9 +59,10 @@ class MultiDownloaderClient
|
||||
CURLOPT_URL => $this->apiUrl . '/v2/zip',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => json_encode($files),
|
||||
CURLOPT_POSTFIELDS => json_encode($request),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $this->apiKey,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user