Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#81: HttpRequestService ability to work with multipart #112

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Adil9994
Copy link
Contributor

No description provided.

@Adil9994 Adil9994 changed the title #81: HttpRequestService ability to work with multipart #81 #81: HttpRequestService ability to work with multipart Apr 13, 2024
@Adil9994 Adil9994 requested a review from DenTray April 13, 2024 13:25
@Adil9994 Adil9994 self-assigned this Apr 13, 2024

protected function getMultipartOptionReplacement(array $data): array
{
Arr::forget($this->options, 'headers.content-type');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please increase Laravel min version requirements up to 5.7

@@ -127,8 +128,19 @@ public function send(string $method, string $url, array $data = [], array $heade
}
}

public function parseMultipart(string $content): StreamedPart
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function parseMultipart(string $content): StreamedPart
public function multipart(): Generator

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get content from the response instead

fwrite($stream, $content);
rewind($stream);

return app()->makeWith(StreamedPart::class, ['stream' => $stream]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return app()->makeWith(StreamedPart::class, ['stream' => $stream]);
return app()
->makeWith(StreamedPart::class, ['stream' => $stream])
->getParts();

} else {
$this->options['body'] = json_encode($data);
}
}

protected function getMultipartOptionReplacement(array $data): array
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected function getMultipartOptionReplacement(array $data): array
protected function convertToMultipart(array $data): array


protected function getMultipartOptionReplacement(array $data): array
{
Arr::forget($this->options, 'headers.content-type');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move this logic out of this function

return $options;
}

protected function getArrayMultipartOptionReplacement(string $parentKey, array $items): array
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep only one method convertToMultipart with optional parentKey arg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants