1 import type { CreateImportPayload, EASY_SWITCH_SOURCES, LaunchImportPayload, OAuthProps } from '../interface';
2 import { ImportType } from '../interface';
4 export const getTokens = () => ({
5 url: 'oauth-token/v1/tokens',
9 export const createToken = (
11 Products: ImportType[];
12 Source: EASY_SWITCH_SOURCES;
15 url: 'oauth-token/v1/tokens',
20 export const createSync = (importerID: string) => ({
21 url: 'importer/v1/sync',
23 data: { ImporterID: importerID, Product: 'Mail' },
26 export const getSyncList = () => ({
27 url: 'importer/v1/sync',
31 export const resumeSync = (syncId: string) => ({
32 url: `importer/v1/sync/${syncId}/resume`,
36 export const deleteSync = (syncId: String) => ({
37 url: `importer/v1/sync/${syncId}`,
41 export const createImport = (data: CreateImportPayload) => ({
42 url: 'importer/v1/importers',
47 export const getImport = (importerID: string) => ({
48 url: `importer/v1/importers/${importerID}`,
52 export const updateImport = (importerID: string, data: CreateImportPayload) => ({
53 url: `importer/v1/importers/${importerID}`,
58 export const startImportTask = (data: LaunchImportPayload) => ({
59 url: 'importer/v1/importers/start',
64 export const getImportsList = () => ({
65 url: 'importer/v1/importers',
69 export const getImportReportsList = () => ({
70 url: 'importer/v1/reports',
74 export const getMailImportData = (
80 url: `importer/v1/mail/importers/${importerID}`,
85 export const getAuthenticationMethod = (params: { Email: string }) => ({
86 url: 'importer/v1/mail/importers/authinfo',
91 export const getCalendarImportData = (importerID: string) => ({
92 url: `importer/v1/calendar/importers/${importerID}`,
96 export const getContactsImportData = (importerID: string) => ({
97 url: `importer/v1/contacts/importers/${importerID}`,
101 export const deleteImportReport = (reportID: string, importType: ImportType) => {
102 const method = 'delete';
104 switch (importType) {
105 case ImportType.MAIL:
106 return { url: `importer/v1/mail/importers/reports/${reportID}`, method };
107 case ImportType.CALENDAR:
108 return { url: `importer/v1/calendar/importers/reports/${reportID}`, method };
109 case ImportType.CONTACTS:
110 return { url: `importer/v1/contacts/importers/reports/${reportID}`, method };
114 export const cancelImport = (data: { ImporterID: string; Products: ImportType[] }) => ({
115 url: 'importer/v1/importers/cancel',
120 export const resumeImport = (data: { ImporterID: string; Products: ImportType[] }) => ({
121 url: 'importer/v1/importers/resume',
126 export const rollbackImport = (reportID: string, Products: ImportType[]) => ({
127 url: `importer/v1/reports/${reportID}/undo`,