Merge pull request #16 from techdavid/multi-actions

Add multi function
This commit is contained in:
Alex Yatskov 2017-07-27 12:28:18 -07:00 committed by GitHub
commit d926260da4
2 changed files with 40 additions and 0 deletions

View File

@ -428,6 +428,13 @@ class AnkiBridge:
return [field['name'] for field in model['flds']]
def multi(self, actions):
response = []
for item in actions:
response.append(AnkiConnect.handler(ac, item))
return response
def deckNames(self):
collection = self.collection()
if collection is not None:
@ -620,6 +627,11 @@ class AnkiConnect:
return self.anki.modelFieldNames(modelName)
@webApi
def multi(self, actions):
return self.anki.multi(actions)
@webApi
def addNote(self, note):
params = AnkiNoteParams(note)

View File

@ -162,6 +162,34 @@ Below is a list of currently supported actions. Requests with invalid actions or
]
```
* **multi**
Performs multiple actions in one request, returning an array with the response of each action (in the given order).
*Sample request*:
```
{
"action": "multi",
"params": {
"actions": [
{"action": "deckNames"},
{
"action": "browse",
"params": {"query": "deck:current"}
}
]
}
}
```
*Sample response*:
```
[
["Default"],
[1494723142483, 1494703460437, 1494703479525]
]
```
* **addNote**
Creates a note using the given deck and model, with the provided field values and tags. Returns the identifier of