Skip to content

Commit e7e4165

Browse files
author
Sebastian Schöps
committed
Another bugfix...
1 parent 590b672 commit e7e4165

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/Models/CamundaModel.php

+18-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Wertmenschen\CamundaApi\Models;
44

55
use GuzzleHttp\Client;
6+
use Illuminate\Support\Arr;
67
use Illuminate\Support\Str;
78
use Illuminate\Support\Facades\Config;
89

@@ -27,28 +28,37 @@ public function __construct($id = null, $attributes = [])
2728

2829
protected function post($url, $data = [], $json = false)
2930
{
30-
$data = $json ? ['json' => $data] : array_merge(['json' => ['a' => 'b']], $data);
31-
return $this->request($url, 'post', $data);
31+
return $this->request($url, 'post', $this->getData($data, $json));
3232
}
3333

3434
protected function put($url, $data = [], $json = false)
3535
{
36-
$data = $json ? ['json' => $data] : array_merge(['json' => ['a' => 'b']], $data);
37-
return $this->request($url, 'put', $data);
36+
return $this->request($url, 'put', $this->getData($data, $json));
3837
}
3938

4039
protected function delete($url, $data = [], $json = false)
4140
{
42-
$data = $json ? ['json' => $data] : array_merge(['json' => ['a' => 'b']], $data);
43-
return $this->request($url, 'delete', $data);
41+
return $this->request($url, 'delete', $this->getData($data, $json));
42+
}
43+
44+
protected function getData($data, $json)
45+
{
46+
if(Arr::has($data, 'multipart')) {
47+
return $data;
48+
}
49+
elseif($json) {
50+
return ['json' => $data];
51+
}
52+
else {
53+
return array_merge(['json' => ['a' => 'b']], $data);
54+
}
4455
}
4556

4657
protected function get($url)
4758
{
4859
return $this->request($url, 'get');
4960
}
5061

51-
5262
private function request($url, $method, $data = [])
5363
{
5464
$data['auth'] = [Config::get('camunda.api.auth.user'), Config::get('camunda.api.auth.password')];
@@ -77,4 +87,4 @@ protected function tenant()
7787
{
7888
return strlen(Config::get('camunda.api.tenant-id')) ? '/tenant-id/' . Config::get('camunda.api.tenant-id') : '';
7989
}
80-
}
90+
}

0 commit comments

Comments
 (0)