Skip to content

Commit 19839b7

Browse files
committed
Packages: add endpoint to fetch all customers with access to the package
1 parent 44a729f commit 19839b7

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ Returns a new job.
170170
$client->packages()->remove('acme-website/package');
171171
```
172172

173+
##### List all customers with access to a package
174+
```php
175+
$client->packages()->listCustomers('acme-website/package');
176+
```
177+
Returns a list of customers with access to the package.
178+
173179
#### Credential
174180

175181
##### List an organization's credentials

Diff for: src/Api/Packages.php

+5
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,9 @@ public function remove($packageName)
6060
{
6161
return $this->delete(sprintf('/packages/%s/', $packageName));
6262
}
63+
64+
public function listCustomers($packageName)
65+
{
66+
return $this->get(sprintf('/packages/%s/customers/', $packageName));
67+
}
6368
}

Diff for: tests/Api/PackagesTest.php

+27
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,33 @@ public function testRemove()
162162
$this->assertSame($expected, $api->remove('acme-website/package'));
163163
}
164164

165+
public function testListPackages()
166+
{
167+
$expected = [
168+
[
169+
'package' => [
170+
'name' => 'composer/composer',
171+
'origin' => 'private',
172+
'versionConstraint' => null,
173+
'expirationDate' => null,
174+
],
175+
'customer' => [
176+
'id' => 1,
177+
'name' => 'Customer',
178+
],
179+
]
180+
];
181+
182+
/** @var Customers&\PHPUnit_Framework_MockObject_MockObject $api */
183+
$api = $this->getApiMock();
184+
$api->expects($this->once())
185+
->method('get')
186+
->with($this->equalTo('/packages/composer/composer/customers/'))
187+
->will($this->returnValue($expected));
188+
189+
$this->assertSame($expected, $api->listCustomers('composer/composer'));
190+
}
191+
165192
protected function getApiClass()
166193
{
167194
return Packages::class;

0 commit comments

Comments
 (0)