dist/vuex-c3s.es.js
function install(Vue) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    Swagger({
      url: options.swaggerURL,
      requestInterceptor: function requestInterceptor(req) {
        // req.headers['content-type'] = 'application/json'
        if (options.store.state.c3s && options.store.state.c3s.user) {
          var u = options.store.state.c3s.user.currentUser;

          if (u) {
            req.headers['X-API-KEY'] = u.api_key;
          }
        } else {
          console.log('c3s: state not loaded or not found');
        }

        return req;
      }
    }).then(function (client) {
      var store = options.store;
      var swaggerURL = options.swaggerURL;

      if (!store || !swaggerURL) {
        console.error('C3S: Missing store and/or Swagger URL params.');
        return;
      }

      console.log('Loaded from ' + options.swaggerURL);

      for (var i in modules) {
        var m = modules[i];
        var name = m['name'];
        var preserve = true;

        if (Array.isArray(name)) {
          if (store.state.c3s && store.state.c3s[name[1]] === undefined) {
            preserve = false;
          }
        } else {
          if (store.state[name] === undefined) {
            preserve = false;
          }
        }

        store.registerModule(name, m['module'], {
          preserveState: preserve
        }); // if (store.state.hasOwnProperty(m['name']) === false) {
        // 	console.error('C3S: C3S vuex module is not correctly initialized. Please check the module name:', m['name']);
        // 	return;
        // }
        // TODO check why store reports this as false when it is created
      }

      store.commit('c3s/SET_API', client);

      var isLoaded = function isLoaded() {
        if (store.c3s !== undefined && store.c3s.client !== null) {
          return true;
        } else {
          return false;
        }
      };

      Vue.prototype.$c3s = {
        store: C3SStore,
        loaded: isLoaded
      };
      Vue.c3s = {
        store: C3SStore,
        loaded: isLoaded
      };
    }).catch(function (err) {
      console.error('C3S: URL was not found or an initialisation error occurred');
      console.error(err);
    });
  }
function install(Vue) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    Swagger({
      url: options.swaggerURL,
      requestInterceptor: function requestInterceptor(req) {
        // req.headers['content-type'] = 'application/json'
        if (options.store.state.c3s && options.store.state.c3s.user) {
          var u = options.store.state.c3s.user.currentUser;

          if (u) {
            req.headers['X-API-KEY'] = u.api_key;
          }
        } else {
          console.log('c3s: state not loaded or not found');
        }

        return req;
      }
    }).then(function (client) {
      var store = options.store;
      var swaggerURL = options.swaggerURL;

      if (!store || !swaggerURL) {
        console.error('C3S: Missing store and/or Swagger URL params.');
        return;
      }

      console.log('Loaded from ' + options.swaggerURL);

      for (var i in modules) {
        var m = modules[i];
        var name = m['name'];
        var preserve = true;

        if (Array.isArray(name)) {
          if (store.state.c3s && store.state.c3s[name[1]] === undefined) {
            preserve = false;
          }
        } else {
          if (store.state[name] === undefined) {
            preserve = false;
          }
        }

        store.registerModule(name, m['module'], {
          preserveState: preserve
        }); // if (store.state.hasOwnProperty(m['name']) === false) {
        // 	console.error('C3S: C3S vuex module is not correctly initialized. Please check the module name:', m['name']);
        // 	return;
        // }
        // TODO check why store reports this as false when it is created
      }

      store.commit('c3s/SET_API', client);

      var isLoaded = function isLoaded() {
        if (store.c3s !== undefined && store.c3s.client !== null) {
          return true;
        } else {
          return false;
        }
      };

      Vue.prototype.$c3s = {
        store: C3SStore,
        loaded: isLoaded
      };
      Vue.c3s = {
        store: C3SStore,
        loaded: isLoaded
      };
    }).catch(function (err) {
      console.error('C3S: URL was not found or an initialisation error occurred');
      console.error(err);
    });
  }
function install ( Vue ) { var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ; Swagger ( { url : options . swaggerURL , requestInterceptor : function requestInterceptor ( req ) { // req.headers['content-type'] = 'application/json' if ( options . store . state . c3s && options . store . state . c3s . user ) { var u = options . store . state . c3s . user . currentUser ; if ( u ) { req . headers [ 'X-API-KEY' ] = u . api_key ; } } else { console . log ( 'c3s: state not loaded or not found' ) ; } return req ; } } ) . then ( function ( client ) { var store = options . store ; var swaggerURL = options . swaggerURL ; if ( ! store || ! swaggerURL ) { console . error ( 'C3S: Missing store and/or Swagger URL params.' ) ; return ; } console . log ( 'Loaded from ' + options . swaggerURL ) ; for ( var i in modules ) { var m = modules [ i ] ; var name = m [ 'name' ] ; var preserve = true ; if ( Array . isArray ( name ) ) { if ( store . state . c3s && store . state . c3s [ name [ 1 ] ] === undefined ) { preserve = false ; } } else { if ( store . state [ name ] === undefined ) { preserve = false ; } } store . registerModule ( name , m [ 'module' ] , { preserveState : preserve } ) ; // if (store.state.hasOwnProperty(m['name']) === false) { // 	console.error('C3S: C3S vuex module is not correctly initialized. Please check the module name:', m['name']); // 	return; // } // TODO check why store reports this as false when it is created } store . commit ( 'c3s/SET_API' , client ) ; var isLoaded = function isLoaded ( ) { if ( store . c3s !== undefined && store . c3s . client !== null ) { return true ; } else { return false ; } } ; Vue . prototype . $c3s = { store : C3SStore , loaded : isLoaded } ; Vue . c3s = { store : C3SStore , loaded : isLoaded } ; } ) . catch ( function ( err ) { console . error ( 'C3S: URL was not found or an initialisation error occurred' ) ; console . error ( err ) ; } ) ; }
Setup function for the plugin, must provide a store and a Swagger file URL
@param Vue
@param options
Setup function for the plugin must provide a store and a Swagger file URL