Skip to content

Commit bca533e

Browse files
authoredAug 21, 2024
Merge pull request #79 from packagist/mention-package-id-changes
Mention package id changes
2 parents f41925f + 234fc88 commit bca533e

File tree

5 files changed

+50
-30
lines changed

5 files changed

+50
-30
lines changed
 

‎README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,19 @@ $packages = $client->teams()->packages($teamId);
287287
Returns an array of packages.
288288

289289
#### Grant a team access to a list of private packages
290+
291+
You pass an array of packages to give access to. The values of the array can be either package ID or package name.
292+
290293
```php
291294
$teamId = 1;
292-
$packages = $client->teams()->addPackages($teamId, ['acme-website/package']);
295+
$packages = $client->teams()->addPackages($teamId, ['acme-website/package', 1]);
293296
```
294297
Returns an array of packages.
295298

296299
#### Remove access for a package from a team
300+
301+
You can use the package ID or package name as a reference.
302+
297303
```php
298304
$teamId = 1;
299305
$packages = $client->teams()->removePackage($teamId, 'acme-website/package');
@@ -429,6 +435,9 @@ $packages = $client->customers()->addOrEditPackages($customerId, $packages);
429435
Returns an array of all added or edited customer packages.
430436

431437
#### Revoke access to a package from a customer
438+
439+
You can reference the package by its ID or name.
440+
432441
```php
433442
$customerId = 42;
434443
$packageName = 'acme-website/package';
@@ -533,6 +542,9 @@ $packages = $client->vendorBundles()->packages()->addOrEditPackages($vendorBundl
533542
Returns an array of all added or edited customer packages.
534543

535544
#### Remove a package from a vendor bundle
545+
546+
You can reference the package by its ID or name.
547+
536548
```php
537549
$vendorBundleId = 42;
538550
$packageName = 'acme-website/package';
@@ -772,6 +784,8 @@ $client->subrepositories()->mirroredRepositories()->removePackages($subrepositor
772784

773785
### Package
774786

787+
You can reference a package by its name or ID.
788+
775789
#### List an organization's packages
776790
```php
777791
$filters = [
@@ -784,7 +798,10 @@ Returns an array of packages.
784798

785799
#### Show a package
786800
```php
801+
// Either use package name:
787802
$package = $client->packages()->show('acme-website/package');
803+
// Or the package ID:
804+
$package = $client->packages()->show(123);
788805
```
789806
Returns the package.
790807

@@ -847,6 +864,9 @@ $client->packages()->listDependents('acme-website/package');
847864
Returns a list of packages.
848865

849866
#### List all customers with access to a package
867+
868+
Pass either package ID or package name as argument.
869+
850870
```php
851871
$client->packages()->listCustomers('acme-website/package');
852872
```

‎src/Api/Customers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public function listPackages($customerIdOrUrlName)
7272
return $this->get(sprintf('/customers/%s/packages/', $customerIdOrUrlName));
7373
}
7474

75-
public function showPackage($customerIdOrUrlName, $packageName)
75+
public function showPackage($customerIdOrUrlName, $packageIdOrName)
7676
{
77-
return $this->get(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageName));
77+
return $this->get(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageIdOrName));
7878
}
7979

