Module: AnkiConnect::Client::Miscellaneous
- Included in:
- AnkiConnect::Client
- Defined in:
- lib/anki_connect/miscellaneous.rb
Overview
Methods for API permissions, version checking, profile management, synchronization, and import/export.
Instance Method Summary collapse
-
#active_profile ⇒ String
Gets the active profile.
-
#api_capabilities(scopes, actions: nil) ⇒ Hash
Gets information about available APIs.
-
#api_version ⇒ Integer
Gets AnkiConnect API version.
-
#batch(actions) ⇒ Array
Performs multiple actions in one request.
-
#export_deck(deck_name, path, include_scheduling: false) ⇒ Boolean
Exports deck to .apkg format.
-
#import_package(path) ⇒ Boolean
Imports .apkg file into collection.
-
#load_profile(name) ⇒ Boolean
Switches to specified profile.
-
#profiles ⇒ Array<String>
Retrieves list of profiles.
-
#reload_collection ⇒ nil
Reloads all data from database.
-
#request_permission ⇒ Hash
Requests API permission (first call to establish trust).
-
#sync ⇒ nil
Synchronizes local collection with AnkiWeb.
Instance Method Details
#active_profile ⇒ String
Gets the active profile.
51 52 53 |
# File 'lib/anki_connect/miscellaneous.rb', line 51 def active_profile request(:getActiveProfile) end |
#api_capabilities(scopes, actions: nil) ⇒ Hash
Gets information about available APIs.
28 29 30 31 32 |
# File 'lib/anki_connect/miscellaneous.rb', line 28 def api_capabilities(scopes, actions: nil) params = { scopes: scopes } params[:actions] = actions if actions request(:apiReflect, **params) end |
#api_version ⇒ Integer
Gets AnkiConnect API version.
19 20 21 |
# File 'lib/anki_connect/miscellaneous.rb', line 19 def api_version request(:version) end |
#batch(actions) ⇒ Array
Performs multiple actions in one request. Unlike convenience wrappers, each action uses AnkiConnect's raw wire keys.
69 70 71 |
# File 'lib/anki_connect/miscellaneous.rb', line 69 def batch(actions) request(:multi, actions: actions) end |
#export_deck(deck_name, path, include_scheduling: false) ⇒ Boolean
Exports deck to .apkg format.
79 80 81 |
# File 'lib/anki_connect/miscellaneous.rb', line 79 def export_deck(deck_name, path, include_scheduling: false) request(:exportPackage, deck: deck_name, path: path, includeSched: include_scheduling) end |
#import_package(path) ⇒ Boolean
Imports .apkg file into collection.
87 88 89 |
# File 'lib/anki_connect/miscellaneous.rb', line 87 def import_package(path) request(:importPackage, path: path) end |
#load_profile(name) ⇒ Boolean
Switches to specified profile.
59 60 61 |
# File 'lib/anki_connect/miscellaneous.rb', line 59 def load_profile(name) request(:loadProfile, name: name) end |
#profiles ⇒ Array<String>
Retrieves list of profiles.
44 45 46 |
# File 'lib/anki_connect/miscellaneous.rb', line 44 def profiles request(:getProfiles) end |
#reload_collection ⇒ nil
Reloads all data from database.
94 95 96 |
# File 'lib/anki_connect/miscellaneous.rb', line 94 def reload_collection request(:reloadCollection) end |
#request_permission ⇒ Hash
Requests API permission (first call to establish trust). Only method accepting requests from any origin. Shows popup for untrusted origins.
12 13 14 |
# File 'lib/anki_connect/miscellaneous.rb', line 12 def request(:requestPermission) end |
#sync ⇒ nil
Synchronizes local collection with AnkiWeb.
37 38 39 |
# File 'lib/anki_connect/miscellaneous.rb', line 37 def sync request(:sync) end |