55from enum import Enum
66
77# readme url
8- URL = "https://dash .readme.com/api/v1 "
8+ URL = "https://api .readme.com/v2/branches/stable "
99# category id for API reference
1010CATEGORY_ID = "685ce4df1df887006ff221c5"
11- CATEGORY_SLUG = "json-rpc-apis "
11+ CATEGORY_SLUG = "JSON-RPC%20API%20Reference "
1212
1313
1414class Action (Enum ):
@@ -18,9 +18,9 @@ class Action(Enum):
1818
1919
2020def getListOfRPCDocs (headers ):
21- response = requests .get (f"{ URL } /categories/{ CATEGORY_SLUG } /docs " , headers = headers )
21+ response = requests .get (f"{ URL } /categories/reference/ { CATEGORY_SLUG } /pages " , headers = headers )
2222 if response .status_code == 200 :
23- return response .json ()
23+ return response .json (). get ( 'data' , [])
2424 else :
2525 return []
2626
@@ -30,28 +30,31 @@ def publishDoc(action, title, body, order, headers):
3030 "title" : title ,
3131 "type" : "basic" ,
3232 "body" : body ,
33- "category" : CATEGORY_ID ,
33+ "category" : {
34+ "id" : CATEGORY_ID
35+ },
3436 "hidden" : False ,
3537 "order" : order ,
3638 }
3739 # title == slug
3840 if action == Action .ADD :
3941 # create doc
40- response = requests .post (URL + "/docs" , json = payload , headers = headers )
42+ payload .slug = title
43+ response = requests .post (URL + "/reference" , json = payload , headers = headers )
4144 if response .status_code != 201 :
4245 print (response .text )
4346 else :
4447 print ("Created " , title )
4548 elif action == Action .UPDATE :
4649 # update doc
47- response = requests .put (f"{ URL } /docs /{ title } " , json = payload , headers = headers )
50+ response = requests .patch (f"{ URL } /reference /{ title } " , json = payload , headers = headers )
4851 if response .status_code != 200 :
4952 print (response .text )
5053 else :
5154 print ("Updated " , title )
5255 elif action == Action .DELETE :
5356 # delete doc
54- response = requests .delete (f"{ URL } /docs /{ title } " , headers = headers )
57+ response = requests .delete (f"{ URL } /reference /{ title } " , headers = headers )
5558 if response .status_code != 204 :
5659 print (response .text )
5760 else :
@@ -79,7 +82,7 @@ def main():
7982 headers = {
8083 "accept" : "application/json" ,
8184 "content-type" : "application/json" ,
82- "authorization " : "Basic " + os .environ .get ("README_API_KEY" ),
85+ "Authorization " : "Bearer " + os .environ .get ("README_API_KEY" ),
8386 }
8487
8588 # path to the rst file from where we fetch all the RPC commands
0 commit comments