Add support for files.getUploadURLExternal and files.completeUploadExternal#176
Add support for files.getUploadURLExternal and files.completeUploadExternal#176maybe-Baylie wants to merge 30 commits intojolicode:mainfrom
Conversation
… of int for execute
…n type of int for execute
… return type of int for execute()
…ompleteUploadExternal and files.getUploadURLExternal
…f from PHP-CS-Fixer
…tive function sprintf from PHP-CS-Fixer
…ernal and filesCompleteUploadExternal
|
I can add the string literal to class string conversions from Jane as well if desired, will add 448 file changes in generated/normalizer/. |
| ] | ||
| } | ||
| }, | ||
| "/files.completeUploadExternal": { |
There was a problem hiding this comment.
The proper way to add stuffs in this file is described here: https://github.com/jolicode/slack-php-api/blob/main/docs/4-updating-sdk.md#generating-a-new-patch
You need to run a command to update the .patch.
There was a problem hiding this comment.
I rebased the branch and followed the instructions in the section and confirmed the patch was correctly applied. Should I write unit tests in the WritingTest.php file?
*edit: I think I answered my own question for the test
This is a temporary fix. Refs: jolicode#163
|
Also, can you rebase your PR? |
… of int for execute
…n type of int for execute
… return type of int for execute()
…ompleteUploadExternal and files.getUploadURLExternal
…ernal and filesCompleteUploadExternal
|
@damienalexandre Is there a preferred way for sending a post request with the client that isn't to a normal endpoint? To complete the test for FilesCompleteUploadExternal, I need to post the file to the link returned from filesGetUploadURLExternal. I would like to use the client since the auth is already attached to it but I'm not super familiar with how I would go about that. Mocking an endpoint maybe? |
|
Actually, if we must POST to a custom URL, we should create a new customizable Endpoint in the lib, inspired by the existing upload one (https://github.com/jolicode/slack-php-api/blob/main/generated/Endpoint/FilesUpload.php). class NewFileUpload extends \JoliCode\Slack\Api\Runtime\Client\BaseEndpoint implements \JoliCode\Slack\Api\Runtime\Client\Endpoint
{
use \JoliCode\Slack\Api\Runtime\Client\EndpointTrait;
private $uri;
public function __construct(string $uri, array $queryParameters = [], array $headerParameters = [])
{
$this->queryParameters = $queryParameters;
$this->headerParameters = $headerParameters;
}
public function getMethod(): string
{
return 'POST';
}
public function getUri(): string
{
return $this->uri;
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
return $this->getMultipartBody($streamFactory);
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
public function getAuthenticationScopes(): array
{
return ['slackAuth'];
}
protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
{
$optionsResolver = parent::getQueryOptionsResolver();
// todo
return $optionsResolver;
}
protected function getHeadersOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
{
$optionsResolver = parent::getHeadersOptionsResolver();
// todo
return $optionsResolver;
}
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
// todo
}
}Then it can be used like this in the Client: public function newfileUpload(string $uploadUri, array $formParameters = [], string $fetch = self::FETCH_OBJECT)
{
return $this->executeEndpoint(new Endpoint\NewFileUpload($uploadUri, $formParameters), $fetch);
}Would that be an option? Do you think it's the way to go? I didn't study the new upload behavior yet but if you can to POST to a custom URI, that's the way to go I think. |
|
That seems like a fine approach to me. Based on slacks own implementation in the WebAPI, they ended up defining the filesUploadV2 method as a convenience wrapper around the two new endpoints with an internal post call in between. I'll get started on it and see what I can do |
…nse200.php, change files arg to string for FilesCompleteUploadExternal.php, remove bad test
|
Ok thanks for sharing your progress! |
|
We did get this feature merged via another PR: #182 Thanks a lot for you time and efforts, the new PR proved to solve all the issues we were having here. Cheers |

This pull request introduces support for two new endpoints:
Additionally, A few errors were corrected in the command classes to allow the tools to run