File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -174,3 +174,19 @@ $emails = $client->api('current_user')->emails()->remove(array('first@provider.o
174174```
175175
176176Return an array of the authenticated user emails.
177+
178+ ### Suspend a user (Enterprise only)
179+
180+ > Requires [ authentication] ( security.md ) .
181+
182+ ``` php
183+ $client->api('user')->suspend('ornicar');
184+ ```
185+
186+ ### Unsuspend a user (Enterprise only)
187+
188+ > Requires [ authentication] ( security.md ) .
189+
190+ ``` php
191+ $client->api('user')->unsuspend('ornicar');
192+ ```
Original file line number Diff line number Diff line change @@ -182,4 +182,32 @@ public function publicEvents($username)
182182 {
183183 return $ this ->get ('users/ ' .rawurlencode ($ username ) . '/events/public ' );
184184 }
185+
186+ /**
187+ * Suspend a user
188+ *
189+ * @link https://developer.github.com/v3/users/administration/#suspend-a-user
190+ *
191+ * @param string $username
192+ *
193+ * @return array
194+ */
195+ public function suspend ($ username )
196+ {
197+ return $ this ->put ('users/ ' .rawurldecode ($ username ).'/suspended ' , array ('Content-Length ' => 0 ));
198+ }
199+
200+ /**
201+ * Unsuspend a user
202+ *
203+ * @link https://developer.github.com/v3/users/administration/#unsuspend-a-user
204+ *
205+ * @param string $username
206+ *
207+ * @return array
208+ */
209+ public function unsuspend ($ username )
210+ {
211+ return $ this ->delete ('users/ ' .rawurldecode ($ username ).'/suspended ' );
212+ }
185213}
Original file line number Diff line number Diff line change @@ -161,6 +161,38 @@ public function shouldGetUserGists()
161161 $ this ->assertEquals ($ expectedArray , $ api ->gists ('l3l0 ' ));
162162 }
163163
164+ /**
165+ * @test
166+ */
167+ public function shouldSuspendUser ()
168+ {
169+ $ expectedArray = array ();
170+
171+ $ api = $ this ->getApiMock ();
172+ $ api ->expects ($ this ->once ())
173+ ->method ('put ' )
174+ ->with ('users/l3l0/suspended ' )
175+ ->will ($ this ->returnValue ($ expectedArray ));
176+ $ this ->assertEquals ($ expectedArray , $ api ->suspend ('l3l0 ' ));
177+ }
178+
179+ /**
180+ * @test
181+ */
182+ public function shouldUnsuspendUser ()
183+ {
184+ $ expectedArray = array ();
185+
186+ $ api = $ this ->getApiMock ();
187+ $ api ->expects ($ this ->once ())
188+ ->method ('delete ' )
189+ ->with ('users/l3l0/suspended ' )
190+ ->will ($ this ->returnValue ($ expectedArray ));
191+
192+ $ this ->assertEquals ($ expectedArray , $ api ->unsuspend ('l3l0 ' ));
193+ }
194+
195+
164196 protected function getApiClass ()
165197 {
166198 return 'Github\Api\User ' ;
You can’t perform that action at this time.
0 commit comments