@@ -100,6 +100,22 @@ def to_json(self):
100
100
"""Return the json representing this object."""
101
101
return self ._json_data
102
102
103
+ @staticmethod
104
+ def requires_auth (func ):
105
+ """Decorator to note which class methods require authorization."""
106
+ def auth_wrapper (self , * args , ** kwargs ):
107
+ auth = False
108
+ if hasattr (self , '_session' ):
109
+ auth = self ._session .auth or \
110
+ self ._session .headers ['Authorization' ]
111
+
112
+ if auth :
113
+ return func (self , * args , ** kwargs )
114
+ else :
115
+ raise Error (type ('Faux Request' , (object , ),
116
+ {'status_code' : 401 , 'message' : 'Requires authentication' }
117
+ ))
118
+
103
119
104
120
class BaseComment (GitHubCore ):
105
121
"""The :class:`BaseComment <BaseComment>` object. A basic class for Gist,
@@ -150,13 +166,15 @@ def created_a
8D47
t(self):
150
166
"""datetime object representing when the comment was created."""
151
167
return self ._created
152
168
169
+ @GitHubCore .requires_auth
153
170
def delete (self ):
154
171
"""Delete this comment.
155
172
156
173
:returns: bool
157
174
"""
158
- return self ._delete (self ._api )
175
+ return self ._boolean ( self . _delete (self ._api ), 204 , 404 )
159
176
177
+ @GitHubCore .requires_auth
160
178
def edit (self , body ):
161
179
"""Edit this comment.
162
180
0 commit comments