Skip to content

Add support for files.getUploadURLExternal and files.completeUploadExternal #176

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

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
144cfd0
CheckerCommand.php - set command name in configure(), add return type…
maybe-Baylie Feb 14, 2025
fc1e383
GeneratePatchCommand.php - set command name in configure(), add retur…
maybe-Baylie Feb 14, 2025
5be64b5
UpdateSpecificationCommand.php - set command name in configure(), add…
maybe-Baylie Feb 14, 2025
90edf33
slack-openapi-patched.json - Add "/files.getUploadURLExternal" patch
maybe-Baylie Feb 14, 2025
b6a380a
slack-openapi-patched.json - Add "/files.completeUploadExternal" patch
maybe-Baylie Feb 14, 2025
63b77a1
slack-openapi-patched.json - add leading slash to files.completeUploa…
maybe-Baylie Feb 14, 2025
b13370d
Add generated Endpoints, Models and Normalizers from Jane for files.C…
maybe-Baylie Feb 14, 2025
b431830
SlackErrorResponse.php - add leading slash for native function sprint…
maybe-Baylie Feb 14, 2025
7d731d2
Client.php - add leading slash for native function sprintf from PHP-C…
maybe-Baylie Feb 14, 2025
fd96215
Runtime/Normalizer/ValidationException.php - add leading slash for na…
maybe-Baylie Feb 14, 2025
c9af333
Generated/Client.php - add generated methods for filesGetUploadURLExt…
maybe-Baylie Feb 14, 2025
4a0f32a
chore(jane): Rebuild the SDK with the latest Jane update (#179)
damienalexandre Feb 27, 2025
9535f16
fix(pagination): Update client cursor pagination (#178)
Ercogx Feb 27, 2025
440b9e8
chore(doc): Specify how to test the full API
damienalexandre Feb 27, 2025
221e7c6
fix(ci): Remove parallelisation of CI jobs to make it more robust
damienalexandre Feb 27, 2025
fb6b661
fix(ci): Add more "sleep" between API calls and update changelog
damienalexandre Feb 27, 2025
92f8640
fix(ci): Increase the time we wait between requests
damienalexandre Feb 27, 2025
d1945b2
CheckerCommand.php - set command name in configure(), add return type…
maybe-Baylie Feb 14, 2025
2799b38
GeneratePatchCommand.php - set command name in configure(), add retur…
maybe-Baylie Feb 14, 2025
1855b26
UpdateSpecificationCommand.php - set command name in configure(), add…
maybe-Baylie Feb 14, 2025
b950e00
slack-openapi-patched.json - Add "/files.getUploadURLExternal" patch
maybe-Baylie Feb 14, 2025
7867822
slack-openapi-patched.json - Add "/files.completeUploadExternal" patch
maybe-Baylie Feb 14, 2025
503549a
slack-openapi-patched.json - add leading slash to files.completeUploa…
maybe-Baylie Feb 14, 2025
7995710
Add generated Endpoints, Models and Normalizers from Jane for files.C…
maybe-Baylie Feb 14, 2025
5b648b1
Generated/Client.php - add generated methods for filesGetUploadURLExt…
maybe-Baylie Feb 14, 2025
f4e8af5
Merge remote-tracking branch 'origin/v4.8.0' into v4.8.0
maybe-Baylie Feb 27, 2025
dff245b
Regenerate SKD and run proper patch creation command
maybe-Baylie Feb 27, 2025
d5f8513
test complete for testGetUploadURLExternal. testCompleteUploadExterna…
maybe-Baylie Feb 27, 2025
f0bb5a5
Update patch file to add members to FilesGetUploadURLExternalGetRespo…
maybe-Baylie Feb 28, 2025
708a056
Upload progress on posting file
maybe-Baylie Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1 # Avoid rate-limit issue on Slack API
matrix:
php-version: [ '8.0', '8.1', '8.2' ]
composer-flags: [ '' ]
Expand All @@ -69,4 +70,4 @@ jobs:
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_TEST_CHANNEL: ${{ secrets.SLACK_TEST_CHANNEL }}
CI: ${{ vars.CI }}
CI: true
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changes between versions

## Unreleased (2025)

* Upgrade JanePHP generated code
* Improve the Cursor paginated methods, add missing and remove obsoletes

## 4.7.1 (2024-06-28)

* Upgrade JanePHP generated code
Expand Down
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ Run the tests using the following script:
make test
```

You need a Slack Application OAuth token to run all the tests.

Scope are at least:

- channels:history
- channels:read
- channels:write
- chat:write
- files:read
- files:write
- im:history
- im:read
- reactions:read
- search:read
- stars:read
- usergroups:read
- users:read

Set the token in `phpunit.xml`:

```xml
<server name="SLACK_TOKEN" value="edit_me" />
```

## Standard code

Use [PHP CS fixer](https://cs.symfony.com/) to make your code compliant with
Expand Down
3 changes: 0 additions & 3 deletions docs/2-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ do {
} while (!empty($cursor));
```

>Note: the virtual methods are not yet documented with PHPDoc so your IDE will
not autocomplete them.

## Concrete examples

Here are some real-life examples of interacting with the SDK:
Expand Down
45 changes: 45 additions & 0 deletions generated/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,32 @@ public function filesCommentsDelete(array $formParameters = [], array $headerPar
return $this->executeEndpoint(new Endpoint\FilesCommentsDelete($formParameters, $headerParameters), $fetch);
}

/**
* Finishes an upload started with files.getUploadURLExternal.
*
* @param array $queryParameters {
*
* @var string $channel_id Channel ID where the file will be shared. If not specified the file will be private.
* @var string $channels comma-separated string of channel IDs where the file will be shared
* @var string $files JSON-encoded array of file ids and their corresponding (optional) titles
* @var string $initial_comment the message text introducing the file in specified channels
* @var string $thread_ts Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. Also make sure to provide only one channel when using 'thread_ts'
* }
*
* @param array $headerParameters {
*
* @var string $token Authentication token. Requires scope: `files:write:user`
* }
*
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
*
* @return Model\FilesCompleteUploadExternalPostResponse200|Model\FilesCompleteUploadExternalPostResponsedefault|\Psr\Http\Message\ResponseInterface|null
*/
public function filesCompleteUploadExternal(array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT)
{
return $this->executeEndpoint(new Endpoint\FilesCompleteUploadExternal($queryParameters, $headerParameters), $fetch);
}

/**
* Deletes a file.
*
Expand All @@ -2500,6 +2526,25 @@ public function filesDelete(array $formParameters = [], array $headerParameters
return $this->executeEndpoint(new Endpoint\FilesDelete($formParameters, $headerParameters), $fetch);
}

/**
* Gets a URL for an edge external file upload.
*
* @param array $queryParameters {
*
* @var string $filename Name of the file being uploaded
* @var int $length Size in bytes of the file being uploaded
* @var string $token Authentication token. Requires scope: `files:write`
* }
*
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
*
* @return Model\FilesGetUploadURLExternalGetResponse200|Model\FilesGetUploadURLExternalGetResponsedefault|\Psr\Http\Message\ResponseInterface|null
*/
public function filesGetUploadURLExternal(array $queryParameters = [], string $fetch = self::FETCH_OBJECT)
{
return $this->executeEndpoint(new Endpoint\FilesGetUploadURLExternal($queryParameters), $fetch);
}

/**
* Gets information about a file.
*
Expand Down
107 changes: 107 additions & 0 deletions generated/Endpoint/FilesCompleteUploadExternal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

declare(strict_types=1);

/*
* This file is part of JoliCode's Slack PHP API project.
*
* (c) JoliCode <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace JoliCode\Slack\Api\Endpoint;

class FilesCompleteUploadExternal extends \JoliCode\Slack\Api\Runtime\Client\BaseEndpoint implements \JoliCode\Slack\Api\Runtime\Client\Endpoint
{
use \JoliCode\Slack\Api\Runtime\Client\EndpointTrait;

/**
* Finishes an upload started with files.getUploadURLExternal.
*
* @param array $queryParameters {
*
* @var string $channel_id Channel ID where the file will be shared. If not specified the file will be private.
* @var string $channels comma-separated string of channel IDs where the file will be shared
* @var string $files JSON-encoded array of file ids and their corresponding (optional) titles
* @var string $initial_comment the message text introducing the file in specified channels
* @var string $thread_ts Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead. Also make sure to provide only one channel when using 'thread_ts'
* }
*
* @param array $headerParameters {
*
* @var string $token Authentication token. Requires scope: `files:write:user`
* }
*/
public function __construct(array $queryParameters = [], array $headerParameters = [])
{
$this->queryParameters = $queryParameters;
$this->headerParameters = $headerParameters;
}

public function getMethod(): string
{
return 'POST';
}

public function getUri(): string
{
return '/files.completeUploadExternal';
}

public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
return [[], null];
}

public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}

