Merge pull request #9 from vchagaev/fix-api-params-handler
Fix API params handler
This commit is contained in:
commit
1db470dcc1
@ -445,9 +445,15 @@ class AnkiConnect:
|
|||||||
|
|
||||||
def handler(self, request):
|
def handler(self, request):
|
||||||
action = 'api_' + request.get('action', '')
|
action = 'api_' + request.get('action', '')
|
||||||
|
params = request.get('params')
|
||||||
|
api_func = getattr(self, action)
|
||||||
|
|
||||||
if hasattr(self, action):
|
if hasattr(self, action):
|
||||||
try:
|
try:
|
||||||
return getattr(self, action)(**(request.get('params') or {}))
|
if not params:
|
||||||
|
return api_func()
|
||||||
|
|
||||||
|
return api_func(params)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -460,9 +466,8 @@ class AnkiConnect:
|
|||||||
return self.anki.modelNames()
|
return self.anki.modelNames()
|
||||||
|
|
||||||
|
|
||||||
def api_modelFieldNames(self, modelName):
|
def api_modelFieldNames(self, params):
|
||||||
return self.anki.modelFieldNames(modelName)
|
return self.anki.modelFieldNames(params.get("modelName"))
|
||||||
|
|
||||||
|
|
||||||
def api_addNote(self, note):
|
def api_addNote(self, note):
|
||||||
params = AnkiNoteParams(note)
|
params = AnkiNoteParams(note)
|
||||||
|
Loading…
Reference in New Issue
Block a user