global test mode + fixes
This commit is contained in:
parent
9df8151682
commit
6ebae6201c
|
@ -4,6 +4,7 @@ namespace Bluesquare\Push;
|
|||
|
||||
use Bluesquare\Push\PushTemplate;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Arr;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
|
@ -73,15 +74,18 @@ class PushApi
|
|||
continue;
|
||||
}
|
||||
|
||||
foreach ($value as $subkey => $subvalue) {
|
||||
$values = Arr::dot($value);
|
||||
|
||||
foreach ($values as $subkey => $subvalue) {
|
||||
$subkey = str_replace('.', '][', $subkey);
|
||||
|
||||
$multipart_form[] = [
|
||||
'name' => "{$key}[$subkey]" . (is_array($subvalue) ? '[' . key($subvalue) . ']' : '' ),
|
||||
'contents' => (is_array($subvalue) ? reset($subvalue) : $subvalue)
|
||||
'name' => "{$key}[$subkey]",
|
||||
'contents' => is_array($subvalue) ? json_encode($subvalue) : $subvalue
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return $client->request('post', $url, [
|
||||
'multipart' => $multipart_form,
|
||||
'headers' => [
|
||||
|
@ -89,9 +93,5 @@ class PushApi
|
|||
'Accept' => 'application/json'
|
||||
]
|
||||
])->getBody();
|
||||
|
||||
} catch(\Exception $e) {
|
||||
throw new PushException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,10 @@ class PushTemplate implements \JsonSerializable
|
|||
public function __construct(string $template_id)
|
||||
{
|
||||
$this->template_id = $template_id;
|
||||
|
||||
if (env('PUSH_TEST_MODE', false)) {
|
||||
$this->testMode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue