11
11
12
12
use PrivatePackagist \ApiClient \Api \Packages \Artifacts ;
13
13
use PrivatePackagist \ApiClient \Exception \InvalidArgumentException ;
14
+ use PrivatePackagist \ApiClient \Payload \ArtifactPackageConfig ;
15
+ use PrivatePackagist \ApiClient \Payload \CustomPackageConfig ;
16
+ use PrivatePackagist \ApiClient \Payload \VcsPackageConfig ;
14
17
15
18
class Packages extends AbstractApi
16
19
{
@@ -55,23 +58,25 @@ public function show($packageName)
55
58
return $ this ->get (sprintf ('/packages/%s/ ' , $ packageName ));
56
59
}
57
60
58
- public function createVcsPackage ($ url , $ credentialId = null , $ type = 'vcs ' )
61
+ public function createVcsPackage ($ url , $ credentialId = null , $ type = 'vcs ' , $ defaultSubrepositoryAccess = null )
59
62
{
60
- return $ this ->post ('/packages/ ' , ['repoType ' => $ type , 'repoUrl ' => $ url , 'credentials ' => $ credentialId ]);
63
+ $ data = new VcsPackageConfig ($ url , $ credentialId , $ type , $ defaultSubrepositoryAccess );
64
+
65
+ return $ this ->post ('/packages/ ' , $ data ->toParameters ());
61
66
}
62
67
63
- public function createCustomPackage ($ customJson , $ credentialId = null )
68
+ public function createCustomPackage ($ customJson , $ credentialId = null , $ defaultSubrepositoryAccess = null )
64
69
{
65
- if (is_array ($ customJson ) || is_object ($ customJson )) {
66
- $ customJson = json_encode ($ customJson );
67
- }
70
+ $ data = new CustomPackageConfig ($ customJson , $ credentialId , $ defaultSubrepositoryAccess );
68
71
69
- return $ this ->post ('/packages/ ' , [ ' repoType ' => ' package ' , ' repoConfig ' => $ customJson , ' credentials ' => $ credentialId ] );
72
+ return $ this ->post ('/packages/ ' , $ data -> toParameters () );
70
73
}
71
74
72
- public function createArtifactPackage (array $ artifactPackageFileIds )
75
+ public function createArtifactPackage (array $ artifactPackageFileIds, $ defaultSubrepositoryAccess = null )
73
76
{
74
- return $ this ->post ('/packages/ ' , ['repoType ' => 'artifact ' , 'artifactIds ' => $ artifactPackageFileIds ]);
77
+ $ data = new ArtifactPackageConfig ($ artifactPackageFileIds , $ defaultSubrepositoryAccess );
78
+
79
+ return $ this ->post ('/packages/ ' , $ data ->toParameters ());
75
80
}
76
81
77
82
/**
@@ -82,27 +87,33 @@ public function updateVcsPackage($packageName, $url, $credentialId = null)
82
87
return $ this ->editVcsPackage ($ packageName , $ url , $ credentialId );
83
88
}
84
89
85
- public function editVcsPackage ($ packageName , $ url , $ credentialId = null , $ type = 'vcs ' )
90
+ public function editVcsPackage ($ packageName , $ url , $ credentialId = null , $ type = 'vcs ' , $ defaultSubrepositoryAccess = null )
86
91
{
87
- return $ this ->put (sprintf ('/packages/%s/ ' , $ packageName ), ['repoType ' => $ type , 'repoUrl ' => $ url , 'credentials ' => $ credentialId ]);
92
+ $ data = new VcsPackageConfig ($ url , $ credentialId , $ type , $ defaultSubrepositoryAccess );
93
+
94
+ return $ this ->put (sprintf ('/packages/%s/ ' , $ packageName ), $ data ->toParameters ());
88
95
}
89
96
90
- public function editArtifactPackage ($ packageName , array $ artifactPackageFileIds )
97
+ public function editArtifactPackage ($ packageName , array $ artifactPackageFileIds, $ defaultSubrepositoryAccess = null )
91
98
{
92
- return $ this ->put (sprintf ('/packages/%s/ ' , $ packageName ), ['repoType ' => 'artifact ' , 'artifactIds ' => $ artifactPackageFileIds ]);
99
+ $ data = new ArtifactPackageConfig ($ artifactPackageFileIds , $ defaultSubrepositoryAccess );
100
+
101
+ return $ this ->put (sprintf ('/packages/%s/ ' , $ packageName ), $ data ->toParameters ());
93
102
}
94
103
95
104
/**
96
105
* @deprecated Use editCustomPackage instead
97
106
*/
98
107
public function updateCustomPackage ($ packageName , $ customJson , $ credentialId = null )
99
108
{
100
- return $ this ->editVcsPackage ($ packageName , $ customJson , $ credentialId );
109
+ return $ this ->editCustomPackage ($ packageName , $ customJson , $ credentialId );
101
110
}
102
111
103
- public function editCustomPackage ($ packageName , $ customJson , $ credentialId = null )
112
+ public function editCustomPackage ($ packageName , $ customJson , $ credentialId = null , $ defaultSubrepositoryAccess = null )
104
113
{
105
- return $ this ->put (sprintf ('/packages/%s/ ' , $ packageName ), ['repoType ' => 'package ' , 'repoConfig ' => $ customJson , 'credentials ' => $ credentialId ]);
114
+ $ data = new CustomPackageConfig ($ customJson , $ credentialId , $ defaultSubrepositoryAccess );
115
+
116
+ return $ this ->put (sprintf ('/packages/%s/ ' , $ packageName ), $ data ->toParameters ());
106
117
}
107
118
108
119
public function remove ($ packageName )
0 commit comments