From a9162b4e23183a6c4f986439673b8106ad0432b8 Mon Sep 17 00:00:00 2001 From: sinatragianpaolo Date: Wed, 14 Aug 2024 13:27:55 +0200 Subject: [PATCH] chore: update api and schema --- src/services/tryberApi/index.ts | 33 ++++++++++++++++++++++----- src/utils/schema.ts | 40 ++++++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/src/services/tryberApi/index.ts b/src/services/tryberApi/index.ts index 2eeb11ad..6299c2c0 100644 --- a/src/services/tryberApi/index.ts +++ b/src/services/tryberApi/index.ts @@ -2130,7 +2130,9 @@ export type GetUsersMeCampaignsByCampaignIdDevicesApiArg = { campaignId: string; }; export type GetUsersMeCampaignsByCampaignIdFormsApiResponse = - /** status 200 OK */ (PreselectionFormQuestion & { + /** status 200 OK */ ({ + question: string; + short_name?: string; value?: | number | { @@ -2144,7 +2146,19 @@ export type GetUsersMeCampaignsByCampaignIdFormsApiResponse = error?: string; }; id: number; - })[]; + } & ( + | { + type: PreselectionQuestionSimple; + } + | { + type: PreselectionQuestionMultiple; + options: string[]; + } + | { + type: PreselectionQuestionCuf; + options?: number[]; + } + ))[]; export type GetUsersMeCampaignsByCampaignIdFormsApiArg = { campaignId: string; }; @@ -2829,22 +2843,29 @@ 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" | "gender" | "phone_number" | "address"; + type: PreselectionQuestionSimple; } | { - type: "multiselect" | "select" | "radio"; - options: { + type: PreselectionQuestionMultiple; + options?: { value: string; isInvalid?: boolean; }[]; } | { - type: string; + type: PreselectionQuestionCuf; options?: { value: number; isInvalid?: boolean; diff --git a/src/utils/schema.ts b/src/utils/schema.ts index c35cea1a..b39399fa 100644 --- a/src/utils/schema.ts +++ b/src/utils/schema.ts @@ -805,19 +805,17 @@ export interface components { short_name?: string; } & ( | { - /** @enum {string} */ - type: "text" | "gender" | "phone_number" | "address"; + type: components["schemas"]["PreselectionQuestionSimple"]; } | { - /** @enum {string} */ - type: "multiselect" | "select" | "radio"; - options: { + type: components["schemas"]["PreselectionQuestionMultiple"]; + options?: { value: string; isInvalid?: boolean; }[]; } | { - type: string; + type: components["schemas"]["PreselectionQuestionCuf"]; options?: { value: number; isInvalid?: boolean; @@ -947,6 +945,18 @@ export interface components { 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 */ @@ -3299,7 +3309,9 @@ export interface operations { /** OK */ 200: { content: { - "application/json": (components["schemas"]["PreselectionFormQuestion"] & { + "application/json": ({ + question: string; + short_name?: string; value?: | number | { @@ -3313,7 +3325,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"];