mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Final touch on CompleteService
This commit is contained in:
parent
d24d2e4b93
commit
4019ff08d6
@ -4,7 +4,6 @@ namespace App\Services\Migration;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Unirest\Request;
|
use Unirest\Request;
|
||||||
use Unirest\Request\Body;
|
|
||||||
|
|
||||||
class CompleteService
|
class CompleteService
|
||||||
{
|
{
|
||||||
@ -12,7 +11,7 @@ class CompleteService
|
|||||||
|
|
||||||
protected $endpoint = 'https://app.invoiceninja.com';
|
protected $endpoint = 'https://app.invoiceninja.com';
|
||||||
|
|
||||||
protected $uri = '/api/v1/migration/start/';
|
protected $uri = 'api/v1/migration/start';
|
||||||
|
|
||||||
protected $errors = [];
|
protected $errors = [];
|
||||||
|
|
||||||
@ -41,24 +40,23 @@ class CompleteService
|
|||||||
|
|
||||||
public function start()
|
public function start()
|
||||||
{
|
{
|
||||||
$body = [
|
$files = [];
|
||||||
'companies' => [],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($this->data as $companyKey => $companyData) {
|
foreach ($this->data as $companyKey => $companyData) {
|
||||||
$body['companies'][] = [
|
$data[] = [
|
||||||
'company_key' => $companyKey,
|
'company_key' => $companyKey,
|
||||||
'migration' => \Unirest\Request\Body::file($companyData['file'], 'application/zip'),
|
|
||||||
'force' => $companyData['force'],
|
'force' => $companyData['force'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$files[$companyKey] = $companyData['file'];
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$body = \Unirest\Request\Body::multipart(['companies' => json_encode($data)], $files);
|
||||||
$response = Request::post($this->getUrl(), $this->getHeaders(), json_encode($body));
|
|
||||||
|
|
||||||
dd($response);
|
try {
|
||||||
|
$response = Request::post($this->getUrl(), $this->getHeaders(), $body);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
dd($e->getMessage());
|
info($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->code == 200) {
|
if ($response->code == 200) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user