public function getAuthenticationScopes(): array
{
return ['slackAuth'];
}

protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
{
$optionsResolver = parent::getQueryOptionsResolver();
$optionsResolver->setDefined(['channel_id', 'channels', 'files', 'initial_comment', 'thread_ts']);
$optionsResolver->setRequired(['files']);
$optionsResolver->setDefaults([]);
$optionsResolver->addAllowedTypes('channel_id', ['string']);
$optionsResolver->addAllowedTypes('channels', ['string']);
$optionsResolver->addAllowedTypes('files', ['string']);
$optionsResolver->addAllowedTypes('initial_comment', ['string']);
$optionsResolver->addAllowedTypes('thread_ts', ['string']);

return $optionsResolver;
}

protected function getHeadersOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
{
$optionsResolver = parent::getHeadersOptionsResolver();
$optionsResolver->setDefined(['token']);
$optionsResolver->setRequired([]);
$optionsResolver->setDefaults([]);
$optionsResolver->addAllowedTypes('token', ['string']);

return $optionsResolver;
}

/**
* @return \JoliCode\Slack\Api\Model\FilesCompleteUploadExternalPostResponse200|\JoliCode\Slack\Api\Model\FilesCompleteUploadExternalPostResponsedefault|null
*/
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (200 === $status) {
return $serializer->deserialize($body, 'JoliCode\Slack\Api\Model\FilesCompleteUploadExternalPostResponse200', 'json');
}

