Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* [Enable a customer](#enable-a-customer)
* [Disable a customer](#disable-a-customer)
* [List a customer's packages](#list-a-customers-packages)
* [Show a customer's package](#show-a-customers-package)
* [Grant a customer access to a package or edit the limitations](#grant-a-customer-access-to-a-package-or-edit-the-limitations)
* [Revoke access to a package from a customer](#revoke-access-to-a-package-from-a-customer)
* [Regenerate a customer's Composer repository token](#regenerate-a-customers-composer-repository-token)
Expand Down Expand Up @@ -107,7 +108,7 @@
* [Validate incoming webhook payloads](#validate-incoming-webhook-payloads)
* [License](#license)

<!-- Added by: glaubinix, at: Thu 13 Jan 2022 13:34:48 GMT -->
<!-- Added by: zanbaldwin, at: Thu 18 Aug 12:50:05 CEST 2022 -->

<!--te-->

Expand Down Expand Up @@ -286,6 +287,14 @@ $packages = $client->customers()->listPackages($customerId);
```
Returns an array of customer packages.

#### Show a customer's package
```php
$customerId = 42;
$package = $client->customers()->showPackage($customerId, $packageName);
$accessibleVersions = $package['versions'];
```
Returns a customer's package, including the versions that the customer has been granted access to.

#### Grant a customer access to a package or edit the limitations
```php
$customerId = 42;
Expand Down Expand Up @@ -508,7 +517,7 @@ $mirroredRepository = $client->subrepositories()->mirroredRepositories()->add($s
```
Returns a list of added mirrored repositories.

#### Edit the mirroring behaviour of mirrored repository in a subrepository
#### Edit the mirroring behaviour of mirrored repository in a subrepository
```php
$subrepositoryName = 'subrepository';
$mirroredRepositoryId = 42;
Expand Down Expand Up @@ -845,7 +854,7 @@ When you create or update a webhook in Private Packagist an optional secret can
$request = /** any Psr7 request */;
$secret = 'webhook-secret';
$webhookSignature = new \PrivatePackagist\ApiClient\WebhookSignature($secret);
$requestSignature = $request->hasHeader('Packagist-Signature') ? $request->getHeader('Packagist-Signature')[0] : null;
$requestSignature = $request->hasHeader('Packagist-Signature') ? $request->getHeader('Packagist-Signature')[0] : null;
$webhookSignature->validate($requestSignature, (string) $request->getBody());
```

Expand Down
5 changes: 5 additions & 0 deletions src/Api/Customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public function listPackages($customerIdOrUrlName)
return $this->get(sprintf('/customers/%s/packages/', $customerIdOrUrlName));
}

public function showPackage($customerIdOrUrlName, $packageName)
{
return $this->get(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageName));
}

/**
* @deprecated Use addOrEditPackages instead
*/
Expand Down
28 changes: 28 additions & 0 deletions tests/Api/CustomersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,34 @@ public function testListPackages()
$this->assertSame($expected, $api->listPackages(1));
}

public function testShowPackage()
{
$expected = [
'name' => 'composer/composer',
'origin' => 'private',
'versionConstraint' => null,
'expirationDate' => null,
'versions' => [
[
'version' => '2.3.9',
'versionNormalized' => '2.3.9.0',
'sourceReference' => '015f524c9969255a29cdea8890cbd4fec240ee47',
'distReference' => '015f524c9969255a29cdea8890cbd4fec240ee47',
'releasedAt' => '2022-07-05T14:52:00+00:00',
],
],
];

/** @var Customers&MockObject $api */
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with($this->equalTo('/customers/1/packages/composer/composer/'))
->willReturn($expected);

$this->assertSame($expected, $api->showPackage(1, 'composer/composer'));
}

public function testAddOrEditPackages()
{
$expected = [
Expand Down