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_reflect(scopes, actions: nil) ⇒ Hash
Gets information about available APIs.
-
#export_deck(deck_name, path, include_scheduling: false) ⇒ Boolean
Exports deck to .apkg format.
-
#import_deck(path) ⇒ Boolean
Imports .apkg file into collection.
-
#load_profile(name) ⇒ Boolean
Switches to specified profile.
-
#multi(actions) ⇒ Array
Performs multiple actions in one request.
-
#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.
-
#version ⇒ Integer
Gets AnkiConnect API version.
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_reflect(scopes, actions: nil) ⇒ Hash
Gets information about available APIs.
28 29 30 31 32 |
# File 'lib/anki_connect/miscellaneous.rb', line 28 def api_reflect(scopes, actions: nil) params = { scopes: scopes } params[:actions] = actions if actions request(:apiReflect, **params) end |
#export_deck(deck_name, path, include_scheduling: false) ⇒ Boolean
Exports deck to .apkg format.
77 78 79 |
# File 'lib/anki_connect/miscellaneous.rb', line 77 def export_deck(deck_name, path, include_scheduling: false) request(:exportPackage, deck: deck_name, path: path, includeSched: include_scheduling) end |
#import_deck(path) ⇒ Boolean
Imports .apkg file into collection.
85 86 87 |
# File 'lib/anki_connect/miscellaneous.rb', line 85 def import_deck(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 |
#multi(actions) ⇒ Array
Performs multiple actions in one request.
67 68 69 |
# File 'lib/anki_connect/miscellaneous.rb', line 67 def multi(actions) request(:multi, actions: actions) 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.
92 93 94 |
# File 'lib/anki_connect/miscellaneous.rb', line 92 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 |
#version ⇒ Integer
Gets AnkiConnect API version.
19 20 21 |
# File 'lib/anki_connect/miscellaneous.rb', line 19 def version request(:version) end |