mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Refactor klicktippcontroller to not call function
This commit is contained in:
parent
8be1278770
commit
b2f0bf37d2
@ -15,6 +15,9 @@ export const klicktippSignIn = async (
|
||||
firstName?: string,
|
||||
lastName?: string,
|
||||
): Promise<boolean> => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return true
|
||||
}
|
||||
const fields = {
|
||||
fieldFirstName: firstName,
|
||||
fieldLastName: lastName,
|
||||
@ -25,12 +28,18 @@ export const klicktippSignIn = async (
|
||||
}
|
||||
|
||||
export const signout = async (email: string, language: string): Promise<boolean> => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return true
|
||||
}
|
||||
const apiKey = language === 'de' ? CONFIG.KLICKTIPP_APIKEY_DE : CONFIG.KLICKTIPP_APIKEY_EN
|
||||
const result = await klicktippConnector.signoff(apiKey, email)
|
||||
return result
|
||||
}
|
||||
|
||||
export const unsubscribe = async (email: string): Promise<boolean> => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return true
|
||||
}
|
||||
const isLogin = await loginKlicktippUser()
|
||||
if (isLogin) {
|
||||
return await klicktippConnector.unsubscribe(email)
|
||||
@ -39,6 +48,9 @@ export const unsubscribe = async (email: string): Promise<boolean> => {
|
||||
}
|
||||
|
||||
export const getKlickTippUser = async (email: string): Promise<any> => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return true
|
||||
}
|
||||
const isLogin = await loginKlicktippUser()
|
||||
if (isLogin) {
|
||||
const subscriberId = await klicktippConnector.subscriberSearch(email)
|
||||
@ -49,14 +61,23 @@ export const getKlickTippUser = async (email: string): Promise<any> => {
|
||||
}
|
||||
|
||||
export const loginKlicktippUser = async (): Promise<boolean> => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return true
|
||||
}
|
||||
return await klicktippConnector.login(CONFIG.KLICKTIPP_USER, CONFIG.KLICKTIPP_PASSWORD)
|
||||
}
|
||||
|
||||
export const logoutKlicktippUser = async (): Promise<boolean> => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return true
|
||||
}
|
||||
return await klicktippConnector.logout()
|
||||
}
|
||||
|
||||
export const untagUser = async (email: string, tagId: string): Promise<boolean> => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return true
|
||||
}
|
||||
const isLogin = await loginKlicktippUser()
|
||||
if (isLogin) {
|
||||
return await klicktippConnector.untag(email, tagId)
|
||||
@ -65,6 +86,9 @@ export const untagUser = async (email: string, tagId: string): Promise<boolean>
|
||||
}
|
||||
|
||||
export const tagUser = async (email: string, tagIds: string): Promise<boolean> => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return true
|
||||
}
|
||||
const isLogin = await loginKlicktippUser()
|
||||
if (isLogin) {
|
||||
return await klicktippConnector.tag(email, tagIds)
|
||||
@ -73,6 +97,9 @@ export const tagUser = async (email: string, tagIds: string): Promise<boolean> =
|
||||
}
|
||||
|
||||
export const getKlicktippTagMap = async () => {
|
||||
if (!CONFIG.KLICKTIPP) {
|
||||
return ''
|
||||
}
|
||||
const isLogin = await loginKlicktippUser()
|
||||
if (isLogin) {
|
||||
return await klicktippConnector.tagIndex()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user