Skip to content

Commit d35bdea

Browse files
authored
Merge pull request #696 from acrobat/fix-repository-list-api
Added check to avoid github 422 error
2 parents 6916263 + 92f4207 commit d35bdea

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lib/Github/Api/CurrentUser.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,25 @@ public function teams()
119119
*
120120
* @return array
121121
*/
122-
public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc', $visibility = 'all', $affiliation = 'owner,collaborator,organization_member')
122+
public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc', $visibility = null, $affiliation = null)
123123
{
124-
return $this->get('/user/repos', [
124+
$params = [
125125
'type' => $type,
126126
'sort' => $sort,
127127
'direction' => $direction,
128-
'visibility' => $visibility,
129-
'affiliation' => $affiliation,
130-
]);
128+
];
129+
130+
if (null !== $visibility) {
131+
unset($params['type']);
132+
$params['visibility'] = $visibility;
133+
}
134+
135+
if (null !== $affiliation) {
136+
unset($params['type']);
137+
$params['affiliation'] = $affiliation;
138+
}
139+
140+
return $this->get('/user/repos', $params);
131141
}
132142

133143
/**

0 commit comments

Comments
 (0)