1010
1111logger = logging .getLogger (__name__ )
1212
13+ __all__ = ["Api" ]
14+
1315
1416class Api :
1517 """
@@ -19,12 +21,12 @@ class Api:
1921 """
2022
2123 def __init__ (
22- self ,
23- email = None ,
24- password = None ,
25- base_url = None ,
26- publication_url = None ,
27- debug = False ,
24+ self ,
25+ email = None ,
26+ password = None ,
27+ base_url = None ,
28+ publication_url = None ,
29+ debug = False ,
2830 ):
2931 """
3032
@@ -116,9 +118,7 @@ def get_drafts(self, filter=None, offset=None, limit=None):
116118 return Api ._handle_response (response = response )
117119
118120 def delete_draft (self , draft_id ):
119- response = self ._session .delete (
120- f"{ self .publication_url } /drafts/{ draft_id } "
121- )
121+ response = self ._session .delete (f"{ self .publication_url } /drafts/{ draft_id } " )
122122 return Api ._handle_response (response = response )
123123
124124 def post_draft (self , body ) -> dict :
@@ -134,12 +134,12 @@ def post_draft(self, body) -> dict:
134134 return Api ._handle_response (response = response )
135135
136136 def put_draft (
137- self ,
138- draft ,
139- title = None ,
140- subtitle = None ,
141- body = None ,
142- cover_image = None ,
137+ self ,
138+ draft ,
139+ title = None ,
140+ subtitle = None ,
141+ body = None ,
142+ cover_image = None ,
143143 ) -> dict :
144144 """
145145
@@ -181,7 +181,7 @@ def prepublish_draft(self, draft) -> dict:
181181 return Api ._handle_response (response = response )
182182
183183 def publish_draft (
184- self , draft , send : bool = True , share_automatically : bool = False
184+ self , draft , send : bool = True , share_automatically : bool = False
185185 ) -> dict :
186186 """
187187
@@ -211,7 +211,7 @@ def schedule_draft(self, draft, draft_datetime: datetime) -> dict:
211211 """
212212 response = self ._session .post (
213213 f"{ self .publication_url } /drafts/{ draft } /schedule" ,
214- json = {"post_date" : draft_datetime .isoformat ()}
214+ json = {"post_date" : draft_datetime .isoformat ()},
215215 )
216216 return Api ._handle_response (response = response )
217217
@@ -225,8 +225,7 @@ def unschedule_draft(self, draft) -> dict:
225225
226226 """
227227 response = self ._session .post (
228- f"{ self .publication_url } /drafts/{ draft } /schedule" ,
229- json = {"post_date" : None }
228+ f"{ self .publication_url } /drafts/{ draft } /schedule" , json = {"post_date" : None }
230229 )
231230 return Api ._handle_response (response = response )
232231
@@ -247,9 +246,7 @@ def get_image(self, image: str):
247246
248247 response = self ._session .post (
249248 f"{ self .publication_url } /image" ,
250- data = {
251- "image" : image
252- },
249+ data = {"image" : image },
253250 )
254251 return Api ._handle_response (response = response )
255252
@@ -265,12 +262,13 @@ def get_categories(self):
265262 return Api ._handle_response (response = response )
266263
267264 def get_category (self , category_id , category_type , page ):
268- response = self ._session .get (f"{ self .base_url } /category/public/{ category_id } /{ category_type } " ,
269- params = {"page" : page })
265+ response = self ._session .get (
266+ f"{ self .base_url } /category/public/{ category_id } /{ category_type } " ,
267+ params = {"page" : page },
268+ )
270269 return Api ._handle_response (response = response )
271270
272- def get_single_category (self , category_id , category_type , page = None ,
273- limit = None ):
271+ def get_single_category (self , category_id , category_type , page = None , limit = None ):
274272 """
275273
276274 Args:
@@ -290,13 +288,15 @@ def get_single_category(self, category_id, category_type, page=None,
290288 while True :
291289 page_output = self .get_category (category_id , category_type , page )
292290 publications .extend (page_output .get ("publications" , []))
293- if (limit is not None and limit <= len (publications )) or not page_output .get ("more" , False ):
291+ if (
292+ limit is not None and limit <= len (publications )
293+ ) or not page_output .get ("more" , False ):
294294 publications = publications [:limit ]
295295 break
296296 page += 1
297297 output = {
298298 "publications" : publications ,
299- "more" : page_output .get ("more" , False )
299+ "more" : page_output .get ("more" , False ),
300300 }
301301 return output
302302
0 commit comments