mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Klicktipp has two single optin apikeys one for en and one for de so we need to get the information of the language in the creation query.
This commit is contained in:
parent
037bf1815d
commit
c4345489c5
@ -30,8 +30,8 @@ export class KlicktippConnector {
|
|||||||
* @return TRUE on success
|
* @return TRUE on success
|
||||||
*/
|
*/
|
||||||
async login(username: string, password: string): Promise<boolean> {
|
async login(username: string, password: string): Promise<boolean> {
|
||||||
if (!(username && password)) {
|
if (!(username.length > 0 && password.length > 0)) {
|
||||||
throw new Error('Login failed: Illegal Arguments')
|
throw new Error('Klicktipp Login failed: Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await this.httpRequest('/account/login', 'POST', { username, password }, false)
|
const res = await this.httpRequest('/account/login', 'POST', { username, password }, false)
|
||||||
@ -43,7 +43,7 @@ export class KlicktippConnector {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Login failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Login failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,7 @@ export class KlicktippConnector {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Logout failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Logout failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +76,7 @@ export class KlicktippConnector {
|
|||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Subscription process index failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscription process index failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,7 +88,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async subscriptionProcessGet(listid: string): Promise<any> {
|
async subscriptionProcessGet(listid: string): Promise<any> {
|
||||||
if (!listid || listid === '') {
|
if (!listid || listid === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve
|
// retrieve
|
||||||
@ -98,7 +98,7 @@ export class KlicktippConnector {
|
|||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Subscription process get failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscription process get failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +111,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async subscriptionProcessRedirect(listid: string, email: string): Promise<any> {
|
async subscriptionProcessRedirect(listid: string, email: string): Promise<any> {
|
||||||
if (!listid || listid === '' || !email || email === '') {
|
if (!listid || listid === '' || !email || email === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
@ -122,7 +122,9 @@ export class KlicktippConnector {
|
|||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Subscription process get redirection url failed: ${res.response.statusText}`)
|
throw new Error(
|
||||||
|
`Klicktipp Subscription process get redirection url failed: ${res.response.statusText}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +139,7 @@ export class KlicktippConnector {
|
|||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Tag index failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Tag index failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,7 +151,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async tagGet(tagid: string): Promise<any> {
|
async tagGet(tagid: string): Promise<any> {
|
||||||
if (!tagid || tagid === '') {
|
if (!tagid || tagid === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
const res = await this.httpRequest(`/tag/${tagid}`)
|
const res = await this.httpRequest(`/tag/${tagid}`)
|
||||||
|
|
||||||
@ -157,7 +159,7 @@ export class KlicktippConnector {
|
|||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Tag get failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Tag get failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,7 +172,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async tagCreate(name: string, text?: string): Promise<boolean> {
|
async tagCreate(name: string, text?: string): Promise<boolean> {
|
||||||
if (!name || name === '') {
|
if (!name || name === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
name,
|
name,
|
||||||
@ -182,7 +184,7 @@ export class KlicktippConnector {
|
|||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Tag creation failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Tag creation failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,7 +198,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async tagUpdate(tagid: string, name?: string, text?: string): Promise<boolean> {
|
async tagUpdate(tagid: string, name?: string, text?: string): Promise<boolean> {
|
||||||
if (!tagid || tagid === '' || (name === '' && text === '')) {
|
if (!tagid || tagid === '' || (name === '' && text === '')) {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
name: name !== undefined ? name : '',
|
name: name !== undefined ? name : '',
|
||||||
@ -209,7 +211,7 @@ export class KlicktippConnector {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Tag update failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Tag update failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,7 +223,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async tagDelete(tagid: string): Promise<boolean> {
|
async tagDelete(tagid: string): Promise<boolean> {
|
||||||
if (!tagid || tagid === '') {
|
if (!tagid || tagid === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await this.httpRequest(`/tag/${tagid}`, 'DELETE')
|
const res = await this.httpRequest(`/tag/${tagid}`, 'DELETE')
|
||||||
@ -230,7 +232,7 @@ export class KlicktippConnector {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Tag deletion failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Tag deletion failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -245,7 +247,7 @@ export class KlicktippConnector {
|
|||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Field index failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Field index failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -282,7 +284,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
throw new Error(`Subscription failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscription failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -294,7 +296,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async unsubscribe(email: string): Promise<boolean> {
|
async unsubscribe(email: string): Promise<boolean> {
|
||||||
if (!email || email === '') {
|
if (!email || email === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsubscribe
|
// unsubscribe
|
||||||
@ -305,7 +307,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
throw new Error(`Unsubscription failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Unsubscription failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,7 +320,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async tag(email: string, tagids: string): Promise<boolean> {
|
async tag(email: string, tagids: string): Promise<boolean> {
|
||||||
if (!email || email === '' || !tagids || tagids === '') {
|
if (!email || email === '' || !tagids || tagids === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// tag
|
// tag
|
||||||
@ -332,7 +334,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
throw new Error(`Tagging failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Tagging failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -345,7 +347,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async untag(email: string, tagid: string): Promise<boolean> {
|
async untag(email: string, tagid: string): Promise<boolean> {
|
||||||
if (!email || email === '' || !tagid || tagid === '') {
|
if (!email || email === '' || !tagid || tagid === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// subscribe
|
// subscribe
|
||||||
@ -359,7 +361,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
throw new Error(`Untagging failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Untagging failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -372,7 +374,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async resend(email: string, autoresponder: string): Promise<boolean> {
|
async resend(email: string, autoresponder: string): Promise<boolean> {
|
||||||
if (!email || email === '' || !autoresponder || autoresponder === '') {
|
if (!email || email === '' || !autoresponder || autoresponder === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// resend/reset autoresponder
|
// resend/reset autoresponder
|
||||||
@ -383,7 +385,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
throw new Error(`Resend failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Resend failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -397,7 +399,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
throw new Error(`Subscriber index failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscriber index failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -409,7 +411,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async subscriberGet(subscriberid: string): Promise<any> {
|
async subscriberGet(subscriberid: string): Promise<any> {
|
||||||
if (!subscriberid || subscriberid === '') {
|
if (!subscriberid || subscriberid === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve
|
// retrieve
|
||||||
@ -417,7 +419,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
throw new Error(`Subscriber get failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscriber get failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -429,7 +431,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async subscriberSearch(email: string): Promise<any> {
|
async subscriberSearch(email: string): Promise<any> {
|
||||||
if (!email || email === '') {
|
if (!email || email === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
// search
|
// search
|
||||||
const data = { email }
|
const data = { email }
|
||||||
@ -438,7 +440,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
throw new Error(`Subscriber search failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscriber search failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -450,7 +452,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async subscriberTagged(tagid: string): Promise<any> {
|
async subscriberTagged(tagid: string): Promise<any> {
|
||||||
if (!tagid || tagid === '') {
|
if (!tagid || tagid === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// search
|
// search
|
||||||
@ -460,7 +462,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
throw new Error(`subscriber tagged failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp subscriber tagged failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -479,7 +481,7 @@ export class KlicktippConnector {
|
|||||||
newsmsnumber?: string,
|
newsmsnumber?: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (!subscriberid || subscriberid === '') {
|
if (!subscriberid || subscriberid === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
@ -492,7 +494,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
throw new Error(`Subscriber update failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscriber update failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -504,7 +506,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async subscriberDelete(subscriberid: string): Promise<boolean> {
|
async subscriberDelete(subscriberid: string): Promise<boolean> {
|
||||||
if (!subscriberid || subscriberid === '') {
|
if (!subscriberid || subscriberid === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
@ -513,7 +515,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
throw new Error(`Subscriber deletion failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscriber deletion failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -527,7 +529,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async signin(apikey: string, email: string, fields?: any, smsnumber?: string): Promise<boolean> {
|
async signin(apikey: string, email: string, fields?: any, smsnumber?: string): Promise<boolean> {
|
||||||
if (!apikey || apikey === '' || ((!email || email === '') && smsnumber === '')) {
|
if (!apikey || apikey === '' || ((!email || email === '') && smsnumber === '')) {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// subscribe
|
// subscribe
|
||||||
@ -543,7 +545,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
throw new Error(`Subscription failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Subscription failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -556,7 +558,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async signout(apikey: string, email: string): Promise<boolean> {
|
async signout(apikey: string, email: string): Promise<boolean> {
|
||||||
if (!apikey || apikey === '' || !email || email === '') {
|
if (!apikey || apikey === '' || !email || email === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// untag
|
// untag
|
||||||
@ -566,7 +568,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
throw new Error(`Untagging failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Untagging failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -579,7 +581,7 @@ export class KlicktippConnector {
|
|||||||
*/
|
*/
|
||||||
async signoff(apikey: string, email: string): Promise<boolean> {
|
async signoff(apikey: string, email: string): Promise<boolean> {
|
||||||
if (!apikey || apikey === '' || !email || email === '') {
|
if (!apikey || apikey === '' || !email || email === '') {
|
||||||
throw new Error('Illegal Arguments')
|
throw new Error('Klicktipp Illegal Arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsubscribe
|
// unsubscribe
|
||||||
@ -589,7 +591,7 @@ export class KlicktippConnector {
|
|||||||
if (!res.isAxiosError) {
|
if (!res.isAxiosError) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
throw new Error(`Unsubscription failed: ${res.response.statusText}`)
|
throw new Error(`Klicktipp Unsubscription failed: ${res.response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async httpRequest(path: string, method?: Method, data?: any, usesession?: boolean): Promise<any> {
|
async httpRequest(path: string, method?: Method, data?: any, usesession?: boolean): Promise<any> {
|
||||||
|
|||||||
@ -13,8 +13,9 @@ const server = {
|
|||||||
GDT_API_URL: process.env.GDT_API_URL || 'https://gdt.gradido.net',
|
GDT_API_URL: process.env.GDT_API_URL || 'https://gdt.gradido.net',
|
||||||
KLICKTTIPP_API_URL: process.env.KLICKTIPP_API_URL || 'https://api.klicktipp.com',
|
KLICKTTIPP_API_URL: process.env.KLICKTIPP_API_URL || 'https://api.klicktipp.com',
|
||||||
KLICKTIPP_USER: process.env.KLICKTIPP_USER || 'mbaier-heinehannes',
|
KLICKTIPP_USER: process.env.KLICKTIPP_USER || 'mbaier-heinehannes',
|
||||||
KLICKTIPP_PASSWORD: process.env.KLICKTIPP_PASSWORD || 'secret321',
|
KLICKTIPP_PASSWORD: process.env.KLICKTIPP_PASSWORD || 'Ynq9m8HCP',
|
||||||
KLICKTIPP_APIKEY: process.env.KLICKTIPP_APIKEY || '',
|
KLICKTIPP_APIKEY_DE: process.env.KLICKTIPP_APIKEY_DE || '4vgozlkpz8z726a',
|
||||||
|
KLICKTIPP_APIKEY_EN: process.env.KLICKTIPP_APIKEY_EN || '4vgpzlkpz8zb79c',
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is needed by graphql-directive-auth
|
// This is needed by graphql-directive-auth
|
||||||
|
|||||||
@ -22,6 +22,9 @@ export class CreateUserArgs {
|
|||||||
|
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
password: string
|
password: string
|
||||||
|
|
||||||
|
@Field(() => String)
|
||||||
|
language: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Resolver, Query, /* Mutation, */ Arg } from 'type-graphql'
|
import { Resolver, Query, /* Mutation, */ Arg } from 'type-graphql'
|
||||||
import CONFIG from '../../config'
|
import CONFIG from '../../config'
|
||||||
import { Balance } from '../models/Balance'
|
import { Balance } from '../models/Balance'
|
||||||
import { apiGet } from '../../apis/loginAPI'
|
import { apiGet } from '../../apis/HttpRequest'
|
||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
export class BalanceResolver {
|
export class BalanceResolver {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { Resolver, Query, /* Mutation, */ Args } from 'type-graphql'
|
|||||||
import CONFIG from '../../config'
|
import CONFIG from '../../config'
|
||||||
import { GdtEntryList } from '../models/GdtEntryList'
|
import { GdtEntryList } from '../models/GdtEntryList'
|
||||||
import { GdtTransactionSessionIdInput } from '../inputs/GdtInputs'
|
import { GdtTransactionSessionIdInput } from '../inputs/GdtInputs'
|
||||||
import { apiGet } from '../../apis/loginAPI'
|
import { apiGet } from '../../apis/HttpRequest'
|
||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
export class GdtResolver {
|
export class GdtResolver {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import {
|
|||||||
UnsecureLoginArgs,
|
UnsecureLoginArgs,
|
||||||
UpdateUserInfosArgs,
|
UpdateUserInfosArgs,
|
||||||
} from '../inputs/LoginUserInput'
|
} from '../inputs/LoginUserInput'
|
||||||
import { apiPost, apiGet } from '../../apis/loginAPI'
|
import { apiPost, apiGet } from '../../apis/HttpRequest'
|
||||||
import { KlicktippConnector } from '../../apis/klicktippAPI'
|
import { KlicktippConnector } from '../../apis/klicktippAPI'
|
||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
@ -73,7 +73,9 @@ export class UserResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Query(() => String)
|
@Query(() => String)
|
||||||
async create(@Args() { email, firstName, lastName, password }: CreateUserArgs): Promise<string> {
|
async create(
|
||||||
|
@Args() { email, firstName, lastName, password, language }: CreateUserArgs,
|
||||||
|
): Promise<string> {
|
||||||
const payload = {
|
const payload = {
|
||||||
email,
|
email,
|
||||||
first_name: firstName,
|
first_name: firstName,
|
||||||
@ -87,19 +89,16 @@ export class UserResolver {
|
|||||||
throw new Error(result.data)
|
throw new Error(result.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const loginSuccessful = await this.connector.login(
|
// const loginSuccessful = await this.connector.login(
|
||||||
CONFIG.KLICKTIPP_USER,
|
// CONFIG.KLICKTIPP_USER,
|
||||||
CONFIG.KLICKTIPP_PASSWORD,
|
// CONFIG.KLICKTIPP_PASSWORD,
|
||||||
)
|
// )
|
||||||
if (loginSuccessful) {
|
// if (loginSuccessful) {
|
||||||
const fields = {}
|
const fields = {}
|
||||||
const success = await this.connector.signin(CONFIG.KLICKTIPP_APIKEY, email, fields)
|
const apiKey = language === 'de' ? CONFIG.KLICKTIPP_APIKEY_DE : CONFIG.KLICKTIPP_APIKEY_EN
|
||||||
if (!success) {
|
await this.connector.signin(apiKey, email, fields)
|
||||||
throw new Error(`Signin to KlickTipp has failed ${this.connector.getLastError()}`)
|
// }
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new Error(`Could not login to Klicktipp ${this.connector.getLastError()}`)
|
|
||||||
}
|
|
||||||
return 'success'
|
return 'success'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,8 +97,20 @@ export const transactionsQuery = gql`
|
|||||||
`
|
`
|
||||||
|
|
||||||
export const resgisterUserQuery = gql`
|
export const resgisterUserQuery = gql`
|
||||||
query($firstName: String!, $lastName: String!, $email: String!, $password: String!) {
|
query (
|
||||||
create(email: $email, firstName: $firstName, lastName: $lastName, password: $password)
|
$firstName: String!
|
||||||
|
$lastName: String!
|
||||||
|
$email: String!
|
||||||
|
$password: String!
|
||||||
|
$language: String!
|
||||||
|
) {
|
||||||
|
create(
|
||||||
|
email: $email
|
||||||
|
firstName: $firstName
|
||||||
|
lastName: $lastName
|
||||||
|
password: $password
|
||||||
|
language: $language
|
||||||
|
)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,11 @@ describe('Register', () => {
|
|||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const mocks = {
|
const mocks = {
|
||||||
|
$store: {
|
||||||
|
state: {
|
||||||
|
language: 'de',
|
||||||
|
},
|
||||||
|
},
|
||||||
$i18n: {
|
$i18n: {
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
},
|
},
|
||||||
@ -214,6 +219,7 @@ describe('Register', () => {
|
|||||||
firstName: 'Max',
|
firstName: 'Max',
|
||||||
lastName: 'Mustermann',
|
lastName: 'Mustermann',
|
||||||
password: 'Aa123456',
|
password: 'Aa123456',
|
||||||
|
language: 'de',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -183,6 +183,7 @@ export default {
|
|||||||
firstName: this.form.firstname,
|
firstName: this.form.firstname,
|
||||||
lastName: this.form.lastname,
|
lastName: this.form.lastname,
|
||||||
password: this.form.password.password,
|
password: this.form.password.password,
|
||||||
|
language: this.$store.state.language,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user