Skip to content

Commit af276bc

Browse files
committed
changed documentation and watch repo api endpoint
1 parent 59bdcf7 commit af276bc

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

doc/activity.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## Activity API (incomplete)
22
[Back to the navigation](index.md)
33

4-
Access to Starring and Watching a Repository for authenticated users.
4+
Access to Starring and Watching a Repository for [non] authenticated users.
55
Wrap [GitHub Activity API](https://developer.github.com/v3/activity/).
66

7-
> No authentication required.
7+
> *** No authentication required. ***
88
99
### Get repos that a specific user has starred
1010

@@ -14,7 +14,15 @@ $users = $client->api('user')->starred('ornicar');
1414

1515
Returns an array of starred repos.
1616

17-
> Requires [authentication](security.md).
17+
### Get repos that a specific user is watching
18+
19+
```php
20+
$users = $client->api('user')->watched('ornicar');
21+
```
22+
23+
Returns an array of watched repos.
24+
25+
> *** Requires [authentication](security.md). ***
1826
1927
### Get repos that a authenticated user has starred
2028

@@ -48,4 +56,39 @@ $owner = "KnpLabs";
4856
$repo = "php-github-api";
4957
$activity = $client->api('current_user')->starred()->unstar($owner, $repo);
5058
```
59+
Throws an Exception in case of failure or NULL in case of success.
60+
61+
62+
### Get repos that a authenticated user is watching
63+
64+
```php
65+
$activity = $client->api('current_user')->watchers()->all();
66+
```
67+
Returns an array of watched repos.
68+
69+
### Check if authenticated user is watching a specific repo
70+
71+
```php
72+
$owner = "KnpLabs";
73+
$repo = "php-github-api";
74+
$activity = $client->api('current_user')->watchers()->check($owner, $repo);
75+
```
76+
Throws an Exception with code 404 in case that the repo is not beeing watched by the authenticated user or NULL in case that it is beeing watched by the authenticated user.
77+
78+
### Watch a specific repo for authenticated user
79+
80+
```php
81+
$owner = "KnpLabs";
82+
$repo = "php-github-api";
83+
$activity = $client->api('current_user')->watchers()->watch($owner, $repo);
84+
```
85+
Throws an Exception in case of failure or NULL in case of success.
86+
87+
### Stop watching a specific repo for authenticated user
88+
89+
```php
90+
$owner = "KnpLabs";
91+
$repo = "php-github-api";
92+
$activity = $client->api('current_user')->watchers()->unwatch($owner, $repo);
93+
```
5194
Throws an Exception in case of failure or NULL in case of success.

lib/Github/Api/CurrentUser/Watchers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Watchers extends AbstractApi
1919
*/
2020
public function all($page = 1)
2121
{
22-
return $this->get('user/watched', array(
22+
return $this->get('user/subscriptions', array(
2323
'page' => $page
2424
));
2525
}
@@ -34,7 +34,7 @@ public function all($page = 1)
3434
*/
3535
public function check($username, $repository)
3636
{
37-
return $this->get('user/watched/'.rawurlencode($username).'/'.rawurlencode($repository));
37+
return $this->get('user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository));
3838
}
3939

4040
/**
@@ -47,7 +47,7 @@ public function check($username, $repository)
4747
*/
4848
public function watch($username, $repository)
4949
{
50-
return $this->put('user/watched/'.rawurlencode($username).'/'.rawurlencode($repository));
50+
return $this->put('user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository));
5151
}
5252

5353
/**
@@ -60,6 +60,6 @@ public function watch($username, $repository)
6060
*/
6161
public function unwatch($username, $repository)
6262
{
63-
return $this->delete('user/watched/'.rawurlencode($username).'/'.rawurlencode($repository));
63+
return $this->delete('user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository));
6464
}
6565
}

0 commit comments

Comments
 (0)