Skip to content

Commit 687503e

Browse files
committed
Update endpoint for add an uploaded file to an existing artifact
1 parent 73f685d commit 687503e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,10 @@ $client->packages()->editArtifactPackage('acme-website/package', $artifactFileId
609609
#### Add an artifact file to an existing package
610610

611611
```php
612-
$packageId = 1;
612+
$packageName = 'acme/artifact';
613613
$fileName = 'package1.zip';
614614
$file = file_get_contents($fileName);
615-
$client->packages()->artifacts()->add($packageId, $file, 'application/zip', $fileName);
615+
$client->packages()->artifacts()->add($packageName, $file, 'application/zip', $fileName);
616616
```
617617
### Credential
618618

src/Api/Packages/Artifacts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public function create($file, $contentType, $fileName)
2121
]));
2222
}
2323

24-
public function add($packageId, $file, $contentType, $fileName)
24+
public function add($packageName, $file, $contentType, $fileName)
2525
{
26-
return $this->postFile('/packages/'.$packageId.'/artifacts/', $file, array_filter([
26+
return $this->postFile('/packages/'.$packageName.'/artifacts/', $file, array_filter([
2727
'Content-Type' => $contentType,
2828
'X-FILENAME' => $fileName
2929
]));

tests/Api/Packages/ArtifactsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testCreate()
3737

3838
public function testAdd()
3939
{
40-
$packageId = 10;
40+
$packageName = 'acme/artifact';
4141
$expected = [
4242
'id' => 1,
4343
];
@@ -51,11 +51,11 @@ public function testAdd()
5151
$api = $this->getApiMock();
5252
$api->expects($this->once())
5353
->method('postFile')
54-
->with($this->equalTo('/packages/'.$packageId.'/artifacts/'), $rawFileContent, $headers)
54+
->with($this->equalTo('/packages/'.$packageName.'/artifacts/'), $rawFileContent, $headers)
5555
->willReturn($expected);
5656

5757

58-
$this->assertSame($expected, $api->add($packageId,$rawFileContent, $headers['Content-Type'], $headers['X-FILENAME']));
58+
$this->assertSame($expected, $api->add($packageName,$rawFileContent, $headers['Content-Type'], $headers['X-FILENAME']));
5959
}
6060

6161
public function testShow()

0 commit comments

Comments
 (0)