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();
61
61
```
62
62
Returns an array of customer packages.
63
63
64
- ##### Grant a customer access to a package
64
+ ##### Grant a customer access to a package or update the limitations
65
65
``` php
66
66
$customerId = 42;
67
67
$packages = [
@@ -71,7 +71,7 @@ $packages = [
71
71
'expirationDate' => (new \DateTime())->add(new \DateInterval('P1Y'))->format('c'), // optional expiration date to limit updades the customer receives
72
72
],
73
73
];
74
- $packages = $client->customers()->addPackages ($customerId, $packages);
74
+ $packages = $client->customers()->addOrUpdatePackages ($customerId, $packages);
75
75
```
76
76
Returns an array of added customer packages.
77
77
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public function listPackages($customerId)
26
26
return $ this ->get (sprintf ('/customers/%s/packages/ ' , $ customerId ));
27
27
}
28
28
29
- public function addPackages ($ customerId , array $ packages )
29
+ public function addOrUpdatePackages ($ customerId , array $ packages )
30
30
{
31
31
foreach ($ packages as $ package ) {
32
32
if (!isset ($ package ['name ' ])) {
@@ -37,6 +37,14 @@ public function addPackages($customerId, array $packages)
37
37
return $ this ->post (sprintf ('/customers/%s/packages/ ' , $ customerId ), $ packages );
38
38
}
39
39
40
+ /**
41
+ * @deprecated Use addOrUpdatePackages instead
42
+ */
43
+ public function addPackages ($ customerId , array $ packages )
44
+ {
45
+ return $ this ->addOrUpdatePackages ($ customerId , $ packages );
46
+ }
47
+
40
48
public function removePackage ($ customerId , $ packageName )
41
49
{
42
50
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()
79
79
$ this ->assertSame ($ expected , $ api ->listPackages (1 ));
80
80
}
81
81
82
- public function testAddPackages ()
82
+ public function testAddOrUpdatePackages ()
83
83
{
84
84
$ expected = [
85
85
[
@@ -99,19 +99,19 @@ public function testAddPackages()
99
99
->with ($ this ->equalTo ('/customers/1/packages/ ' ), $ this ->equalTo ($ packages ))
100
100
->will ($ this ->returnValue ($ expected ));
101
101
102
- $ this ->assertSame ($ expected , $ api ->addPackages (1 , $ packages ));
102
+ $ this ->assertSame ($ expected , $ api ->addOrUpdatePackages (1 , $ packages ));
103
103
}
104
104
105
105
/**
106
106
* @expectedException \PrivatePackagist\ApiClient\Exception\InvalidArgumentException
107
107
* @expectedExceptionMessage Parameter "name" is requried.
108
108
*/
109
- public function testAddPackagesMissingName ()
109
+ public function testAddOrUpdatePackagesMissingName ()
110
110
{
111
111
/** @var Customers&\PHPUnit_Framework_MockObject_MockObject $api */
112
112
$ api = $ this ->getApiMock ();
113
113
114
- $ api ->addPackages (1 , [[]]);
114
+ $ api ->addOrUpdatePackages (1 , [[]]);
115
115
}
116
116
117
117
public function testRemovePackage ()
You can’t perform that action at this time.
0 commit comments