mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Implement subscriptions (issue #70)
This commit is contained in:
@@ -182,6 +182,15 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
None
|
||||
)
|
||||
|
||||
def add_to_subscriptions( self, subscription ):
|
||||
assert isinstance( subscription, Repository.Repository ), subscription
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"PUT",
|
||||
"/user/subscriptions/" + subscription._identity,
|
||||
None,
|
||||
None
|
||||
)
|
||||
|
||||
def add_to_watched( self, watched ):
|
||||
assert isinstance( watched, Repository.Repository ), watched
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
@@ -533,6 +542,20 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
data
|
||||
)
|
||||
|
||||
def get_subscriptions( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
"/user/subscriptions",
|
||||
None,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
Repository.Repository,
|
||||
self._requester,
|
||||
headers,
|
||||
data
|
||||
)
|
||||
|
||||
def get_watched( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
@@ -567,6 +590,16 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def has_in_subscriptions( self, subscription ):
|
||||
assert isinstance( subscription, Repository.Repository ), subscription
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
"GET",
|
||||
"/user/subscriptions/" + subscription._identity,
|
||||
None,
|
||||
None
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def has_in_watched( self, watched ):
|
||||
assert isinstance( watched, Repository.Repository ), watched
|
||||
status, headers, data = self._requester.requestRaw(
|
||||
@@ -605,6 +638,15 @@ class AuthenticatedUser( GithubObject.GithubObject ):
|
||||
None
|
||||
)
|
||||
|
||||
def remove_from_subscriptions( self, subscription ):
|
||||
assert isinstance( subscription, Repository.Repository ), subscription
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"DELETE",
|
||||
"/user/subscriptions/" + subscription._identity,
|
||||
None,
|
||||
None
|
||||
)
|
||||
|
||||
def remove_from_watched( self, watched ):
|
||||
assert isinstance( watched, Repository.Repository ), watched
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
|
||||
@@ -328,6 +328,20 @@ class NamedUser( GithubObject.GithubObject ):
|
||||
data
|
||||
)
|
||||
|
||||
def get_subscriptions( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
self.url + "/subscriptions",
|
||||
None,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
Repository.Repository,
|
||||
self._requester,
|
||||
headers,
|
||||
data
|
||||
)
|
||||
|
||||
def get_watched( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
|
||||
@@ -978,6 +978,20 @@ class Repository( GithubObject.GithubObject ):
|
||||
data
|
||||
)
|
||||
|
||||
def get_subscribers( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
self.url + "/subscribers",
|
||||
None,
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
NamedUser.NamedUser,
|
||||
self._requester,
|
||||
headers,
|
||||
data
|
||||
)
|
||||
|
||||
def get_tags( self ):
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
"GET",
|
||||
|
||||
Reference in New Issue
Block a user