From c200a8f2816394a233cb39fd06c667821e13bedb Mon Sep 17 00:00:00 2001 From: Kariamos Date: Thu, 17 Oct 2024 18:46:12 +0200 Subject: [PATCH] feat: Updateapi and schema.ts to use new language package --- src/services/tryberApi/index.ts | 140 +++++++++++++------------------- src/utils/schema.ts | 110 ++++++++++++++----------- 2 files changed, 119 insertions(+), 131 deletions(-) diff --git a/src/services/tryberApi/index.ts b/src/services/tryberApi/index.ts index 5cc496e2..4888d9f4 100644 --- a/src/services/tryberApi/index.ts +++ b/src/services/tryberApi/index.ts @@ -1464,34 +1464,8 @@ export type PutCampaignsByCampaignTasksAndTaskApiArg = { }; export type GetCampaignsByCampaignUxApiResponse = /** status 200 A UseCase linked with the Campaign */ { - status: "draft" | "published" | "draft-modified"; goal: string; usersNumber: number; - insights?: { - id: number; - title: string; - severity: { - id: number; - name: string; - }; - description: string; - clusters: - | "all" - | { - id: number; - name: string; - }[]; - videoParts: { - id: number; - start: number; - end: number; - mediaId: number; - url: string; - streamUrl: string; - description: string; - poster?: string; - }[]; - }[]; sentiments: { id: number; value: number; @@ -1510,6 +1484,7 @@ export type GetCampaignsByCampaignUxApiResponse = id: number; name: string; }[]; + visible: number; }; export type GetCampaignsByCampaignUxApiArg = { /** A campaign id */ @@ -1519,44 +1494,25 @@ export type PatchCampaignsByCampaignUxApiResponse = /** status 200 OK */ {}; export type PatchCampaignsByCampaignUxApiArg = { /** A campaign id */ campaign: string; - body: - | { - goal: string; - usersNumber: number; - insights: { - id?: number; - title: string; - description: string; - severityId: number; - order: number; - clusterIds: number[] | "all"; - videoParts: { - id?: number; - start: number; - end: number; - mediaId: number; - description: string; - order: number; - }[]; - }[]; - sentiments: { - id?: number; - clusterId: number; - value: number; - comment: string; - }[]; - methodology: { - type: "qualitative" | "quantitative" | "quali-quantitative"; - description: string; - }; - questions: { - id?: number; - name: string; - }[]; - } - | { - status: "publish"; - }; + body: { + goal?: string; + usersNumber?: number; + visible?: number; + methodology?: { + description: string; + type: string; + }; + sentiments?: { + clusterId: number; + value: number; + comment: string; + id?: number; + }[]; + questions?: { + name: string; + id?: number; + }[]; + }; }; export type PostCampaignsFormsApiResponse = /** status 201 Created */ { id: number; @@ -1899,7 +1855,6 @@ export type GetUsersMeApiResponse = /** status 200 OK */ { gross: Currency; }; languages?: { - id?: number; name?: string; }[]; onboarding_completed?: boolean; @@ -2173,7 +2128,9 @@ export type GetUsersMeCampaignsByCampaignIdDevicesApiArg = { campaignId: string; }; export type GetUsersMeCampaignsByCampaignIdFormsApiResponse = - /** status 200 OK */ (PreselectionFormQuestion & { + /** status 200 OK */ ({ + question: string; + short_name?: string; value?: | number | { @@ -2187,7 +2144,19 @@ export type GetUsersMeCampaignsByCampaignIdFormsApiResponse = error?: string; }; id: number; - })[]; + } & ( + | { + type: PreselectionQuestionSimple; + } + | { + type: PreselectionQuestionMultiple; + options: string[]; + } + | { + type: PreselectionQuestionCuf; + options?: number[]; + } + ))[]; export type GetUsersMeCampaignsByCampaignIdFormsApiArg = { campaignId: string; }; @@ -2412,20 +2381,18 @@ export type PutUsersMeFiscalApiArg = { }; }; export type PostUsersMeLanguagesApiResponse = /** status 201 Created */ { - id: string; name: string; }; export type PostUsersMeLanguagesApiArg = { body: { - languageId?: number; + language_name?: string; }; }; export type PutUsersMeLanguagesApiResponse = /** status 200 OK */ { - id?: number; name?: string; }[]; export type PutUsersMeLanguagesApiArg = { - body: number[]; + body: string[]; }; export type DeleteUsersMeLanguagesByLanguageIdApiResponse = /** status 200 OK */ { @@ -2670,7 +2637,6 @@ export type GetDossiersByCampaignApiResponse = /** status 200 OK */ { }; countries?: CountryCode[]; languages?: { - id: number; name: string; }[]; browsers?: { @@ -2872,25 +2838,33 @@ export type TaskRequired = { campaign_id: number; }; export type Task = TaskOptional & TaskRequired; +export type PreselectionQuestionSimple = + | "gender" + | "text" + | "phone_number" + | "address"; +export type PreselectionQuestionMultiple = "multiselect" | "select" | "radio"; +export type PreselectionQuestionCuf = string; export type PreselectionFormQuestion = { question: string; short_name?: string; } & ( | { - type: "text"; - } - | { - type: "multiselect" | "select" | "radio"; - options: string[]; - invalidOptions?: string[]; + type: PreselectionQuestionSimple; } | { - type: string; - options?: number[]; - invalidOptions?: number[]; + type: PreselectionQuestionMultiple; + options?: { + value: string; + isInvalid?: boolean; + }[]; } | { - type: "gender" | "phone_number" | "address"; + type: PreselectionQuestionCuf; + options?: { + value: number; + isInvalid?: boolean; + }[]; } ); export type CustomUserFieldsType = "text" | "select" | "multiselect"; @@ -3044,7 +3018,7 @@ export type DossierCreationData = { cap?: number; }; countries?: CountryCode[]; - languages?: number[]; + languages?: string[]; browsers?: number[]; productType?: number; notes?: string; diff --git a/src/utils/schema.ts b/src/utils/schema.ts index 393a1339..507b30bc 100644 --- a/src/utils/schema.ts +++ b/src/utils/schema.ts @@ -805,23 +805,21 @@ export interface components { short_name?: string; } & ( | { - /** @enum {string} */ - type: "text"; + type: components["schemas"]["PreselectionQuestionSimple"]; } | { - /** @enum {string} */ - type: "multiselect" | "select" | "radio"; - options: string[]; - invalidOptions?: string[]; - } - | { - type: string; - options?: number[]; - invalidOptions?: number[]; + type: components["schemas"]["PreselectionQuestionMultiple"]; + options?: { + value: string; + isInvalid?: boolean; + }[]; } | { - /** @enum {string} */ - type: "gender" | "phone_number" | "address"; + type: components["schemas"]["PreselectionQuestionCuf"]; + options?: { + value: number; + isInvalid?: boolean; + }[]; } ); /** Project */ @@ -942,11 +940,23 @@ export interface components { cap?: number; }; countries?: components["schemas"]["CountryCode"][]; - languages?: number[]; + languages?: string[]; browsers?: number[]; productType?: number; notes?: string; }; + /** + * PreselectionQuestionSimple + * @enum {string} + */ + PreselectionQuestionSimple: "gender" | "text" | "phone_number" | "address"; + /** + * PreselectionQuestionMultiple + * @enum {string} + */ + PreselectionQuestionMultiple: "multiselect" | "select" | "radio"; + /** PreselectionQuestionCuf */ + PreselectionQuestionCuf: string; }; responses: { /** A user */ @@ -1966,8 +1976,6 @@ export interface operations { 200: { content: { "application/json": { - /** @enum {string} */ - status: "draft" | "published" | "draft-modified"; goal: string; usersNumber: number; sentiments: { @@ -1989,6 +1997,7 @@ export interface operations { id: number; name: string; }[]; + visible: number; }; }; }; @@ -2015,30 +2024,25 @@ export interface operations { }; requestBody: { content: { - "application/json": - | { - goal: string; - usersNumber: number; - sentiments: { - id?: number; - clusterId: number; - value: number; - comment: string; - }[]; - methodology: { - /** @enum {string} */ - type: "qualitative" | "quantitative" | "quali-quantitative"; - description: string; - }; - questions: { - id?: number; - name: string; - }[]; - } - | { - /** @enum {string} */ - status: "publish"; - }; + "application/json": { + goal?: string; + usersNumber?: number; + visible?: number; + methodology?: { + description: string; + type: string; + }; + sentiments?: { + clusterId: number; + value: number; + comment: string; + id?: number; + }[]; + questions?: { + name: string; + id?: number; + }[]; + }; }; }; }; @@ -2863,7 +2867,6 @@ export interface operations { gross: components["schemas"]["Currency"]; }; languages?: { - id?: number; name?: string; }[]; onboarding_completed?: boolean; @@ -3305,7 +3308,9 @@ export interface operations { /** OK */ 200: { content: { - "application/json": (components["schemas"]["PreselectionFormQuestion"] & { + "application/json": ({ + question: string; + short_name?: string; value?: | number | { @@ -3319,7 +3324,19 @@ export interface operations { error?: string; }; id: number; - })[]; + } & ( + | { + type: components["schemas"]["PreselectionQuestionSimple"]; + } + | { + type: components["schemas"]["PreselectionQuestionMultiple"]; + options: string[]; + } + | { + type: components["schemas"]["PreselectionQuestionCuf"]; + options?: number[]; + } + ))[]; }; }; 403: components["responses"]["NotAuthorized"]; @@ -3758,7 +3775,6 @@ export interface operations { 200: { content: { "application/json": { - id?: number; name?: string; }[]; }; @@ -3767,7 +3783,7 @@ export interface operations { }; requestBody: { content: { - "application/json": number[]; + "application/json": string[]; }; }; }; @@ -3778,7 +3794,6 @@ export interface operations { 201: { content: { "application/json": { - id: string; name: string; }; }; @@ -3788,7 +3803,7 @@ export interface operations { requestBody: { content: { "application/json": { - languageId?: number; + language_name?: string; }; }; }; @@ -4195,7 +4210,6 @@ export interface operations { }; countries?: components["schemas"]["CountryCode"][]; languages?: { - id: number; name: string; }[]; browsers?: {