UNPKG

fb-test-module

Version:

How to use: ``` import {store, getStore} from 'fb-test-module'; conf.DialogramApi = "API_BASE_URL"; conf.Platform = "mobile"; //use "web" if you are on webApp getStore(); //Inject store in your provider ``` and you'r readyt to go. # Base ## Act

69 lines (68 loc) 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("../index"); class SessionHelper { static getSessionStatus() { const state = index_1.store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('status')) { return null; } return state.get('status'); } ; static getSessionToken() { const state = index_1.store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('session')) { return null; } if (!state.get('session').first()) return null; return state.get('session').first().get('token'); } static getSessionId() { const state = index_1.store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('session')) { return null; } if (!state.get('session').first()) return null; return state.get('session').first().get('id'); } static getSessionUserId() { const state = index_1.store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('session')) { return null; } if (!state.get('session').first()) return null; return state.get('session').first().get('user'); } static getSessionError() { const state = index_1.store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('error')) { return null; } return state.get('error'); } } exports.default = SessionHelper;