2018-10-19 05:15:28 +00:00
|
|
|
import axios from 'axios';
|
|
|
|
|
2018-10-19 06:04:27 +00:00
|
|
|
const FIREBASE_URL = 'https://us-central1-gamebrary-8c736.cloudfunctions.net';
|
2018-10-19 05:15:28 +00:00
|
|
|
|
|
|
|
export default {
|
2018-10-19 06:04:27 +00:00
|
|
|
LOAD_GAMES({ commit }, gameList) {
|
2018-10-19 05:15:28 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2018-11-21 02:43:10 +00:00
|
|
|
axios.get(`${FIREBASE_URL}/games?games=${gameList}`)
|
2018-10-19 05:15:28 +00:00
|
|
|
.then(({ data }) => {
|
|
|
|
commit('CACHE_GAME_DATA', data);
|
|
|
|
resolve();
|
|
|
|
}).catch(reject);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-02-08 05:46:29 +00:00
|
|
|
LOAD_RELEASES({ commit }) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
axios.get('https://api.github.com/repos/romancmx/gamebrary/releases')
|
|
|
|
.then(({ data }) => {
|
|
|
|
commit('SET_RELEASES', data);
|
|
|
|
resolve();
|
|
|
|
}).catch(reject);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-11-21 02:43:10 +00:00
|
|
|
LOAD_PUBLIC_GAMES({ commit }, gameList) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
axios.get(`${FIREBASE_URL}/games?games=${gameList}`)
|
|
|
|
.then(({ data }) => {
|
|
|
|
commit('SET_PUBLIC_GAME_DATA', data);
|
|
|
|
resolve();
|
|
|
|
}).catch(reject);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-11-17 22:21:29 +00:00
|
|
|
LOAD_GAME({ commit }, gameId) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
axios.get(`${FIREBASE_URL}/game?gameId=${gameId}`)
|
|
|
|
.then(({ data }) => {
|
|
|
|
commit('SET_ACTIVE_GAME', data);
|
|
|
|
resolve();
|
|
|
|
}).catch(reject);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-10-25 06:33:15 +00:00
|
|
|
SEARCH({ commit, state }, searchText) {
|
2018-10-19 05:15:28 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2018-10-25 06:33:15 +00:00
|
|
|
axios.get(`${FIREBASE_URL}/search?searchText=${searchText}&platformId=${state.platform.id}`)
|
2018-10-19 05:15:28 +00:00
|
|
|
.then(({ data }) => {
|
|
|
|
commit('SET_SEARCH_RESULTS', data);
|
|
|
|
commit('CACHE_GAME_DATA', data);
|
|
|
|
resolve();
|
|
|
|
}).catch(reject);
|
|
|
|
});
|
|
|
|
},
|
2018-11-27 06:46:01 +00:00
|
|
|
|
|
|
|
LOAD_PLATFORM({ state }) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
axios.get(`${FIREBASE_URL}/platform?&platformId=${state.platform.id}`)
|
|
|
|
.then(({ data }) => {
|
|
|
|
resolve(data);
|
|
|
|
}).catch(reject);
|
|
|
|
});
|
|
|
|
},
|
2019-04-02 23:45:01 +00:00
|
|
|
|
|
|
|
SEND_WELCOME_EMAIL() {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const payload = {
|
|
|
|
address: 'urbanbooth@gmail.com',
|
|
|
|
template_id: 'welcome',
|
|
|
|
};
|
|
|
|
|
|
|
|
axios.post(`${FIREBASE_URL}/email`, payload)
|
|
|
|
.then(({ data }) => {
|
|
|
|
resolve(data);
|
|
|
|
}).catch(reject);
|
|
|
|
});
|
|
|
|
},
|
2018-10-19 05:15:28 +00:00
|
|
|
};
|