8080
/**
@@ -104,9 +104,9 @@ public function addPackages($customerIdOrUrlName, array $packages)
104104
return $this->addOrEditPackages($customerIdOrUrlName, $packages);
105105
}
106106

107-
public function removePackage($customerIdOrUrlName, $packageName)
107+
public function removePackage($customerIdOrUrlName, $packageIdOrName)
108108
{
109-
return $this->delete(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageName));
109+
return $this->delete(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageIdOrName));
110110
}
111111

112112
public function regenerateToken($customerIdOrUrlName, array $confirmation)

‎src/Api/Packages.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public function all(array $filters = [])
5353
return $this->get('/packages/', $filters);
5454
}
5555

56-
public function show($packageName)
56+
public function show($packageIdOrName)
5757
{
58-
return $this->get(sprintf('/packages/%s/', $packageName));
58+
return $this->get(sprintf('/packages/%s/', $packageIdOrName));
5959
}
6060

6161
public function createVcsPackage($url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
@@ -87,18 +87,18 @@ public function updateVcsPackage($packageName, $url, $credentialId = null)
8787
return $this->editVcsPackage($packageName, $url, $credentialId);
8888
}
8989

90-
public function editVcsPackage($packageName, $url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
90+
public function editVcsPackage($packageIdOrName, $url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
9191
{
9292
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSubrepositoryAccess);
9393

94-
return $this->put(sprintf('/packages/%s/', $packageName), $data->toParameters());
94+
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
9595
}
9696

97-
public function editArtifactPackage($packageName, array $artifactPackageFileIds, $defaultSubrepositoryAccess = null)
97+
public function editArtifactPackage($packageIdOrName, array $artifactPackageFileIds, $defaultSubrepositoryAccess = null)
9898
{
9999
$data = new ArtifactPackageConfig($artifactPackageFileIds, $defaultSubrepositoryAccess);
100100

101-
return $this->put(sprintf('/packages/%s/', $packageName), $data->toParameters());
101+
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
102102
}
103103

104104
/**
@@ -109,41 +109,41 @@ public function updateCustomPackage($packageName, $customJson, $credentialId = n
109109
return $this->editCustomPackage($packageName, $customJson, $credentialId);
110110
}
111111

112-
public function editCustomPackage($packageName, $customJson, $credentialId = null, $defaultSubrepositoryAccess = null)
112+
public function editCustomPackage($packageIdOrName, $customJson, $credentialId = null, $defaultSubrepositoryAccess = null)
113113
{
114114
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSubrepositoryAccess);
115115

116-
return $this->put(sprintf('/packages/%s/', $packageName), $data->toParameters());
116+
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
117117
}
118118

119-
public function remove($packageName)
119+
public function remove($packageIdOrName)
120120
{
121-
return $this->delete(sprintf('/packages/%s/', $packageName));
121+
return $this->delete(sprintf('/packages/%s/', $packageIdOrName));
122122
}
123123

124-
public function listCustomers($packageName)
124+
public function listCustomers($packageIdOrName)
125125
{
126-
return $this->get(sprintf('/packages/%s/customers/', $packageName));
126+
return $this->get(sprintf('/packages/%s/customers/', $packageIdOrName));
127127
}
128128

129129
public function listDependents($packageName)
130130
{
131131
return $this->get(sprintf('/packages/%s/dependents/', $packageName));
132132
}
133133

134-
public function listSecurityIssues($packageName, array $filters = [])
134+
public function listSecurityIssues($packageIdOrName, array $filters = [])
135135
{
136-
return $this->get(sprintf('/packages/%s/security-issues/', $packageName), $filters);
136+
return $this->get(sprintf('/packages/%s/security-issues/', $packageIdOrName), $filters);
137137
}
138138

139-
public function showSecurityMonitoringConfig($packageName)
139+
public function showSecurityMonitoringConfig($packageIdOrName)
140140
{
141-
return $this->get(sprintf('/packages/%s/security-monitoring/', $packageName));
141+
return $this->get(sprintf('/packages/%s/security-monitoring/', $packageIdOrName));
142142
}
143143

144-
public function editSecurityMonitoringConfig($packageName, array $config)
144+
public function editSecurityMonitoringConfig($packageIdOrName, array $config)
145145
{
146-
return $this->put(sprintf('/packages/%s/security-monitoring/', $packageName), $config);
146+
return $this->put(sprintf('/packages/%s/security-monitoring/', $packageIdOrName), $config);
147147
}
148148

149149
public function artifacts()

‎src/Api/Packages/Artifacts.php

Lines changed: 4 additions & 4 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($packageName, $file, $contentType, $fileName)
24+
public function add($packageIdOrName, $file, $contentType, $fileName)
2525
{
26-
return $this->postFile('/packages/'.$packageName.'/artifacts/', $file, array_filter([
26+
return $this->postFile('/packages/'.$packageIdOrName.'/artifacts/', $file, array_filter([
2727
'Content-Type' => $contentType,
2828
'X-FILENAME' => $fileName
2929
]));
@@ -34,8 +34,8 @@ public function show($artifactId)
3434
return $this->get(sprintf('/packages/artifacts/%s/', $artifactId));
3535
}
3636

37-
public function showPackageArtifacts($packageName)
37+
public function showPackageArtifacts($packageIdOrName)
3838
{
39-
return $this->get(sprintf('/packages/%s/artifacts/', $packageName));
39+
return $this->get(sprintf('/packages/%s/artifacts/', $packageIdOrName));
4040
}
4141
}

‎src/Api/VendorBundles/Packages.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public function addOrEditPackages($vendorBundleId, array $packages)
4141

4242
/**
4343
* @param int $vendorBundleId
44-
* @param string $packageName
44+
* @param string|int $packageIdOrName
4545
*/
46-
public function removePackage($vendorBundleId, $packageName)
46+
public function removePackage($vendorBundleId, $packageIdOrName)
4747
{
48-
return $this->delete(sprintf('/vendor-bundles/%s/packages/%s/', $vendorBundleId, $packageName));
48+
return $this->delete(sprintf('/vendor-bundles/%s/packages/%s/', $vendorBundleId, $packageIdOrName));
4949
}
5050
}

0 commit comments

Comments
 (0)