-
Notifications
You must be signed in to change notification settings - Fork 10
Add artifact endpoints for suborganization #92
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9847fa7
Add artifact package method for suborganization
eiriksm e9f5f49
Add new endpoints and tests
eiriksm 805988e
Use naming not looking deprecated
eiriksm a10da4e
Also document edit artifact package
eiriksm 05232a9
Rename all instances of deprecated param defaultSubrepositoryAccess t…
eiriksm 4a285e2
Update tests/Api/Suborganizations/PackagesTest.php
eiriksm eb0157d
Merge branch 'master' into feat/artifact-package-suborg
eiriksm e3d5d7a
Update README.md
eiriksm a5dd7ae
Merge branch 'feat/artifact-package-suborg' of github.com:packagist/p…
eiriksm dc8b417
Remove duplicated line
eiriksm 3998f48
Update src/Api/Suborganizations/Packages.php
eiriksm 989cd1a
Merge branch 'feat/artifact-package-suborg' of github.com:packagist/p…
eiriksm 2262f90
Remove defaultSuborganizationAccess for create
eiriksm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * (c) Packagist Conductors GmbH <contact@packagist.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace PrivatePackagist\ApiClient\Api\Suborganizations\Packages; | ||
|
|
||
| use PrivatePackagist\ApiClient\Api\AbstractApi; | ||
|
|
||
| class Artifacts extends AbstractApi | ||
| { | ||
| public function create($suborganizationName, $file, $contentType, $fileName) | ||
| { | ||
| return $this->postFile(sprintf('/suborganizations/%s/packages/artifacts/', $suborganizationName), $file, array_filter([ | ||
| 'Content-Type' => $contentType, | ||
| 'X-FILENAME' => $fileName | ||
| ])); | ||
| } | ||
|
|
||
| public function add($suborganizationName, $packageIdOrName, $file, $contentType, $fileName) | ||
| { | ||
| return $this->postFile(sprintf('/suborganizations/%s/packages/%s/artifacts/', $suborganizationName, $packageIdOrName), $file, array_filter([ | ||
| 'Content-Type' => $contentType, | ||
| 'X-FILENAME' => $fileName | ||
| ])); | ||
| } | ||
|
|
||
| public function show($suborganizationName, $artifactId) | ||
| { | ||
| return $this->get(sprintf('/suborganizations/%s/packages/artifacts/%s/', $suborganizationName, $artifactId)); | ||
| } | ||
|
|
||
| public function showPackageArtifacts($suborganizationName, $packageIdOrName) | ||
| { | ||
| return $this->getCollection(sprintf('/suborganizations/%s/packages/%s/artifacts/', $suborganizationName, $packageIdOrName)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * (c) Packagist Conductors GmbH <contact@packagist.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace PrivatePackagist\ApiClient\Api\Suborganizations\Packages; | ||
|
|
||
| use PHPUnit\Framework\MockObject\MockObject; | ||
| use PrivatePackagist\ApiClient\Api\ApiTestCase; | ||
|
|
||
| class ArtifactsTest extends ApiTestCase | ||
| { | ||
| public function testCreate() | ||
| { | ||
| $suborganizationName = 'suborganization'; | ||
| $expected = [ | ||
| 'id' => 1, | ||
| ]; | ||
| $rawFileContent = 'foobar'; | ||
| $headers = [ | ||
| 'Content-Type' => 'application/zip', | ||
| 'X-FILENAME' => 'file.zip' | ||
| ]; | ||
|
|
||
| /** @var Artifacts&MockObject $api */ | ||
| $api = $this->getApiMock(); | ||
| $api->expects($this->once()) | ||
| ->method('postFile') | ||
| ->with($this->equalTo('/suborganizations/suborganization/packages/artifacts/'), $rawFileContent, $headers) | ||
| ->willReturn($expected); | ||
|
|
||
|
|
||
| $this->assertSame($expected, $api->create($suborganizationName, $rawFileContent, $headers['Content-Type'], $headers['X-FILENAME'])); | ||
| } | ||
|
|
||
| public function testAdd() | ||
| { | ||
| $suborganizationName = 'suborganization'; | ||
| $packageName = 'acme/artifact'; | ||
| $expected = [ | ||
| 'id' => 1, | ||
| ]; | ||
| $rawFileContent = 'foobar'; | ||
| $headers = [ | ||
| 'Content-Type' => 'application/zip', | ||
| 'X-FILENAME' => 'file.zip' | ||
| ]; | ||
|
|
||
| /** @var Artifacts&MockObject $api */ | ||
| $api = $this->getApiMock(); | ||
| $api->expects($this->once()) | ||
| ->method('postFile') | ||
| ->with($this->equalTo('/suborganizations/'.$suborganizationName.'/packages/'.$packageName.'/artifacts/'), $rawFileContent, $headers) | ||
| ->willReturn($expected); | ||
|
|
||
|
|
||
| $this->assertSame($expected, $api->add($suborganizationName, $packageName, $rawFileContent, $headers['Content-Type'], $headers['X-FILENAME'])); | ||
| } | ||
|
|
||
| public function testShow() | ||
| { | ||
| $suborganizationName = 'suborganization'; | ||
| $expected = [ | ||
| 'repoType' => 'artifact', | ||
| 'artifactPackageFileIds' =>[1, 2], | ||
| ]; | ||
|
|
||
| /** @var Artifacts&MockObject $api */ | ||
| $api = $this->getApiMock(); | ||
| $api->expects($this->once()) | ||
| ->method('get') | ||
| ->with($this->equalTo('/suborganizations/suborganization/packages/artifacts/1/')) | ||
| ->willReturn($expected); | ||
|
|
||
| $this->assertSame($expected, $api->show($suborganizationName, '1')); | ||
| } | ||
|
|
||
| public function testShowPackageArtifacts() | ||
| { | ||
| $suborganizationName = 'suborganization'; | ||
| $expected = [ | ||
| 'name' => 'acme-website/package', | ||
| 'repoType' => 'artifact', | ||
| 'artifactFiles' => 'artifact', | ||
| ]; | ||
|
|
||
| /** @var Artifacts&MockObject $api */ | ||
| $api = $this->getApiMock(); | ||
| $api->expects($this->once()) | ||
| ->method('getCollection') | ||
| ->with($this->equalTo('/suborganizations/suborganization/packages/acme-website/package/artifacts/')) | ||
| ->willReturn($expected); | ||
|
|
||
| $this->assertSame($expected, $api->showPackageArtifacts($suborganizationName, 'acme-website/package')); | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| protected function getApiClass() | ||
| { | ||
| return Artifacts::class; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.