File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ $packages = $client->customers()->listPackages();
6161```
6262Returns an array of customer packages.
6363
64- ##### Grant a customer access to a package
64+ ##### Grant a customer access to a package or update the limitations
6565``` php
6666$customerId = 42;
6767$packages = [
@@ -71,7 +71,7 @@ $packages = [
7171 'expirationDate' => (new \DateTime())->add(new \DateInterval('P1Y'))->format('c'), // optional expiration date to limit updades the customer receives
7272 ],
7373];
74- $packages = $client->customers()->addPackages ($customerId, $packages);
74+ $packages = $client->customers()->addOrUpdatePackages ($customerId, $packages);
7575```
7676Returns an array of added customer packages.
7777
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public function listPackages($customerId)
2626 return $ this ->get (sprintf ('/customers/%s/packages/ ' , $ customerId ));
2727 }
2828
29- public function addPackages ($ customerId , array $ packages )
29+ public function addOrUpdatePackages ($ customerId , array $ packages )
3030 {
3131 foreach ($ packages as $ package ) {
3232 if (!isset ($ package ['name ' ])) {
@@ -37,6 +37,14 @@ public function addPackages($customerId, array $packages)
3737 return $ this ->post (sprintf ('/customers/%s/packages/ ' , $ customerId ), $ packages );
3838 }
3939
40+ /**
41+ * @deprecated Use addOrUpdatePackages instead
42+ */
43+ public function addPackages ($ customerId , array $ packages )
44+ {
45+ return $ this ->addOrUpdatePackages ($ customerId , $ packages );
46+ }
47+
4048 public function removePackage ($ customerId , $ packageName )
4149 {
4250 return $ this ->delete (sprintf ('/customers/%s/packages/%s/ ' , $ customerId , $ packageName ));
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public function testListPackages()
7979 $ this ->assertSame ($ expected , $ api ->listPackages (1 ));
8080 }
8181
82- public function testAddPackages ()
82+ public function testAddOrUpdatePackages ()
8383 {
8484 $ expected = [
8585 [
@@ -99,19 +99,19 @@ public function testAddPackages()
9999 ->with ($ this ->equalTo ('/customers/1/packages/ ' ), $ this ->equalTo ($ packages ))
100100 ->will ($ this ->returnValue ($ expected ));
101101
102- $ this ->assertSame ($ expected , $ api ->addPackages (1 , $ packages ));
102+ $ this ->assertSame ($ expected , $ api ->addOrUpdatePackages (1 , $ packages ));
103103 }
104104
105105 /**
106106 * @expectedException \PrivatePackagist\ApiClient\Exception\InvalidArgumentException
107107 * @expectedExceptionMessage Parameter "name" is requried.
108108 */
109- public function testAddPackagesMissingName ()
109+ public function testAddOrUpdatePackagesMissingName ()
110110 {
111111 /** @var Customers&\PHPUnit_Framework_MockObject_MockObject $api */
112112 $ api = $ this ->getApiMock ();
113113
114- $ api ->addPackages (1 , [[]]);
114+ $ api ->addOrUpdatePackages (1 , [[]]);
115115 }
116116
117117 public function testRemovePackage ()
You can’t perform that action at this time.
0 commit comments