w-aura/src/api/resources/Session.ts
Daniil Chemerkin 4b386ec849 hint-palm
2025-03-07 09:05:32 +00:00

185 lines
8.0 KiB
TypeScript

import routes from "@/routes";
import { getBaseHeaders } from "../utils";
import { IUTM } from "@/store/utm";
import { ICreateAuthorizeUser } from "./User";
import { ELocalesPlacement } from "@/locales";
export interface PayloadCreate {
feature: string, // Type: string
locale: string, // Type: string
timezone: string, // Type: string
source: string, // Type: string
sign: boolean, // Type: boolean
signDate: string | undefined, // Type: string, ISO Date
utm: IUTM // Type: { [key: string]: string } - Optional
}
export interface PayloadUpdate {
sessionId: string,
data: {
feature: string, // Type: string
profile?: Partial<ICreateAuthorizeUser>;
partner?: Partial<Exclude<ICreateAuthorizeUser, "relationship_status">>;
answers?: Partial<IAnswersSessionPalmistry | IAnswersSessionChats | IAnswersSessionCompatibilityV2>;
}
}
export interface IAnswersSessionPalmistry {
what_aspects: 'love_relationships' | 'health_vitality' | 'career_destiny' | 'life_transitions', // Type: string, optional - 'love_relationships' | 'health_vitality' | 'career_destiny';
relationship_status: 'single' | 'in_relationship' | 'engaged' | 'divorced' | 'complicated', // Type: string, optional - 'single' | 'in_relationship';
element_resonates: 'water' | 'fire' | 'air' | 'earth' | 'light' | 'darkness', // Type: string, optional - 'water' | 'fire' | 'air' | 'earth';
favorite_color: 'blue' | 'green' | 'orange' | 'violet' | 'red' | 'yellow' | 'turquoise', // Type: string, optional - 'blue' | 'green' | 'orange' | 'violet' | 'red' | 'yellow';
head_or_heart: 'head' | 'heart' | 'both' | 'depends', // Type: string, optional - 'head' | 'heart' | 'both';
time_alone: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
own_company: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
socializing_in_groups: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
loneliness_avoid: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
activities_independently: 1 | 2 | 3 | 4 | 5 // Type: number, optional - 1 | 2 | 3 | 4 | 5;
}
export interface IAnswersSessionCompatibilityV2 {
what_aspects: 'love_relationships' | 'health_vitality' | 'career_destiny' | 'life_transitions', // Type: string, optional - 'love_relationships' | 'health_vitality' | 'career_destiny';
relationship_status: 'single' | 'in_relationship' | 'engaged' | 'divorced' | 'complicated', // Type: string, optional - 'single' | 'in_relationship';
element_resonates: 'water' | 'fire' | 'air' | 'earth' | 'light' | 'darkness', // Type: string, optional - 'water' | 'fire' | 'air' | 'earth';
favorite_color: 'blue' | 'green' | 'orange' | 'violet' | 'red' | 'yellow' | 'turquoise', // Type: string, optional - 'blue' | 'green' | 'orange' | 'violet' | 'red' | 'yellow';
head_or_heart: 'head' | 'heart' | 'both' | 'depends', // Type: string, optional - 'head' | 'heart' | 'both';
time_alone: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
own_company: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
socializing_in_groups: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
loneliness_avoid: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
activities_independently: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
date_event: string; // Type: string, optional - ISO Date
partner_expectations: 1 | 2 | 3 | 4 | 5; // Type: number, optional - 1 | 2 | 3 | 4 | 5;
romantic_gestures: "love" | "neutral" | "dislike"; // Type: string, optional - "love" | "neutral" | "dislike";
checking_phone: "against" | "allow" | "normally"; // Type: string, optional - "against" | "allow" | "normally";
}
export interface IAnswersSessionCompatibilityV3 {
what_aspects: 'love_relationships' | 'health_vitality' | 'career_destiny' | 'life_transitions', // Type: string, optional - 'love_relationships' | 'health_vitality' | 'career_destiny';
relationship_status: 'single' | 'in_relationship' | 'engaged' | 'divorced' | 'complicated', // Type: string, optional - 'single' | 'in_relationship';
element_resonates: 'water' | 'fire' | 'air' | 'earth' | 'light' | 'darkness', // Type: string, optional - 'water' | 'fire' | 'air' | 'earth';
favorite_color: 'blue' | 'green' | 'orange' | 'violet' | 'red' | 'yellow' | 'turquoise', // Type: string, optional - 'blue' | 'green' | 'orange' | 'violet' | 'red' | 'yellow';
head_or_heart: 'head' | 'heart' | 'both' | 'depends', // Type: string, optional - 'head' | 'heart' | 'both';
time_alone: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
own_company: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
socializing_in_groups: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
loneliness_avoid: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
activities_independently: 1 | 2 | 3 | 4 | 5, // Type: number, optional - 1 | 2 | 3 | 4 | 5;
date_event: string; // Type: string, optional - ISO Date
partner_expectations: 1 | 2 | 3 | 4 | 5; // Type: number, optional - 1 | 2 | 3 | 4 | 5;
romantic_gestures: "love" | "neutral" | "dislike"; // Type: string, optional - "love" | "neutral" | "dislike";
checking_phone: "against" | "allow" | "normally"; // Type: string, optional - "against" | "allow" | "normally";
}
export interface IAnswersSessionChats {
psychicReading: string;
goal: string;
relationshipStatus: string;
satisfiedWithLife: string;
parentStatus: string;
whatEmotion: string;
whatYouWant: string;
missingInLife: string;
yourGoal: string;
somethingWorrying: string;
proneToOverthinking: string;
worriesImpact: string;
sensitiveToCriticism: string;
headOrHeart: string;
howConfident: string;
needGuidance: string;
decisionGuidance: string;
resonateLove: string;
resonateLife: string;
resonateFuture: string;
believeInSpirituality: string;
readingExperience: string;
interestedHowLong: string;
mainReason: string;
whatToExpect: string;
guidanceArea: string[];
psychicComfortable: string[];
userName: string;
}
export interface ResponseCreate {
status: "success" | string,
sessionId: string
}
export interface ResponseUpdate {
status: "success" | string,
message: "Session updated" | string
}
export interface ResponseGetLocale {
male: Record<string, string>
female: Record<string, string>
fallback: {
male: Record<string, string>,
female: Record<string, string>
}
}
export interface ResponseGetPixels {
status: "success" | string,
data: {
fb?: string[];
}
}
export const createRequest = (data: PayloadCreate) => {
const url = new URL(routes.server.createSession());
const body = JSON.stringify(data);
return new Request(url, {
method: "POST",
body,
headers: getBaseHeaders()
});
};
export const updateRequest = ({ data, sessionId }: PayloadUpdate) => {
const url = new URL(routes.server.updateSession(sessionId));
const body = JSON.stringify(data);
return new Request(url, {
method: "PATCH",
body,
headers: getBaseHeaders()
});
};
export interface PayloadGetLocale {
funnel: ELocalesPlacement,
locale: string
}
export const getLocaleRequest = (data: PayloadGetLocale) => {
const url = new URL(routes.server.getLocale());
const body = JSON.stringify(data);
return new Request(url, {
method: "POST",
body,
headers: getBaseHeaders()
});
};
export interface PayloadGetPixels {
domain: string;
source: string;
locale: string;
}
export const getPixelsRequest = ({ domain, source, locale }: PayloadGetPixels) => {
const url = new URL(routes.server.getPixels());
const query = new URLSearchParams({
domain,
source,
locale
});
url.search = query.toString();
return new Request(url, {
method: "GET",
headers: getBaseHeaders()
});
};