return $serializer->deserialize($body, 'JoliCode\Slack\Api\Model\FilesCompleteUploadExternalPostResponsedefault', 'json');
}
}
86 changes: 86 additions & 0 deletions generated/Endpoint/FilesGetUploadURLExternal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

declare(strict_types=1);

/*
* This file is part of JoliCode's Slack PHP API project.
*
* (c) JoliCode <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace JoliCode\Slack\Api\Endpoint;

class FilesGetUploadURLExternal extends \JoliCode\Slack\Api\Runtime\Client\BaseEndpoint implements \JoliCode\Slack\Api\Runtime\Client\Endpoint
{
use \JoliCode\Slack\Api\Runtime\Client\EndpointTrait;

/**
* Gets a URL for an edge external file upload.
*
* @param array $queryParameters {
*
* @var string $filename Name of the file being uploaded
* @var int $length Size in bytes of the file being uploaded
* @var string $token Authentication token. Requires scope: `files:write`
* }
*/
public function __construct(array $queryParameters = [])
{
$this->queryParameters = $queryParameters;
}

public function getMethod(): string
{
return 'GET';
}

public function getUri(): string
{
return '/files.getUploadURLExternal';
}

public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
return [[], null];
}

public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}

public function getAuthenticationScopes(): array
{
return ['slackAuth'];
}

protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
{
$optionsResolver = parent::getQueryOptionsResolver();
$optionsResolver->setDefined(['filename', 'length', 'token']);
$optionsResolver->setRequired([]);
$optionsResolver->setDefaults([]);
$optionsResolver->addAllowedTypes('filename', ['string']);
$optionsResolver->addAllowedTypes('length', ['int']);
$optionsResolver->addAllowedTypes('token', ['string']);

return $optionsResolver;
}

/**
* @return \JoliCode\Slack\Api\Model\FilesGetUploadURLExternalGetResponse200|\JoliCode\Slack\Api\Model\FilesGetUploadURLExternalGetResponsedefault|null
*/
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if (200 === $status) {
return $serializer->deserialize($body, 'JoliCode\Slack\Api\Model\FilesGetUploadURLExternalGetResponse200', 'json');
}

return $serializer->deserialize($body, 'JoliCode\Slack\Api\Model\FilesGetUploadURLExternalGetResponsedefault', 'json');
}
}
44 changes: 44 additions & 0 deletions generated/Model/FilesCompleteUploadExternalPostResponse200.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/*
* This file is part of JoliCode's Slack PHP API project.
*
* (c) JoliCode <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace JoliCode\Slack\Api\Model;

class FilesCompleteUploadExternalPostResponse200 extends \ArrayObject
{
/**
* @var array
*/
protected $initialized = [];
/**
* @var bool|null
*/
protected $ok;

public function isInitialized($property): bool
{
return \array_key_exists($property, $this->initialized);
}

public function getOk(): ?bool
{
return $this->ok;
}

public function setOk(?bool $ok): self
{
$this->initialized['ok'] = true;
$this->ok = $ok;

return $this;
}
}
Loading