at the end of the day, it was inevitable
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
export const getSavedAnalysesApi = createApi('GET', '/api/v1/analytic', {
|
||||
inputData: (data) => {
|
||||
if (data.sort !== 'numberCharts') {
|
||||
data.sort = 's.' + data.sort
|
||||
}
|
||||
return data
|
||||
},
|
||||
rejectData: (defHandler, xhr) => {
|
||||
return defHandler(xhr, undefined, 'Cannot get saved analyses')
|
||||
}
|
||||
})
|
||||
export const deleteSavedAnalysesApi = createApi('DELETE', '/api/v1/analytic/delete', {
|
||||
inputData: (ids) => {
|
||||
return JSON.stringify({ids: ids})
|
||||
},
|
||||
rejectData: (defHandler, xhr) => {
|
||||
return defHandler(xhr, undefined, 'Cannot delete saved analyses')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,165 @@
|
||||
import { sum } from 'lodash'
|
||||
import { convertlocaltoUTC } from '../../common/helper'
|
||||
import { get, post, put } from '../httpInterceptor/httpInterceptor'
|
||||
|
||||
const formatValues = (data) => {
|
||||
let newObj = {}
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
for (let v in value) {
|
||||
newObj[v] = newObj[v]
|
||||
? { ...newObj[v], [key]: value[v] }
|
||||
: { [key]: value[v] }
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(data).map((dt) => {
|
||||
for (let item in newObj) {
|
||||
newObj[item][dt] = newObj[item][dt] || 0
|
||||
}
|
||||
})
|
||||
|
||||
const obj = Object.keys(newObj).map((v) => ({
|
||||
name: v,
|
||||
data: newObj[v]
|
||||
}))
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
export const addEditAnalyticsAPI = async (data, id) => {
|
||||
let url = `/analysis${id ? `/${id}` : ''}`
|
||||
|
||||
const bodyObj = {}
|
||||
// bodyObj.filters = [] // need changes
|
||||
bodyObj.filters = {
|
||||
date: {
|
||||
type: 'between',
|
||||
start: convertlocaltoUTC(data.startDate, 'YYYY-MM-DD'),
|
||||
end: convertlocaltoUTC(data.endDate, 'YYYY-MM-DD')
|
||||
}
|
||||
}
|
||||
bodyObj.feeds = data.feeds.map((val) => val.id)
|
||||
|
||||
const func = id ? put : post
|
||||
const res = await func(url, bodyObj)
|
||||
console.log('API Response :: addEditAnalytics ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
export const getAnalyticDetailsAPI = async (id) => {
|
||||
let url = `/analysis/${id}`
|
||||
const res = await get(url)
|
||||
console.log('API Response :: getAnalyticDetails ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
export const createAlertAPI = async (data) => {
|
||||
let url = '/notifications'
|
||||
const res = await post(url, data)
|
||||
console.log('API Response :: creteAnalytics ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
/* Chart APIs */
|
||||
export const getOverviewBarAPI = async (type = 'none', id) => {
|
||||
let isOther = type !== 'none'
|
||||
let url = isOther
|
||||
? `/mention-over-time-bar-graph/${id}`
|
||||
: `/mention-bar-graph/${id}`
|
||||
const res = await post(url, isOther ? { type } : undefined)
|
||||
if (isOther && res.data && res.data.data) {
|
||||
res.data.data = res.data.data.map((feed) => ({
|
||||
name: feed.name,
|
||||
data: formatValues(feed.data)
|
||||
}))
|
||||
}
|
||||
console.log('API Response :: getOverviewBarAPI ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
/* Used for Overview, Performance, Sentiment, Demographics */
|
||||
export const getOverviewPieAPI = async (type = 'none', id) => {
|
||||
let isOther = type !== 'none'
|
||||
let url = isOther
|
||||
? `/mention-over-time-pie-graph/${id}`
|
||||
: `/mention-pie-graph/${id}`
|
||||
const res = await post(url, isOther ? { type } : undefined)
|
||||
console.log('API Response :: getOverviewPieAPI ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
export const getInfluencersAPI = async (id, filter, data = undefined) => {
|
||||
let url = `/influencer/${id}`
|
||||
if (filter === 1) {
|
||||
data = { isAuthorType: true }
|
||||
}
|
||||
const res = await post(url, data)
|
||||
console.log('API Response :: getInfluencersAPI ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
export const getEngagementsTimeAPI = async (id) => {
|
||||
let url = `/engagement-over-time-bar-graph/${id}`
|
||||
const res = await post(url)
|
||||
console.log('API Response :: getEngagementsTimeAPI ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
export const getEngagementsAPI = async (id) => {
|
||||
let url = `/engagement-over-time-pie-graph/${id}`
|
||||
const res = await post(url)
|
||||
console.log('API Response :: getEngagementsAPI ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
/* Themes */
|
||||
|
||||
export const getThemesTimeAPI = async (id) => {
|
||||
let url = `/theme-over-time-bar-graph/${id}`
|
||||
const res = await post(url)
|
||||
const { data } = res.data
|
||||
let newData = data
|
||||
if (data) {
|
||||
newData = data.map((feedData) => {
|
||||
const { name, data } = feedData
|
||||
let dataTotal = data.map((theme) => {
|
||||
const { name, data } = theme
|
||||
const total = sum(Object.values(data))
|
||||
return { name, data, total }
|
||||
})
|
||||
dataTotal = topN(dataTotal, 5)
|
||||
return { name, data: dataTotal }
|
||||
})
|
||||
}
|
||||
res.data.data = newData
|
||||
console.log('API Response :: getThemesTimeAPI ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
function topN(arr, n) {
|
||||
if (n > arr.length) {
|
||||
return arr
|
||||
}
|
||||
return arr
|
||||
.slice()
|
||||
.sort((a, b) => {
|
||||
return b.total - a.total
|
||||
})
|
||||
.slice(0, n)
|
||||
}
|
||||
|
||||
export const getThemesCloudAPI = async (id) => {
|
||||
let url = `/theme-over-time-pie-graph/${id}`
|
||||
const res = await post(url)
|
||||
console.log('API Response :: getThemesCloudAPI ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
/* World Map */
|
||||
|
||||
export const getWorldMapAPI = async (id) => {
|
||||
let url = `/world-map/${id}`
|
||||
const res = await post(url)
|
||||
console.log('API Response :: getWorldMapAPI ::: ', res)
|
||||
return res
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { get, del } from '../httpInterceptor/httpInterceptor'
|
||||
|
||||
export const savedAnalytics = async (params) => {
|
||||
let url = '/analysis'
|
||||
const res = await get(url, params)
|
||||
console.log('API Response :: savedAnalytics ::: ', res)
|
||||
return res
|
||||
}
|
||||
|
||||
export const deleteAnalytics = async (id) => {
|
||||
let url = `/analysis/${id}`
|
||||
const res = await del(url)
|
||||
console.log('API Response :: deleteAnalytics ::: ', res)
|
||||
return res
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
/**
|
||||
* payload: {ids: [...]}
|
||||
*/
|
||||
export const deleteDocumentsFromFeed = createApi('POST', '/api/v1/feed/{feedId}/documents/delete', {
|
||||
inputData: (idsArray) => JSON.stringify({ids: idsArray}),
|
||||
urlData: (params, feedId) => ({feedId})
|
||||
})
|
||||
|
||||
/**
|
||||
* payload: {emailTo, emailReplyTo, subject, content}
|
||||
*/
|
||||
export const sendDocumentsByEmail = createApi('POST', '/api/v1/documents/email', {
|
||||
})
|
||||
|
||||
/**
|
||||
* payload: {title, comment}
|
||||
*/
|
||||
export const commentDocument = createApi('POST', '/api/v1/documents/{documentId}/comments', {
|
||||
urlData: (params, documentId) => ({documentId})
|
||||
})
|
||||
|
||||
/**
|
||||
* payload: {ids: []}
|
||||
*/
|
||||
export const clipDocuments = createApi('POST', '/api/v1/feed/{feedId}/documents/clip', {
|
||||
urlData: (params, feedId) => ({feedId}),
|
||||
inputData: (idsArray) => JSON.stringify({ids: idsArray})
|
||||
})
|
||||
|
||||
/**
|
||||
* payload: {title, comment}
|
||||
*/
|
||||
export const updateComment = createApi('PUT', '/api/v1/comments/{commentId}', {
|
||||
urlData: (params, commentId) => ({commentId})
|
||||
})
|
||||
|
||||
export const deleteComment = createApi('DELETE', '/api/v1/comments/{commentId}', {
|
||||
urlData: (params, commentId) => ({commentId})
|
||||
})
|
||||
|
||||
export const getComments = createApi('GET', '/api/v1/documents/{documentId}/comments', {
|
||||
inputData: (params) => params,
|
||||
urlData: (params, documentId) => ({documentId})
|
||||
})
|
||||
|
||||
export const readLater = createApi('POST', '/api/v1/feed/readLater/{documentId}', {
|
||||
urlData: (params, documentId) => ({documentId})
|
||||
})
|
||||
|
||||
export const getRecentClipFeeds = createApi('GET', '/api/v1/feed/recentClip')
|
||||
@@ -0,0 +1,68 @@
|
||||
import {createApi, mockApi} from '../common/Common'
|
||||
|
||||
const base = '/api/v1/dashboards'
|
||||
|
||||
/*class DashboardWidget {
|
||||
id: number,
|
||||
type: "feed" | "chart" | "video" | "youtube",
|
||||
name?: string,
|
||||
source?: Feed | Chart,
|
||||
limit?: number,
|
||||
url?: string
|
||||
}
|
||||
|
||||
class Dashboard {
|
||||
id: ...
|
||||
name: string,
|
||||
layout: any,
|
||||
widgets: DashboardWidget[]
|
||||
}
|
||||
*/
|
||||
|
||||
//export const getDashboards = createApi('GET', base);
|
||||
export const getDashboards = mockApi([
|
||||
{id: 1, name: 'My Dashboard', layout: '{ver: 1, left: [1, 2], right: [3, 4]}', widgets: [
|
||||
{id: 1, type: 'feed', name: 'Widget1', source: {id: 1}, limit: 5},
|
||||
{id: 2, type: 'feed', name: 'Widget2', source: {id: 2}, limit: 5},
|
||||
{id: 3, type: 'feed', name: 'Widget3', source: {id: 3}, limit: 5},
|
||||
{id: 4, type: 'feed', name: 'Widget4', source: {id: 4}, limit: 5}
|
||||
]},
|
||||
{id: 2, name: 'Dashboard 2', layout: '{ver: 1, left: [5, 6, 7], right: [8]}', widgets: [
|
||||
{id: 5, type: 'feed', name: 'Widget5', source: {id: 1}, limit: 5},
|
||||
{id: 6, type: 'feed', name: 'Widget6', source: {id: 2}, limit: 5},
|
||||
{id: 7, type: 'feed', name: 'Widget7', source: {id: 3}, limit: 5},
|
||||
{id: 8, type: 'feed', name: 'Widget8', source: {id: 4}, limit: 5}
|
||||
]},
|
||||
{id: 44, name: 'Not_my_dashboard', layout: '{ver: 1, left: [], right: [9, 10, 11, 12]}', widgets: [
|
||||
{id: 9, type: 'feed', name: 'Widget9', source: {id: 1}, limit: 5},
|
||||
{id: 10, type: 'feed', name: 'Widget10', source: {id: 2}, limit: 5},
|
||||
{id: 11, type: 'feed', name: 'Widget11', source: {id: 3}, limit: 5},
|
||||
{id: 12, type: 'feed', name: 'Widget12', source: {id: 4}, limit: 5}
|
||||
]}
|
||||
])
|
||||
|
||||
//payload = {name}
|
||||
export const createDashboard = createApi('POST', base)
|
||||
|
||||
//payload = dashboard widget
|
||||
export const createDashboardWidget = createApi('POST', `${base}/{dashboardId}/widgets`, {
|
||||
urlData: (payload, dashboardId) => ({dashboardId})
|
||||
})
|
||||
|
||||
export const getVideoWidgetUrl = createApi('GET', `${base}/{dashboardId}/widgets/{widgetId}/video`, {
|
||||
urlData: (payload, dashboardId, widgetId) => ({dashboardId, widgetId})
|
||||
})
|
||||
|
||||
//payload = dashboard without widgets
|
||||
export const updateDashboard = createApi('PUT', `${base}/{dashboardId}`, {
|
||||
urlData: (payload, dashboardId) => ({dashboardId})
|
||||
})
|
||||
|
||||
//payload = dashboard widget
|
||||
export const updateDashboardWidget = createApi('PUT', `${base}/{dashboardId}/widgets/{widgetId}`, {
|
||||
urlData: (payload, dashboardId, widgetId) => ({dashboardId, widgetId})
|
||||
})
|
||||
|
||||
export const deleteDashboardWidget = createApi('DELETE', `${base}/{dashboardId}`)
|
||||
|
||||
export const deleteDashboard = createApi('DELETE', `${base}/{dashboardId}`)
|
||||
@@ -0,0 +1,4 @@
|
||||
// import {createApi} from '../common/Common'
|
||||
|
||||
// const baseUrl = '/api/v1/receivers'
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
const root = '/api/v1/feed'
|
||||
|
||||
/**
|
||||
* payload: {feed: {name: string, category: id, subType: string}, search: {query: string, filters: Object, advancedFilters: Object}}
|
||||
*/
|
||||
export const createFeed = createApi('POST', root)
|
||||
|
||||
/**
|
||||
* payload: {feed: {name: string, category: id, subType: string}, search: {query: string, filters: Object, advancedFilters: Object}}
|
||||
*/
|
||||
export const saveFeed = createApi('PUT', `${root}/{feedId}`, {
|
||||
urlData: (data, feedId) => ({feedId})
|
||||
})
|
||||
|
||||
/**
|
||||
* payload = {name: string}
|
||||
*/
|
||||
export const renameFeed = createApi('PUT', `${root}/{feedId}/rename`, {
|
||||
urlData: (payload, feedId) => ({feedId})
|
||||
})
|
||||
|
||||
export const moveFeed = createApi('POST', `${root}/{feedId}/move_to/{categoryId}`, {
|
||||
urlData: (payload, feedId, categoryId) => ({feedId, categoryId})
|
||||
})
|
||||
|
||||
export const deleteFeed = createApi('DELETE', `${root}/{feedId}`, {
|
||||
urlData: (payload, feedId) => ({feedId})
|
||||
})
|
||||
|
||||
/**
|
||||
* payload: {page: number, advancedFilters: Object}
|
||||
*/
|
||||
export const getFeedSearchResults = createApi('POST', `${root}/{feedId}/documents`, {
|
||||
urlData: (params, feedId) => ({feedId})
|
||||
})
|
||||
|
||||
/**
|
||||
* payload = {export: bool}
|
||||
*/
|
||||
export const toggleExportFeed = createApi('PUT', `${root}/{feedId}/toggleExport`, {
|
||||
urlData: (payload, feedId) => ({feedId})
|
||||
})
|
||||
|
||||
/**
|
||||
* payload = {export: bool}
|
||||
*/
|
||||
export const toggleExportCategory = createApi('PUT', `${root}/toggleExport/{categoryId}`, {
|
||||
urlData: (payload, categoryId) => ({categoryId})
|
||||
})
|
||||
|
||||
export const loadExportedFeeds = createApi('GET', `${root}/exported`)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
const baseUrl = '/api/v1/recipients/groups'
|
||||
|
||||
export const getItems = createApi('GET', baseUrl, {
|
||||
inputData: (data) => data
|
||||
})
|
||||
|
||||
export const createItem = createApi('POST', baseUrl)
|
||||
|
||||
export const updateItem = createApi('PUT', baseUrl + '/{groupId}', {
|
||||
urlData: (data, groupId) => ({groupId})
|
||||
})
|
||||
|
||||
export const deleteItems = createApi('POST', baseUrl + '/delete')
|
||||
|
||||
export const activateItems = createApi('PUT', baseUrl + '/active')
|
||||
@@ -0,0 +1,122 @@
|
||||
import axios from 'axios';
|
||||
import apiBase from '../../appConfig';
|
||||
import i18n from '../../i18n';
|
||||
|
||||
export const get = (
|
||||
url,
|
||||
params,
|
||||
isPublic = false,
|
||||
responseType = null,
|
||||
passedFullURL = false
|
||||
) => {
|
||||
let apiUrl = passedFullURL
|
||||
? `${apiBase.apiUrl}${url}`
|
||||
: `${apiBase.apiUrl}/api/v1${url}`;
|
||||
|
||||
const axiosInstance = axios.create();
|
||||
|
||||
const axiosObj = {
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
params: params
|
||||
};
|
||||
|
||||
if (isPublic) {
|
||||
// apis in which no authentication needed
|
||||
axiosInstance.transformRequest = (data, headers) => {
|
||||
delete headers.common['Authorization'];
|
||||
};
|
||||
}
|
||||
|
||||
if (responseType) axiosObj.responseType = responseType;
|
||||
return axiosInstance(axiosObj)
|
||||
.then((response) => handleResponse(response))
|
||||
.catch((error) => handleError(error));
|
||||
};
|
||||
|
||||
export function put(...rest) {
|
||||
return dataRequest('put', ...rest);
|
||||
}
|
||||
|
||||
export function post(...rest) {
|
||||
return dataRequest('post', ...rest);
|
||||
}
|
||||
|
||||
export function del(...rest) {
|
||||
return dataRequest('delete', ...rest);
|
||||
}
|
||||
|
||||
const dataRequest = (
|
||||
type = 'post',
|
||||
url,
|
||||
bodyObj = undefined,
|
||||
isPublic = false,
|
||||
mediaFile = false,
|
||||
passedFullURL = false
|
||||
) => {
|
||||
const apiUrl = passedFullURL
|
||||
? `${apiBase.apiUrl}${url}`
|
||||
: `${apiBase.apiUrl}/api/v1${url}`;
|
||||
|
||||
if (mediaFile) {
|
||||
const formData = new FormData();
|
||||
Object.keys(bodyObj).map((key) => {
|
||||
formData.append(key, bodyObj[key]);
|
||||
});
|
||||
bodyObj = formData;
|
||||
}
|
||||
|
||||
const axiosInstance = axios.create();
|
||||
|
||||
const axiosObj = {
|
||||
method: type,
|
||||
url: apiUrl,
|
||||
data: bodyObj
|
||||
};
|
||||
|
||||
if (isPublic) {
|
||||
// apis in which no authentication needed
|
||||
axiosInstance.transformRequest = (data, headers) => {
|
||||
delete headers.common['Authorization'];
|
||||
};
|
||||
}
|
||||
|
||||
return axiosInstance(axiosObj)
|
||||
.then((response) => handleResponse(response))
|
||||
.catch((error) => handleError(error));
|
||||
};
|
||||
|
||||
export const handleResponse = (response) => {
|
||||
if (
|
||||
response.data &&
|
||||
(response.data.code === 403 || response.data.code === 404)
|
||||
) {
|
||||
return {
|
||||
error: true,
|
||||
errorMessage: response.data.message,
|
||||
data: response.message
|
||||
};
|
||||
}
|
||||
return {
|
||||
error: false,
|
||||
data: response.data
|
||||
};
|
||||
};
|
||||
|
||||
export const handleError = (error) => {
|
||||
const { response } = error;
|
||||
let errorMsg = i18n.t('common:alerts.error.somethingWrong');
|
||||
if (response && response.status === 422) {
|
||||
if (response.data.message) errorMsg = response.data.message;
|
||||
} else if (response && response.status === 401) {
|
||||
// Unauthorized
|
||||
}
|
||||
console.log('API Error ::: ', JSON.stringify(response));
|
||||
|
||||
return {
|
||||
error: true,
|
||||
errorMessage: errorMsg,
|
||||
data: response ? response.data.errors : null,
|
||||
status: response ? response.status : null
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
import $ from 'jquery'
|
||||
import {createApi} from '../common/Common'
|
||||
import config from '../appConfig'
|
||||
import { errorConstants } from '../common/constants'
|
||||
import i18n from '../i18n'
|
||||
|
||||
export const login = (userData) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: config.apiUrl + '/security/token/create',
|
||||
dataType: 'json',
|
||||
data: JSON.stringify({
|
||||
email: userData.email,
|
||||
password: userData.password
|
||||
}),
|
||||
success: function (data) {
|
||||
resolve(data)
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
const errMessage =
|
||||
jqXHR.responseJSON &&
|
||||
jqXHR.responseJSON.errors &&
|
||||
jqXHR.responseJSON.errors
|
||||
.map((err) =>
|
||||
i18n.t(`loginApp:errorMessages.${errorConstants[err]}`, {
|
||||
defaultValue: err || ''
|
||||
})
|
||||
)
|
||||
.join(' ');
|
||||
console.log(errorThrown + ': Error ' + jqXHR.status, 'jsonAPIERROR');
|
||||
reject({
|
||||
msg: errMessage || i18n.t('common:alerts.error.somethingWrong')
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const loginRefresh = (refreshToken) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: config.apiUrl + '/security/token/refresh',
|
||||
dataType: 'json',
|
||||
data: JSON.stringify({
|
||||
refreshToken: refreshToken
|
||||
}),
|
||||
success: function (data) {
|
||||
resolve(data)
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
console.log(errorThrown + ': Error ' + jqXHR.status, 'jsonAPIERROR')
|
||||
reject({msg: 'Your session is expired, please login again'})
|
||||
|
||||
/* if (jqXHR.status === 401) {
|
||||
reject({msg: 'Your session is expired, please login again'});
|
||||
} else {
|
||||
reject({msg: 'Login error, please login again'});
|
||||
} */
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const getRestrictions = createApi('GET', '/api/v1/users/current/restrictions', {
|
||||
inputData: (data) => data
|
||||
})
|
||||
@@ -0,0 +1,38 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
const baseUrl = '/api/v1/notifications'
|
||||
|
||||
export const getItems = createApi('GET', baseUrl, {
|
||||
inputData: (data) => data
|
||||
})
|
||||
|
||||
export const getItem = createApi('GET', baseUrl + '/{id}', {
|
||||
inputData: () => {},
|
||||
urlData: (data, id) => ({id})
|
||||
})
|
||||
|
||||
export const createItem = createApi('POST', baseUrl)
|
||||
|
||||
export const updateItem = createApi('PUT', baseUrl + '/{id}', {
|
||||
urlData: (data, id) => ({id})
|
||||
})
|
||||
|
||||
export const deleteItems = createApi('POST', baseUrl + '/delete')
|
||||
|
||||
export const activateItems = createApi('PUT', baseUrl + '/active')
|
||||
|
||||
export const publishItems = createApi('PUT', baseUrl + '/published')
|
||||
|
||||
export const subscribeItems = createApi('POST', baseUrl + '/subscribe')
|
||||
|
||||
export const getAllItems = createApi('GET', baseUrl + '/all', {
|
||||
inputData: (data) => data
|
||||
})
|
||||
export const getFilters = createApi('GET', baseUrl + '/filters', {
|
||||
inputData: (data) => data
|
||||
})
|
||||
|
||||
export const getHistory = createApi('GET', baseUrl + '/{notificationId}/history', {
|
||||
inputData: (data) => data,
|
||||
urlData: (data, notificationId) => ({notificationId})
|
||||
})
|
||||
@@ -0,0 +1,154 @@
|
||||
import axios from 'axios';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import appConfig from '../../appConfig';
|
||||
import { hubspotBaseURL } from '../../common/constants';
|
||||
import { getHPContext } from '../../common/helper';
|
||||
import {
|
||||
get,
|
||||
handleError,
|
||||
handleResponse,
|
||||
post
|
||||
} from '../httpInterceptor/httpInterceptor';
|
||||
|
||||
export const cancelPlan = async () => {
|
||||
let url = '/users/cancel/plan';
|
||||
const res = await post(url);
|
||||
console.log('API Response :: cancelPlan ::: ', res);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getTransactions = async (params) => {
|
||||
let url = '/users/invoices';
|
||||
const res = await get(url, params);
|
||||
console.log('API Response :: getTransactions ::: ', res);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updatePlanPayment = async (data) => {
|
||||
let url = '/users/update/plan';
|
||||
const res = await post(url, data);
|
||||
console.log('API Response :: updatePlanPayment ::: ', res);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const changeCardDetails = async (data) => {
|
||||
let url = '/users/card/change';
|
||||
const res = await post(url, data);
|
||||
console.log('API Response :: changeCard ::: ', res);
|
||||
return res;
|
||||
};
|
||||
|
||||
// submit update plan data to Hubspot form API
|
||||
export const updatePlanHubspot = (dataObj) => {
|
||||
const { hubSpotportalID } = appConfig;
|
||||
if (!hubSpotportalID) {
|
||||
return Promise.resolve('No IDs');
|
||||
}
|
||||
|
||||
const data = cloneDeep(dataObj);
|
||||
data.line1 = data.line2 ? [data.line1, data.line2].join(', ') : data.line1;
|
||||
const hubSpotFormURL = `${hubspotBaseURL}/47b0e83d-0e26-4528-8822-9aec64db35e8`;
|
||||
const hubSpotMapping = {
|
||||
savedFeeds: 'feed_licenses',
|
||||
searchesPerDay: 'search_licenses',
|
||||
webFeeds: 'webfeed_licenses',
|
||||
alerts: 'alert_licenses',
|
||||
subscriberAccounts: 'user_accounts',
|
||||
line1: 'address',
|
||||
city: 'city',
|
||||
state: 'state',
|
||||
postal_code: 'zip',
|
||||
country: 'country',
|
||||
phone: 'phone',
|
||||
email: 'email',
|
||||
totalCost: 'amount'
|
||||
};
|
||||
|
||||
const mediaTypesMapping = {
|
||||
news: 'News',
|
||||
blog: 'Blogs',
|
||||
reddit: 'Reddit',
|
||||
twitter: 'Twitter',
|
||||
instagram: 'Instagram'
|
||||
};
|
||||
|
||||
const mediaTypes = Object.keys(mediaTypesMapping)
|
||||
.filter((key) => data[key])
|
||||
.map((v) => mediaTypesMapping[v])
|
||||
.join(';');
|
||||
|
||||
const newObj = Object.keys(hubSpotMapping)
|
||||
.filter((key) => data[key])
|
||||
.map((key) => ({
|
||||
name: hubSpotMapping[key],
|
||||
value: data[key]
|
||||
}));
|
||||
|
||||
newObj.push({
|
||||
name: 'media_types',
|
||||
value: mediaTypes
|
||||
});
|
||||
|
||||
newObj.push({
|
||||
name: 'analytics',
|
||||
value: data['analytics'] && data['analytics'] !== 0
|
||||
});
|
||||
|
||||
return axios
|
||||
.post(hubSpotFormURL, {
|
||||
fields: newObj,
|
||||
context: getHPContext()
|
||||
})
|
||||
.then((response) => handleResponse(response))
|
||||
.catch((error) => handleError(error));
|
||||
};
|
||||
|
||||
// submit cancel plan data to Hubspot form API
|
||||
export const cancelPlanHubspot = (dataObj) => {
|
||||
const { hubSpotportalID } = appConfig;
|
||||
if (!hubSpotportalID) {
|
||||
return Promise.resolve('No IDs');
|
||||
}
|
||||
|
||||
const data = cloneDeep(dataObj);
|
||||
const hubSpotFormURL = `${hubspotBaseURL}/4d2496c3-0535-4723-8b5e-bd04e7903338`;
|
||||
const hubSpotMapping = {
|
||||
email: 'email',
|
||||
content: 'TICKET.content',
|
||||
subject: 'TICKET.subject'
|
||||
};
|
||||
|
||||
const reason = {
|
||||
1: '1',
|
||||
2: '2',
|
||||
3: '3',
|
||||
4: '4',
|
||||
5: '5',
|
||||
Other: 'Other'
|
||||
};
|
||||
|
||||
const reasonValues = Object.keys(reason)
|
||||
.filter((key) => data[key])
|
||||
.map((v) => reason[v])
|
||||
.join(';');
|
||||
|
||||
const newObj = Object.keys(hubSpotMapping)
|
||||
.filter((key) => data[key])
|
||||
.map((key) => ({
|
||||
name: hubSpotMapping[key],
|
||||
value: data[key]
|
||||
}));
|
||||
|
||||
newObj.push({
|
||||
name: 'cancelreason',
|
||||
value: reasonValues
|
||||
});
|
||||
|
||||
return axios
|
||||
.post(hubSpotFormURL, {
|
||||
fields: newObj,
|
||||
context: getHPContext()
|
||||
})
|
||||
.then((response) => handleResponse(response))
|
||||
.catch((error) => handleError(error));
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
const baseUrl = '/api/v1/receivers'
|
||||
|
||||
export const getItems = createApi('GET', baseUrl, {
|
||||
inputData: (data) => data
|
||||
})
|
||||
|
||||
export const getEmailHistory = createApi('GET', baseUrl + '/{id}/emailHistory', {
|
||||
urlData: (payload, receiverId) => ({id: receiverId}),
|
||||
inputData: data => data
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
const baseUrl = '/api/v1/recipients'
|
||||
|
||||
export const getItems = createApi('GET', baseUrl, {
|
||||
inputData: (data) => data
|
||||
})
|
||||
|
||||
export const createItem = createApi('POST', baseUrl)
|
||||
|
||||
export const updateItem = createApi('PUT', baseUrl + '/{recipientId}', {
|
||||
urlData: (data, recipientId) => ({recipientId})
|
||||
})
|
||||
|
||||
export const deleteItems = createApi('POST', baseUrl + '/delete')
|
||||
|
||||
export const activateItems = createApi('PUT', baseUrl + '/active')
|
||||
@@ -0,0 +1,72 @@
|
||||
import axios from 'axios';
|
||||
import appConfig from '../../appConfig';
|
||||
import {
|
||||
get,
|
||||
handleError,
|
||||
handleResponse,
|
||||
post
|
||||
} from '../httpInterceptor/httpInterceptor';
|
||||
import { getHPContext } from '../../common/helper';
|
||||
import { hubspotBaseURL } from '../../common/constants';
|
||||
|
||||
export const getPlans = async () => {
|
||||
const url = '/security/plans';
|
||||
const res = await get(url, null, true, null, true);
|
||||
console.log('API Response :: getPlans ::: ', res);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updatePrice = async (data) => {
|
||||
let url = '/security/cost_calculation';
|
||||
const res = await post(url, data, true, null, true);
|
||||
console.log('API Response :: updatePrice ::: ', res);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const registerUser = async (data) => {
|
||||
let url = '/security/registration';
|
||||
const res = await post(url, data, true, null, true);
|
||||
console.log('API Response :: registerUser ::: ', res);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const activeAccount = async (token) => {
|
||||
let url = `/security/registration/confirm/${token}`;
|
||||
const res = await post(url, undefined, true, null, true);
|
||||
console.log('API Response :: activeAccount ::: ', res);
|
||||
return res;
|
||||
};
|
||||
|
||||
// submit data for form API
|
||||
export const submitHubspot = (data) => {
|
||||
const { hubSpotportalID } = appConfig;
|
||||
if (!hubSpotportalID) {
|
||||
return Promise.resolve('No IDs');
|
||||
}
|
||||
|
||||
const hubSpotFormURL = `${hubspotBaseURL}/070e31d4-8e6d-480d-89b2-872a6bb28ff4`;
|
||||
const hubSpotMapping = {
|
||||
email: 'email',
|
||||
firstName: 'firstname',
|
||||
lastName: 'lastname',
|
||||
companyName: 'company',
|
||||
jobFunction: 'job_function',
|
||||
numberOfEmployee: 'numemployees',
|
||||
industry: 'industry',
|
||||
websiteUrl: 'website',
|
||||
lifecyclestage: 'lifecyclestage'
|
||||
};
|
||||
|
||||
const newObj = Object.keys(hubSpotMapping).map((key) => ({
|
||||
name: hubSpotMapping[key],
|
||||
value: data[key]
|
||||
}));
|
||||
|
||||
return axios
|
||||
.post(hubSpotFormURL, {
|
||||
fields: newObj,
|
||||
context: getHPContext()
|
||||
})
|
||||
.then((response) => handleResponse(response))
|
||||
.catch((error) => handleError(error));
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
const root = '/security/registration'
|
||||
|
||||
export const getBillingPlans = createApi('GET', `${root}/plans`)
|
||||
|
||||
export const sendRegistrationRequest = createApi('POST', root)
|
||||
|
||||
export const finishRegistration = createApi('POST', `${root}/finish`)
|
||||
|
||||
export const autocompleteOrganizationName = createApi('GET', `${root}/organizationAutocomplete`, {
|
||||
inputData: (organizationName) => ({organizationName})
|
||||
})
|
||||
|
||||
export const requestPasswordReset = createApi('POST', '/security/resetting/request')
|
||||
export const confirmPasswordReset = createApi('POST', '/security/resetting/confirm')
|
||||
@@ -0,0 +1,85 @@
|
||||
import axios from 'axios'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import appConfig from '../appConfig'
|
||||
import {createApi} from '../common/Common'
|
||||
import { hubspotBaseURL } from '../common/constants'
|
||||
import { getHPContext } from '../common/helper'
|
||||
import { handleError, handleResponse } from './httpInterceptor/httpInterceptor'
|
||||
|
||||
const slRoot = '/api/v1/source-list'
|
||||
|
||||
export const searchQuery = createApi('POST', '/api/v1/query/search', {})
|
||||
|
||||
export const searchSources = createApi('POST', '/api/v1/source-index/', {})
|
||||
|
||||
export const addSourcesToLists = createApi('POST', '/api/v1/source-index/add-to-sources-list', {})
|
||||
|
||||
export const replaceSourceListsForSource = createApi('POST', '/api/v1/source-index/{id}/list', {
|
||||
urlData: (params) => ({id: params.id}),
|
||||
inputData: (params) => JSON.stringify({sourceLists: params.sourceLists})
|
||||
})
|
||||
|
||||
export const getSourceLists = createApi('POST', `${slRoot}/list`, {})
|
||||
|
||||
export const addSourceLists = createApi('POST', `${slRoot}/`, {
|
||||
inputData: (name) => JSON.stringify({name})
|
||||
})
|
||||
|
||||
export const renameSourceLists = createApi('PUT', `${slRoot}/{id}`, {
|
||||
urlData: (params) => ({id: params.id}),
|
||||
inputData: (params) => JSON.stringify({name: params.name})
|
||||
})
|
||||
|
||||
export const cloneSourceLists = createApi('POST', `${slRoot}/{id}/clone`, {
|
||||
urlData: (params) => ({id: params.id}),
|
||||
inputData: (params) => JSON.stringify({name: params.name})
|
||||
})
|
||||
|
||||
export const deleteSourceLists = createApi('DELETE', `${slRoot}/{id}`, {
|
||||
urlData: (id) => ({id}),
|
||||
inputData: () => {}
|
||||
})
|
||||
|
||||
export const getSourcesOfList = createApi('POST', `${slRoot}/{id}/sources/search`, {
|
||||
urlData: (data, id) => ({id})
|
||||
})
|
||||
|
||||
export const shareSourceList = createApi('POST', `${slRoot}/{id}/share`, {
|
||||
urlData: (id) => ({id}),
|
||||
inputData: () => null
|
||||
})
|
||||
export const unshareSourceList = createApi('POST', `${slRoot}/{id}/unshare`, {
|
||||
urlData: (id) => ({id}),
|
||||
inputData: () => null
|
||||
})
|
||||
|
||||
// submit search queries to Hubspot form API for free user
|
||||
export const submitSearchHubspot = (dataObj) => {
|
||||
const { hubSpotportalID } = appConfig;
|
||||
if (!hubSpotportalID) {
|
||||
return Promise.resolve('No IDs');
|
||||
}
|
||||
|
||||
const data = cloneDeep(dataObj);
|
||||
const hubSpotFormURL = `${hubspotBaseURL}/3f297902-d32d-44bb-89a6-12af1c7b886e`;
|
||||
const hubSpotMapping = {
|
||||
email: 'email',
|
||||
searchquery: 'searchquery'
|
||||
// raw_query: 'raw_query'
|
||||
};
|
||||
|
||||
const newObj = Object.keys(hubSpotMapping)
|
||||
.filter((key) => data[key])
|
||||
.map((key) => ({
|
||||
name: hubSpotMapping[key],
|
||||
value: data[key]
|
||||
}));
|
||||
|
||||
return axios
|
||||
.post(hubSpotFormURL, {
|
||||
fields: newObj,
|
||||
context: getHPContext()
|
||||
})
|
||||
.then((response) => handleResponse(response))
|
||||
.catch((error) => handleError(error));
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
export const getCategories = createApi('GET', '/api/v1/categories')
|
||||
|
||||
//payload = {name, parent}
|
||||
export const addCategory = createApi('POST', '/api/v1/categories', {
|
||||
urlData: (payload, feedId) => ({feedId})
|
||||
})
|
||||
|
||||
//payload = {name, parent}
|
||||
export const renameCategory = createApi('PUT', '/api/v1/categories/{categoryId}', {
|
||||
urlData: (payload, categoryId) => ({categoryId})
|
||||
})
|
||||
|
||||
export const moveCategory = createApi('POST', '/api/v1/categories/{categoryId}/move_to/{newCategoryId}', {
|
||||
urlData: (payload, categoryId, newCategoryId) => ({categoryId, newCategoryId})
|
||||
})
|
||||
|
||||
//payload = {name, parent}
|
||||
export const deleteCategory = createApi('DELETE', '/api/v1/categories/{categoryId}', {
|
||||
urlData: (payload, categoryId) => ({categoryId})
|
||||
})
|
||||
@@ -0,0 +1,7 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
const baseUrl = '/api/v1/notifications/themes'
|
||||
|
||||
export const getDefaultItem = createApi('GET', baseUrl + '/default', {
|
||||
inputData: (data) => data
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
import {createApi} from '../common/Common'
|
||||
|
||||
const root = '/api/v1/users'
|
||||
|
||||
export const changePassword = createApi('POST', `${root}/change-password`)
|
||||
Reference in New Issue
Block a user