public function create($method, $uri, array $headers = [], $body = null)
{
if (!is_array($body)) {
return $this->getRequestFactory()->createRequest($method, $uri, $headers, $body);
}
$builder = $this->getMultipartStreamBuilder();
foreach ($body as $item) {
$name = $item['name'];
$content = $item['content'];
unset($item['name']);
unset($item['content']);
$builder->addResource($name, $content, $item);
}
$multipartStream = $builder->build();
$boundary = $builder->getBoundary();
$headers['Content-Type'] = 'multipart/form-data; boundary=' . $boundary;
return $this->getRequestFactory()->createRequest($method, $uri, $headers, $multipartStream);
}