5.0.2 • Published 10 months ago

@hoobs/sdk v5.0.2

Weekly downloads
192
License
GPL-3.0
Repository
github
Last release
10 months ago

npm.io

HOOBS JavaScript SDK for building applications that talk with the HOOBS API.

Installing

HOOBS recommends Yarn. From your project's root run;

yarn add @hoobs/sdk

Or using NPM.

npm install @hoobs/sdk

Usage

First you need to import the SDK

import SDK from "@hoobs/sdk";

Then create an bridge.

const hoobs = SDK();

Authorization Token

The HOOBS SDK manages authorization tokens for you. To do this you need to define the functions used to get and set the token. This is usefull, because it allows you to intergrate the authorization token into your projects state management.

hoobs.config.token.get(() => {
    // fetch and return the stored token
});

hoobs.config.token.set((token) => {
    // store token logic
});

Without this you will not be able to login to the HOOBS API.

Intergrating with Vue

The HOOBS SDK is designed to be used with Vue. To setup the mixin, modify your main.ts|js file. This example uses Vuex for managing the authorization token.

import Vue from "vue";
import Vuex from "vuex";
import SDK from "@hoobs/sdk";

import app from "./app.vue";

Vue.use(Vuex);

const store = new Vuex.Store({
    state: {
        session: "",
        user: {
            permissions: {},
        },
    },

    mutations: {
        "SESSION:SET": (state: { [key: string]: any }, token: string) => {
            state.session = token;

            if (token && token !== "") {
                const user = JSON.parse(atob(token));

                state.user = {
                    id: user.id,
                    name: user.name,
                    username: user.username,
                    permissions: user.permissions || {},
                };
            } else {
                state.user = {
                    permissions: {},
                };
            }
        }
    }
};

const hoobs = SDK();

hoobs.config.token.get(() => store.state.session);
hoobs.config.token.set((token) => { store.commit("SESSION:SET", token); });

Vue.mixin(hoobs.mixin());

new Vue({
    store,
    render: (h) => h(app),
}).$mount("#app");

Now you will be able to access the SDK via this.$hoobs in your components.

<script>
    export default {
        data() {
            return {
                version: "",
            }
        },

        async mounted() {
            this.version = await this.$hoobs.version();
        }
    }
</script>

Documentation

SDK documentation can be found here.
SDK Documentation

Legal

HOOBS and the HOOBS logo are registered trademarks of HOOBS Inc. Copyright (C) 2020 HOOBS Inc. All rights reserved.

5.0.2

10 months ago

5.0.1

10 months ago

5.0.0

10 months ago

5.0.1-alpha.9

11 months ago

5.0.1-alpha.8

12 months ago

5.0.1-alpha.12

11 months ago

5.0.1-alpha.13

11 months ago

5.0.1-alpha.14

11 months ago

5.0.1-alpha.15

11 months ago

5.0.1-alpha.10

11 months ago

5.0.1-alpha.11

11 months ago

5.0.1-alpha.7

12 months ago

5.0.1-alpha.6

1 year ago

5.0.1-alpha.5

1 year ago

5.0.1-alpha.4

1 year ago

5.0.1-alpha.2

1 year ago

5.0.1-alpha.3

1 year ago

5.0.1-alpha.1

1 year ago

5.0.1-alpha.0

1 year ago

4.7.1

2 years ago

4.5.9

3 years ago

4.5.10

3 years ago

4.5.11

3 years ago

4.5.8

3 years ago

4.5.7

3 years ago

4.5.4

3 years ago

4.5.5

3 years ago

4.5.3

3 years ago

4.5.2

3 years ago

4.5.1

3 years ago

4.4.11

3 years ago

4.4.10

3 years ago

4.4.9

3 years ago

4.4.8

3 years ago

4.4.7

3 years ago

4.4.5

3 years ago

4.4.4

3 years ago

4.4.6

3 years ago

4.4.1

3 years ago

4.4.2

3 years ago

4.3.20

3 years ago

4.3.19

3 years ago

4.3.18

3 years ago

4.3.9

3 years ago

4.3.8

3 years ago

4.3.7

3 years ago

4.3.12

3 years ago

4.3.11

3 years ago

4.3.10

3 years ago

4.3.17

3 years ago

4.3.15

3 years ago

4.3.14

3 years ago

4.3.5

3 years ago

4.2.22

3 years ago

4.3.4

3 years ago

4.3.3

3 years ago

4.2.20

3 years ago

4.2.21

3 years ago

4.2.19

3 years ago

4.2.17

3 years ago

4.2.18

3 years ago

4.2.16

3 years ago

4.2.15

3 years ago

4.2.12

3 years ago

4.2.14

3 years ago

4.2.11

3 years ago

4.2.10

3 years ago

4.2.9

3 years ago

4.2.8

3 years ago

4.2.7

3 years ago

4.2.6

3 years ago

4.2.5

3 years ago

4.2.4

3 years ago

4.2.3

3 years ago

4.2.2

3 years ago

4.2.1

3 years ago

4.1.7

3 years ago

4.1.6

3 years ago

4.1.5

3 years ago

4.1.4

3 years ago

4.1.3

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.0.11

3 years ago

4.0.10

3 years ago

4.0.9

3 years ago

4.0.8

3 years ago

4.0.7

3 years ago

4.0.6

3 years ago

4.0.5

3 years ago

4.0.4

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago