Merge pull request #71 from c-okelly/master

Add createDeck action
This commit is contained in:
Alex Yatskov 2018-02-22 12:08:20 -08:00 committed by GitHub
commit 6a7bfe269a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -793,6 +793,13 @@ class AnkiBridge:
return decks return decks
def createDeck(self, deck):
self.startEditing()
deckId = self.collection().decks.id(deck)
self.stopEditing()
return deckId
def changeDeck(self, cards, deck): def changeDeck(self, cards, deck):
self.startEditing() self.startEditing()
@ -1207,6 +1214,9 @@ class AnkiConnect:
def getDecks(self, cards): def getDecks(self, cards):
return self.anki.getDecks(cards) return self.anki.getDecks(cards)
@webApi()
def createDeck(self, deck):
return self.anki.createDeck(deck)
@webApi() @webApi()
def changeDeck(self, cards, deck): def changeDeck(self, cards, deck):

View File

@ -313,6 +313,28 @@ guarantee that your application continues to function properly in the future.
} }
``` ```
* **createDeck**
Create a new empty deck. Will not overwrite a deck that exists with the same name.
*Sample request*:
```json
{
"action": "createDeck",
"version": 5,
"params": {
"deck": "Japanese::Tokyo"
}
}
```
*Sample result*:
```json
{
"result": 1519323742721,
"error": null
}
```
* **changeDeck** * **changeDeck**
Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet. Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.