~foosoft/anki-connect

a779fa673f306907da620c3f02929c1c72b16f0c — Alex Yatskov 4 years ago 8c248d9 + 6723332
Merge pull request #159 from snoyes/getProfiles

Add getProfiles action
3 files changed, 31 insertions(+), 0 deletions(-)

M README.md
M plugin/__init__.py
M tests/test_misc.py
M README.md => README.md +20 -0
@@ 222,6 222,26 @@ guarantee that your application continues to function properly in the future.
    }
    ```

*   **getProfiles**

    Retrieve the list of profiles.

    *Sample request*:
    ```json
    {
        "action": "getProfiles",
        "version": 6
    }
    ```

    *Sample result*:
    ```json
    {
        "result": ["User 1"],
        "error": null
    }
    ```

*   **loadProfile**

    Selects the profile specified in request.

M plugin/__init__.py => plugin/__init__.py +3 -0
@@ 262,6 262,9 @@ class AnkiConnect:
    def version(self):
        return util.setting('apiVersion')

    @util.api()
    def getProfiles(self):
        return self.window().pm.profiles()

    @util.api()
    def loadProfile(self, name):

M tests/test_misc.py => tests/test_misc.py +8 -0
@@ 14,6 14,14 @@ class TestMisc(unittest.TestCase):
        # sync
        util.invoke('sync')

        # getProfiles
        profiles = util.invoke('getProfiles')
        self.assertIsInstance(profiles, list)
        self.assertGreater(len(profiles), 0)

        # loadProfile
        util.invoke('loadProfile', name=profiles[0])

        # multi
        actions = [util.request('version'), util.request('version'), util.request('version')]
        results = util.invoke('multi', actions=actions)

Do not follow this link