diff --git a/Dockerfile b/Dockerfile
index 5698b6f73..9752ae383 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,6 +15,8 @@ COPY /api_pagopa.yaml /usr/src/app/api_pagopa.yaml
COPY /api_public.yaml /usr/src/app/api_public.yaml
COPY /api_bonus.yaml /usr/src/app/api_bonus.yaml
COPY /api_session.yaml /usr/src/app/api_session.yaml
+COPY /api_myportal.yaml /usr/src/app/api_myportal.yaml
+COPY /api_bpd.yaml /usr/src/app/api_bpd.yaml
COPY /.npmrc /usr/src/app/.npmrc
RUN sudo chmod -R 777 /usr/src/app \
diff --git a/package.json b/package.json
index 9888d0e92..ceeab8733 100644
--- a/package.json
+++ b/package.json
@@ -26,18 +26,18 @@
"test:coverage": "dotenv -e .env.example -- jest -i --coverage",
"start": "node src/server.js",
"generate:proxy-models": "npm-run-all generate:proxy:* generate:api:* generate:messages:*",
- "generate:proxy:api-models": "rimraf generated/backend && shx mkdir -p generated/backend && gen-api-models --api-spec api_backend.yaml --out-dir generated/backend",
- "generate:proxy:auth-models": "rimraf generated/auth && shx mkdir -p generated/auth && gen-api-models --api-spec api_auth.yaml --out-dir generated/auth",
- "generate:proxy:notification-models": "rimraf generated/notifications && shx mkdir -p generated/notifications && gen-api-models --api-spec api_notifications.yaml --out-dir generated/notifications",
- "generate:messages:notifications": "rimraf generated/messages && shx mkdir -p generated/messages && gen-api-models --api-spec notification_queue_messages.yaml --out-dir generated/messages",
- "generate:proxy:pagopa-models": "rimraf generated/pagopa && shx mkdir -p generated/pagopa && gen-api-models --api-spec api_pagopa.yaml --out-dir generated/pagopa",
- "generate:proxy:myportal-models": "rimraf generated/myportal && shx mkdir -p generated/myportal && gen-api-models --api-spec api_myportal.yaml --out-dir generated/myportal",
- "generate:proxy:bpd-models": "rimraf generated/bpd && shx mkdir -p generated/bpd && gen-api-models --api-spec api_bpd.yaml --out-dir generated/bpd",
- "generate:proxy:public-models": "rimraf generated/public && shx mkdir -p generated/public && gen-api-models --api-spec api_public.yaml --out-dir generated/public",
- "generate:api:io": "rimraf generated/io-api && shx mkdir -p generated/io-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-app/master/openapi/index.yaml --no-strict --out-dir generated/io-api --request-types --response-decoders",
- "generate:proxy:bonus-models": "rimraf generated/bonus && shx mkdir -p generated/bonus && gen-api-models --api-spec api_bonus.yaml --out-dir generated/bonus",
- "generate:api:io-bonus": "rimraf generated/io-bonus-api && shx mkdir -p generated/io-bonus-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-bonus/master/openapi/index.yaml --no-strict --out-dir generated/io-bonus-api --request-types --response-decoders",
- "generate:api:pagopaproxy": "rimraf generated/pagopa-proxy && shx mkdir -p generated/pagopa-proxy && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-pagopa-proxy/v0.8.6/api_pagopa.yaml --no-strict --out-dir generated/pagopa-proxy --request-types --response-decoders",
+ "generate:proxy:api-models": "rimraf generated/backend && gen-api-models --api-spec api_backend.yaml --out-dir generated/backend",
+ "generate:proxy:auth-models": "rimraf generated/auth && gen-api-models --api-spec api_auth.yaml --out-dir generated/auth",
+ "generate:proxy:notification-models": "rimraf generated/notifications && gen-api-models --api-spec api_notifications.yaml --out-dir generated/notifications",
+ "generate:messages:notifications": "rimraf generated/messages && gen-api-models --api-spec notification_queue_messages.yaml --out-dir generated/messages",
+ "generate:proxy:pagopa-models": "rimraf generated/pagopa && gen-api-models --api-spec api_pagopa.yaml --out-dir generated/pagopa",
+ "generate:proxy:myportal-models": "rimraf generated/myportal && gen-api-models --api-spec api_myportal.yaml --out-dir generated/myportal",
+ "generate:proxy:bpd-models": "rimraf generated/bpd && gen-api-models --api-spec api_bpd.yaml --out-dir generated/bpd",
+ "generate:proxy:public-models": "rimraf generated/public && gen-api-models --api-spec api_public.yaml --out-dir generated/public",
+ "generate:api:io": "rimraf generated/io-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-app/master/openapi/index.yaml --no-strict --out-dir generated/io-api --request-types --response-decoders --client",
+ "generate:proxy:bonus-models": "rimraf generated/bonus && gen-api-models --api-spec api_bonus.yaml --out-dir generated/bonus",
+ "generate:api:io-bonus": "rimraf generated/io-bonus-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-bonus/master/openapi/index.yaml --no-strict --out-dir generated/io-bonus-api --request-types --response-decoders --client",
+ "generate:api:pagopaproxy": "rimraf generated/pagopa-proxy && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-pagopa-proxy/v0.8.6/api_pagopa.yaml --no-strict --out-dir generated/pagopa-proxy --request-types --response-decoders --client",
"generate:test-certs": "./scripts/generate-test-certs.sh certs",
"postversion": "git push && git push --tags",
"dist:modules": "modclean -r -n default:safe && yarn install --production",
@@ -119,7 +119,7 @@
"danger-plugin-digitalcitizenship": "^0.3.1",
"dotenv-cli": "^3.1.0",
"italia-tslint-rules": "^1.1.3",
- "italia-utils": "^4.2.0",
+ "italia-utils": "^5.1.0",
"jest": "^23.6.0",
"lolex": "4.2.0",
"mock-redis-client": "^0.91.13",
diff --git a/src/clients/api.ts b/src/clients/api.ts
index 7b16547e2..ee8c7208e 100644
--- a/src/clients/api.ts
+++ b/src/clients/api.ts
@@ -1,239 +1,24 @@
-import {
- ApiHeaderJson,
- composeHeaderProducers,
- composeResponseDecoders,
- constantResponseDecoder,
- createFetchRequestForApi,
- ioResponseDecoder,
- ReplaceRequestParams,
- RequestHeaderProducer,
- RequestParams,
- TypeofApiCall
-} from "italia-ts-commons/lib/requests";
-import { ProblemJson } from "italia-ts-commons/lib/responses";
-import { Omit } from "italia-ts-commons/lib/types";
import nodeFetch from "node-fetch";
-
-import {
- createProfileDefaultDecoder,
- CreateProfileT,
- getMessageDefaultDecoder,
- getMessagesByUserDefaultDecoder,
- GetMessagesByUserT,
- GetMessageT,
- getProfileDefaultDecoder,
- GetProfileT,
- getServiceDefaultDecoder,
- GetServiceT,
- getUserDataProcessingDefaultDecoder,
- GetUserDataProcessingT,
- getVisibleServicesDefaultDecoder,
- GetVisibleServicesT,
- StartEmailValidationProcessT,
- updateProfileDefaultDecoder,
- UpdateProfileT,
- upsertUserDataProcessingDefaultDecoder,
- UpsertUserDataProcessingT
-} from "../../generated/io-api/requestTypes";
-
-// we want to authenticate against the platform APIs with the APIM header key or
-// the Azure Functions header key, so we send both headers
-function SubscriptionKeyHeaderProducer
(
- token: string
-): RequestHeaderProducer
{
- return () => ({
- "Ocp-Apim-Subscription-Key": token,
- "X-Functions-Key": token
- });
-}
+import { Client, createClient } from "../../generated/io-api/client";
export function APIClient(
baseUrl: string,
token: string,
// tslint:disable-next-line:no-any
fetchApi: typeof fetch = (nodeFetch as any) as typeof fetch // TODO: customize fetch with timeout
-): {
- readonly updateProfile: TypeofApiCall;
- readonly getMessage: TypeofApiCall;
- readonly getMessages: TypeofApiCall;
- readonly getProfile: TypeofApiCall;
- readonly createProfile: TypeofApiCall;
- readonly upsertUserDataProcessing: TypeofApiCall<
- typeof upsertUserDataProcessingT
- >;
- readonly emailValidationProcess: TypeofApiCall<
- typeof emailValidationProcessT
- >;
- readonly getService: TypeofApiCall;
- readonly getVisibleServices: TypeofApiCall;
- readonly getUserDataProcessing: TypeofApiCall;
-} {
- const options = {
+): Client<"SubscriptionKey"> {
+ return createClient<"SubscriptionKey">({
+ basePath: "",
baseUrl,
- fetchApi
- };
-
- const tokenHeaderProducer = SubscriptionKeyHeaderProducer(token);
-
- // Custom decoder until we fix the problem in the io-utils generator
- // https://www.pivotaltracker.com/story/show/169915207
- // tslint:disable-next-line:typedef
- function startEmailValidationProcessCustomDecoder() {
- return composeResponseDecoders(
- composeResponseDecoders(
- composeResponseDecoders(
- composeResponseDecoders(
- constantResponseDecoder(202, undefined),
- ioResponseDecoder<
- 400,
- typeof ProblemJson["_A"],
- typeof ProblemJson["_O"]
- >(400, ProblemJson)
- ),
- constantResponseDecoder(401, undefined)
- ),
- constantResponseDecoder(404, undefined)
- ),
- constantResponseDecoder(429, undefined)
- );
- }
-
- const getProfileT: ReplaceRequestParams<
- GetProfileT,
- Omit, "SubscriptionKey">
- > = {
- headers: tokenHeaderProducer,
- method: "get",
- query: _ => ({}),
- response_decoder: getProfileDefaultDecoder(),
- url: params => `/profiles/${params.fiscalCode}`
- };
-
- const createProfileT: ReplaceRequestParams<
- CreateProfileT,
- Omit, "SubscriptionKey">
- > = {
- body: params => JSON.stringify(params.newProfile),
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "post",
- query: _ => ({}),
- response_decoder: createProfileDefaultDecoder(),
- url: params => `/profiles/${params.fiscalCode}`
- };
-
- const updateProfileT: ReplaceRequestParams<
- UpdateProfileT,
- Omit, "SubscriptionKey">
- > = {
- body: params => JSON.stringify(params.profile),
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "put",
- query: _ => ({}),
- response_decoder: updateProfileDefaultDecoder(),
- url: params => `/profiles/${params.fiscalCode}`
- };
-
- const emailValidationProcessT: ReplaceRequestParams<
- StartEmailValidationProcessT,
- Omit, "SubscriptionKey">
- > = {
- body: _ => "{}",
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "post",
- query: _ => ({}),
- response_decoder: startEmailValidationProcessCustomDecoder(),
- url: params => `/email-validation-process/${params.fiscalCode}`
- };
-
- const getUserDataProcessingT: ReplaceRequestParams<
- GetUserDataProcessingT,
- Omit, "SubscriptionKey">
- > = {
- headers: tokenHeaderProducer,
- method: "get",
- query: _ => ({}),
- response_decoder: getUserDataProcessingDefaultDecoder(),
- url: params =>
- `/user-data-processing/${params.fiscalCode}/${params.userDataProcessingChoiceParam}`
- };
-
- const getMessagesT: ReplaceRequestParams<
- GetMessagesByUserT,
- Omit, "SubscriptionKey">
- > = {
- headers: tokenHeaderProducer,
- method: "get",
- query: _ => ({}),
- response_decoder: getMessagesByUserDefaultDecoder(),
- url: params => `/messages/${params.fiscalCode}`
- };
-
- const getMessageT: ReplaceRequestParams<
- GetMessageT,
- Omit, "SubscriptionKey">
- > = {
- headers: tokenHeaderProducer,
- method: "get",
- query: _ => ({}),
- response_decoder: getMessageDefaultDecoder(),
- url: params => `/messages/${params.fiscalCode}/${params.id}`
- };
-
- const getVisibleServicesT: ReplaceRequestParams<
- GetVisibleServicesT,
- Omit, "SubscriptionKey">
- > = {
- headers: tokenHeaderProducer,
- method: "get",
- query: _ => ({}),
- response_decoder: getVisibleServicesDefaultDecoder(),
- url: () => `/services`
- };
-
- const getServiceT: ReplaceRequestParams<
- GetServiceT,
- Omit, "SubscriptionKey">
- > = {
- headers: tokenHeaderProducer,
- method: "get",
- query: _ => ({}),
- response_decoder: getServiceDefaultDecoder(),
- url: params => `/services/${params.service_id}`
- };
-
- const upsertUserDataProcessingT: ReplaceRequestParams<
- UpsertUserDataProcessingT,
- Omit, "SubscriptionKey">
- > = {
- body: params => JSON.stringify(params.userDataProcessingChoiceRequest),
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "post",
- query: _ => ({}),
- response_decoder: upsertUserDataProcessingDefaultDecoder(),
- url: params => `/user-data-processing/${params.fiscalCode}`
- };
-
- return {
- createProfile: createFetchRequestForApi(createProfileT, options),
- emailValidationProcess: createFetchRequestForApi(
- emailValidationProcessT,
- options
- ),
- getMessage: createFetchRequestForApi(getMessageT, options),
- getMessages: createFetchRequestForApi(getMessagesT, options),
- getProfile: createFetchRequestForApi(getProfileT, options),
- getService: createFetchRequestForApi(getServiceT, options),
- getUserDataProcessing: createFetchRequestForApi(
- getUserDataProcessingT,
- options
- ),
- getVisibleServices: createFetchRequestForApi(getVisibleServicesT, options),
- updateProfile: createFetchRequestForApi(updateProfileT, options),
- upsertUserDataProcessing: createFetchRequestForApi(
- upsertUserDataProcessingT,
- options
- )
- };
+ fetchApi,
+ withDefaults: op => params =>
+ op({
+ ...params,
+ // please refer to source api spec for actual header mapping
+ // https://github.com/pagopa/io-functions-app/blob/master/openapi/index.yaml#:~:text=%20%20SubscriptionKey:
+ SubscriptionKey: token
+ })
+ });
}
export type APIClient = typeof APIClient;
diff --git a/src/clients/bonus.ts b/src/clients/bonus.ts
index aae969b10..b435e2531 100644
--- a/src/clients/bonus.ts
+++ b/src/clients/bonus.ts
@@ -1,168 +1,24 @@
-import {
- ApiHeaderJson,
- composeHeaderProducers,
- createFetchRequestForApi,
- IPostApiRequestType,
- IResponseType,
- ReplaceRequestParams,
- RequestHeaderProducer,
- RequestParams,
- TypeofApiCall
-} from "italia-ts-commons/lib/requests";
-import { Omit } from "italia-ts-commons/lib/types";
import nodeFetch from "node-fetch";
-
-import { InstanceId } from "generated/io-bonus-api/InstanceId";
-import { ProblemJson } from "italia-ts-commons/lib/responses";
-import {
- getAllBonusActivationsDefaultDecoder,
- GetAllBonusActivationsT,
- getBonusEligibilityCheckDefaultDecoder,
- GetBonusEligibilityCheckT,
- getLatestBonusActivationByIdDefaultDecoder,
- GetLatestBonusActivationByIdT,
- startBonusActivationProcedureDefaultDecoder,
- startBonusEligibilityCheckDefaultDecoder
-} from "../../generated/io-bonus-api/requestTypes";
-
-// we want to authenticate against the platform APIs with
-// the Azure Functions header key
-function SubscriptionKeyHeaderProducer(
- token: string
- // tslint:disable-next-line: no-duplicate-string (WHY THE LINT INTERPRETS THIS AS A VALUE AND NOT AS A TYPE?)
-): RequestHeaderProducer
{
- return () => ({
- "X-Functions-Key": token
- });
-}
+import { Client, createClient } from "../../generated/io-bonus-api/client";
export function BonusAPIClient(
token: string,
baseUrl: string,
// tslint:disable-next-line:no-any
fetchApi: typeof fetch = (nodeFetch as any) as typeof fetch
-): {
- readonly getAllBonusActivations: TypeofApiCall<
- typeof getAllBonusActivationsT
- >;
- readonly getBonusEligibilityCheck: TypeofApiCall<
- typeof getBonusEligibilityCheckT
- >;
- readonly getLatestBonusActivationById: TypeofApiCall<
- typeof getLatestBonusActivationByIdT
- >;
- readonly startBonusActivationProcedure: TypeofApiCall<
- typeof startBonusActivationProcedureT
- >;
- readonly startBonusEligibilityCheck: TypeofApiCall<
- typeof startBonusEligibilityCheckT
- >;
-} {
- const options = {
+): Client<"ApiKey"> {
+ return createClient<"ApiKey">({
+ basePath: "",
baseUrl,
- fetchApi
- };
- const tokenHeaderProducer = SubscriptionKeyHeaderProducer(token);
-
- // This request type need to be rewritten because the code generator doesn't handle custom response header values
- const startBonusEligibilityCheckT: IPostApiRequestType<
- { readonly fiscalCode: string },
- "Content-Type" | "X-Functions-Key",
- never,
- // tslint:disable-next-line: max-union-size
- | IResponseType<201, InstanceId, "Location">
- | IResponseType<202, undefined>
- | IResponseType<401, undefined>
- | IResponseType<403, undefined>
- | IResponseType<409, ProblemJson>
- | IResponseType<500, ProblemJson>
- > = {
- body: _ => "",
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "post",
- query: _ => ({}),
- response_decoder: startBonusEligibilityCheckDefaultDecoder(),
- url: params => `/bonus/vacanze/eligibility/${params.fiscalCode}`
- };
-
- const getBonusEligibilityCheckT: ReplaceRequestParams<
- GetBonusEligibilityCheckT,
- Omit, "ApiKey">
- > = {
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "get",
- query: _ => ({}),
- response_decoder: getBonusEligibilityCheckDefaultDecoder(),
- url: params => `/bonus/vacanze/eligibility/${params.fiscalCode}`
- };
-
- const getLatestBonusActivationByIdT: ReplaceRequestParams<
- GetLatestBonusActivationByIdT,
- Omit, "ApiKey">
- > = {
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "get",
- query: _ => ({}),
- response_decoder: getLatestBonusActivationByIdDefaultDecoder(),
- url: params =>
- `/bonus/vacanze/activations/${params.fiscalCode}/${params.bonus_id}`
- };
-
- const getAllBonusActivationsT: ReplaceRequestParams<
- GetAllBonusActivationsT,
- Omit, "ApiKey">
- > = {
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "get",
- query: _ => ({}),
- response_decoder: getAllBonusActivationsDefaultDecoder(),
- url: params => `/bonus/vacanze/activations/${params.fiscalCode}`
- };
-
- // This request type need to be rewritten because the code generator doesn't handle custom response header values
- const startBonusActivationProcedureT: IPostApiRequestType<
- { readonly fiscalCode: string },
- "Content-Type" | "X-Functions-Key",
- never,
- // tslint:disable-next-line: max-union-size
- | IResponseType<201, InstanceId, "Location">
- | IResponseType<202, InstanceId>
- | IResponseType<401, undefined>
- | IResponseType<403, undefined>
- | IResponseType<409, undefined>
- | IResponseType<410, undefined>
- | IResponseType<500, ProblemJson>
- > = {
- body: _ => "",
- headers: composeHeaderProducers(tokenHeaderProducer, ApiHeaderJson),
- method: "post",
- query: _ => ({}),
- response_decoder: startBonusActivationProcedureDefaultDecoder(),
- url: params => `/bonus/vacanze/activations/${params.fiscalCode}`
- };
-
- return {
- getAllBonusActivations: createFetchRequestForApi(
- getAllBonusActivationsT,
- options
- ),
- getBonusEligibilityCheck: createFetchRequestForApi(
- getBonusEligibilityCheckT,
- options
- ),
- getLatestBonusActivationById: createFetchRequestForApi(
- getLatestBonusActivationByIdT,
- options
- ),
- startBonusActivationProcedure: createFetchRequestForApi(
- startBonusActivationProcedureT,
- options
- ),
- startBonusEligibilityCheck: createFetchRequestForApi(
- startBonusEligibilityCheckT,
- options
- )
- };
+ fetchApi,
+ withDefaults: op => params =>
+ op({
+ ...params,
+ // please refer to source api spec for actual header mapping
+ // https://github.com/pagopa/io-functions-bonus/blob/master/openapi/index.yaml#:~:text=%20%20ApiKey:
+ ApiKey: token
+ })
+ });
}
export type BonusAPIClient = typeof BonusAPIClient;
diff --git a/src/clients/pagopa.ts b/src/clients/pagopa.ts
index 836352757..ad38d5a82 100644
--- a/src/clients/pagopa.ts
+++ b/src/clients/pagopa.ts
@@ -1,63 +1,16 @@
-import {
- ApiHeaderJson,
- createFetchRequestForApi,
- TypeofApiCall
-} from "italia-ts-commons/lib/requests";
import nodeFetch from "node-fetch";
-
-import {
- activatePaymentDefaultDecoder,
- ActivatePaymentT,
- getActivationStatusDefaultDecoder,
- GetActivationStatusT,
- getPaymentInfoDefaultDecoder,
- GetPaymentInfoT
-} from "../../generated/pagopa-proxy/requestTypes";
+import { Client, createClient } from "../../generated/pagopa-proxy/client";
export function PagoPAClient(
- baseUrl?: string,
+ baseUrl: string,
// tslint:disable-next-line:no-any
fetchApi: typeof fetch = (nodeFetch as any) as typeof fetch
-): {
- readonly activatePayment: TypeofApiCall;
- readonly getActivationStatus: TypeofApiCall;
- readonly getPaymentInfo: TypeofApiCall;
-} {
- const options = {
+): Client {
+ return createClient({
+ basePath: "",
baseUrl,
fetchApi
- };
-
- const activatePayment: ActivatePaymentT = {
- body: params => JSON.stringify(params.paymentActivationsPostRequest),
- headers: ApiHeaderJson,
- method: "post",
- query: _ => ({}),
- response_decoder: activatePaymentDefaultDecoder(),
- url: () => `/payment-activations`
- };
-
- const getActivationStatus: GetActivationStatusT = {
- headers: () => ({}),
- method: "get",
- query: _ => ({}),
- response_decoder: getActivationStatusDefaultDecoder(),
- url: params => `/payment-activations/${params.codiceContestoPagamento}`
- };
-
- const getPaymentInfo: GetPaymentInfoT = {
- headers: () => ({}),
- method: "get",
- query: _ => ({}),
- response_decoder: getPaymentInfoDefaultDecoder(),
- url: params => `/payment-requests/${params.rptId}`
- };
-
- return {
- activatePayment: createFetchRequestForApi(activatePayment, options),
- getActivationStatus: createFetchRequestForApi(getActivationStatus, options),
- getPaymentInfo: createFetchRequestForApi(getPaymentInfo, options)
- };
+ });
}
export type PagoPAClient = typeof PagoPAClient;
diff --git a/src/controllers/__tests__/bonusController.test.ts b/src/controllers/__tests__/bonusController.test.ts
index ba2673858..30870bcfb 100644
--- a/src/controllers/__tests__/bonusController.test.ts
+++ b/src/controllers/__tests__/bonusController.test.ts
@@ -58,7 +58,7 @@ const aInstanceId: InstanceId = {
const aEligibilityCheck: EligibilityCheck = {
dsu_request: {
- dsu_created_at: new Date().toString(),
+ dsu_created_at: new Date(),
dsu_protocol_id: "123" as NonEmptyString,
family_members: [],
has_discrepancies: false,
@@ -75,7 +75,7 @@ const aBonusActivation: BonusActivation = {
applicant_fiscal_code: aFiscalCode,
created_at: aDate,
dsu_request: {
- dsu_created_at: "",
+ dsu_created_at: new Date(),
dsu_protocol_id: "dsuprotid" as NonEmptyString,
family_members: [
{ fiscal_code: aFiscalCode, name: aValidName, surname: aValidFamilyname }
diff --git a/src/services/__tests__/bonusService.test.ts b/src/services/__tests__/bonusService.test.ts
index fb153303b..9b1d548c9 100644
--- a/src/services/__tests__/bonusService.test.ts
+++ b/src/services/__tests__/bonusService.test.ts
@@ -31,7 +31,7 @@ const aBonusId = "aBonusId" as NonEmptyString & BonusCode;
const aEligibilityCheck: EligibilityCheck = {
dsu_request: {
- dsu_created_at: new Date().toString(),
+ dsu_created_at: new Date(),
dsu_protocol_id: "123" as NonEmptyString,
family_members: [],
has_discrepancies: false,
@@ -49,7 +49,7 @@ const aBonusActivation: BonusActivation = {
applicant_fiscal_code: "SPNDNL80R14C522K" as FiscalCode,
created_at: new Date(),
dsu_request: {
- dsu_created_at: "",
+ dsu_created_at: new Date(),
dsu_protocol_id: "dsuprotid" as NonEmptyString,
family_members: [
{
@@ -131,7 +131,7 @@ describe("BonusService#startBonusEligibilityCheck", () => {
await service.startBonusEligibilityCheck(mockedUser);
expect(mockStartBonusEligibilityCheck).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscalcode: mockedUser.fiscal_code
});
});
@@ -247,7 +247,7 @@ describe("BonusService#getBonusEligibilityCheck", () => {
await service.getBonusEligibilityCheck(mockedUser);
expect(mockGetBonusEligibilityCheck).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscalcode: mockedUser.fiscal_code
});
});
@@ -320,7 +320,7 @@ describe("BonusService#getLatestBonusActivationById", () => {
expect(mockGetLatestBonusActivationById).toHaveBeenCalledWith({
bonus_id: aBonusId,
- fiscalCode: mockedUser.fiscal_code
+ fiscalcode: mockedUser.fiscal_code
});
});
@@ -414,7 +414,7 @@ describe("BonusService#getAllBonusActivations", () => {
await service.getAllBonusActivations(mockedUser);
expect(mockGetAllBonusActivations).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscalcode: mockedUser.fiscal_code
});
});
@@ -503,7 +503,7 @@ describe("BonusService#startBonusActivationProcedure", () => {
await service.startBonusActivationProcedure(mockedUser);
expect(mockStartBonusActivationProcedure).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscalcode: mockedUser.fiscal_code
});
});
diff --git a/src/services/__tests__/messagesService.test.ts b/src/services/__tests__/messagesService.test.ts
index d7ef1c36d..1c2aee5cc 100644
--- a/src/services/__tests__/messagesService.test.ts
+++ b/src/services/__tests__/messagesService.test.ts
@@ -165,14 +165,16 @@ beforeEach(() => {
});
jest.mock("../apiClientFactory");
-jest.spyOn(ApiClientFactory.prototype, "getClient").mockImplementation(() => {
- return ({
- getMessage: mockGetMessage,
- getMessages: mockGetMessages,
- getService: mockGetService,
- getServices: mockGetServices
- } as unknown) as ReturnType;
-});
+// partial because we may not want to mock every operation
+const mockClient: Partial> = {
+ getMessage: mockGetMessage,
+ getMessagesByUser: mockGetMessages,
+ getService: mockGetService,
+ getVisibleServices: mockGetServices
+};
+jest
+ .spyOn(ApiClientFactory.prototype, "getClient")
+ .mockImplementation(() => (mockClient as unknown) as ReturnType);
const api = new ApiClientFactory("", "");
@@ -187,7 +189,7 @@ describe("MessageService#getMessagesByUser", () => {
const res = await service.getMessagesByUser(mockedUser);
expect(mockGetMessages).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscal_code: mockedUser.fiscal_code
});
expect(res).toMatchObject({
kind: "IResponseSuccessJson",
@@ -205,7 +207,7 @@ describe("MessageService#getMessagesByUser", () => {
const res = await service.getMessagesByUser(mockedUser);
expect(mockGetMessages).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscal_code: mockedUser.fiscal_code
});
expect(res.kind).toEqual("IResponseErrorNotFound");
});
@@ -229,7 +231,7 @@ describe("MessageService#getMessagesByUser", () => {
const res = await service.getMessagesByUser(mockedUser);
expect(mockGetMessages).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscal_code: mockedUser.fiscal_code
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -243,7 +245,7 @@ describe("MessageService#getMessagesByUser", () => {
const res = await service.getMessagesByUser(mockedUser);
expect(mockGetMessages).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscal_code: mockedUser.fiscal_code
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -258,7 +260,7 @@ describe("MessageService#getMessage", () => {
const res = await service.getMessage(mockedUser, aValidMessageId);
expect(mockGetMessage).toHaveBeenCalledWith({
- fiscalCode: aValidFiscalCode,
+ fiscal_code: aValidFiscalCode,
id: aValidMessageId
});
expect(res).toMatchObject({
@@ -277,7 +279,7 @@ describe("MessageService#getMessage", () => {
const res = await service.getMessage(mockedUser, aValidMessageId);
expect(mockGetMessage).toHaveBeenCalledWith({
- fiscalCode: aValidFiscalCode,
+ fiscal_code: aValidFiscalCode,
id: aValidMessageId
});
expect(res).toMatchSnapshot();
@@ -289,7 +291,7 @@ describe("MessageService#getMessage", () => {
const res = await service.getMessage(mockedUser, aValidMessageId);
expect(mockGetMessage).toHaveBeenCalledWith({
- fiscalCode: aValidFiscalCode,
+ fiscal_code: aValidFiscalCode,
id: aValidMessageId
});
expect(res.kind).toEqual("IResponseErrorInternal");
@@ -304,7 +306,7 @@ describe("MessageService#getMessage", () => {
const res = await service.getMessage(mockedUser, aValidMessageId);
expect(mockGetMessage).toHaveBeenCalledWith({
- fiscalCode: aValidFiscalCode,
+ fiscal_code: aValidFiscalCode,
id: aValidMessageId
});
expect(res.kind).toEqual("IResponseErrorInternal");
diff --git a/src/services/__tests__/pagoPAProxyService.test.ts b/src/services/__tests__/pagoPAProxyService.test.ts
index c8e66a127..0e820c255 100644
--- a/src/services/__tests__/pagoPAProxyService.test.ts
+++ b/src/services/__tests__/pagoPAProxyService.test.ts
@@ -134,7 +134,7 @@ describe("PagoPAProxyService#getPaymentInfo", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockGetPaymentInfo).toHaveBeenCalledWith({
- rptId: aRptId
+ rpt_id_from_string: aRptId
});
expect(res).toEqual({
apply: expect.any(Function),
@@ -153,7 +153,9 @@ describe("PagoPAProxyService#getPaymentInfo", () => {
const res = await service.getPaymentInfo(aRptId, true);
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.TEST);
- expect(mockGetPaymentInfo).toHaveBeenCalledWith({ rptId: aRptId });
+ expect(mockGetPaymentInfo).toHaveBeenCalledWith({
+ rpt_id_from_string: aRptId
+ });
expect(res).toEqual({
apply: expect.any(Function),
kind: "IResponseSuccessJson",
@@ -172,7 +174,7 @@ describe("PagoPAProxyService#getPaymentInfo", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockGetPaymentInfo).toHaveBeenCalledWith({
- rptId: aRptId
+ rpt_id_from_string: aRptId
});
expect(res.kind).toEqual("IResponseErrorValidation");
});
@@ -188,7 +190,7 @@ describe("PagoPAProxyService#getPaymentInfo", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockGetPaymentInfo).toHaveBeenCalledWith({
- rptId: aRptId
+ rpt_id_from_string: aRptId
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -204,7 +206,7 @@ describe("PagoPAProxyService#getPaymentInfo", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockGetPaymentInfo).toHaveBeenCalledWith({
- rptId: aRptId
+ rpt_id_from_string: aRptId
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -226,7 +228,7 @@ describe("PagoPAProxyService#activatePayment", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockActivatePayment).toHaveBeenCalledWith({
- paymentActivationsPostRequest: validPaymentActivation
+ body: validPaymentActivation
});
expect(res).toEqual({
apply: expect.any(Function),
@@ -246,7 +248,7 @@ describe("PagoPAProxyService#activatePayment", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.TEST);
expect(mockActivatePayment).toHaveBeenCalledWith({
- paymentActivationsPostRequest: validPaymentActivation
+ body: validPaymentActivation
});
expect(res).toEqual({
apply: expect.any(Function),
@@ -266,7 +268,7 @@ describe("PagoPAProxyService#activatePayment", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockActivatePayment).toHaveBeenCalledWith({
- paymentActivationsPostRequest: validPaymentActivation
+ body: validPaymentActivation
});
expect(res.kind).toEqual("IResponseErrorValidation");
});
@@ -282,7 +284,7 @@ describe("PagoPAProxyService#activatePayment", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockActivatePayment).toHaveBeenCalledWith({
- paymentActivationsPostRequest: validPaymentActivation
+ body: validPaymentActivation
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -298,7 +300,7 @@ describe("PagoPAProxyService#activatePayment", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockActivatePayment).toHaveBeenCalledWith({
- paymentActivationsPostRequest: validPaymentActivation
+ body: validPaymentActivation
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -323,7 +325,7 @@ describe("PagoPAProxyService#getActivationStatus", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockGetActivationStatus).toHaveBeenCalledWith({
- codiceContestoPagamento: acodiceContestoPagamento
+ codice_contesto_pagamento: acodiceContestoPagamento
});
expect(res).toEqual({
apply: expect.any(Function),
@@ -346,7 +348,7 @@ describe("PagoPAProxyService#getActivationStatus", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.TEST);
expect(mockGetActivationStatus).toHaveBeenCalledWith({
- codiceContestoPagamento: acodiceContestoPagamento
+ codice_contesto_pagamento: acodiceContestoPagamento
});
expect(res).toEqual({
apply: expect.any(Function),
@@ -369,7 +371,7 @@ describe("PagoPAProxyService#getActivationStatus", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockGetActivationStatus).toHaveBeenCalledWith({
- codiceContestoPagamento: acodiceContestoPagamento
+ codice_contesto_pagamento: acodiceContestoPagamento
});
expect(res.kind).toEqual("IResponseErrorNotFound");
});
@@ -388,7 +390,7 @@ describe("PagoPAProxyService#getActivationStatus", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockGetActivationStatus).toHaveBeenCalledWith({
- codiceContestoPagamento: acodiceContestoPagamento
+ codice_contesto_pagamento: acodiceContestoPagamento
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -407,7 +409,7 @@ describe("PagoPAProxyService#getActivationStatus", () => {
expect(mockGetClient).toHaveBeenCalledWith(PagoPAEnvironment.PRODUCTION);
expect(mockGetActivationStatus).toHaveBeenCalledWith({
- codiceContestoPagamento: acodiceContestoPagamento
+ codice_contesto_pagamento: acodiceContestoPagamento
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
diff --git a/src/services/__tests__/profileService.test.ts b/src/services/__tests__/profileService.test.ts
index fed82335d..8f64acd86 100644
--- a/src/services/__tests__/profileService.test.ts
+++ b/src/services/__tests__/profileService.test.ts
@@ -13,6 +13,7 @@ import {
import { SpidLevelEnum } from "../../../generated/backend/SpidLevel";
import { ExtendedProfile as ExtendedProfileApi } from "../../../generated/io-api/ExtendedProfile";
import { NewProfile } from "../../../generated/io-api/NewProfile";
+import { APIClient } from "../../clients/api";
import { toInitializedProfile } from "../../types/profile";
import { SessionToken, WalletToken } from "../../types/token";
@@ -112,20 +113,19 @@ const expectedApiError = new Error("Api error.");
const mockGetProfile = jest.fn();
const mockUpdateProfile = jest.fn();
const mockCreateProfile = jest.fn();
-const mockEmailValidationProcess = jest.fn();
+const mockStartEmailValidationProcess = jest.fn();
-const mockGetClient = jest.fn().mockImplementation(() => {
- return {
+// partial because we may not mock every method
+const mockClient: Partial> = {
createProfile: mockCreateProfile,
- emailValidationProcess: mockEmailValidationProcess,
+ startEmailValidationProcess: mockStartEmailValidationProcess,
getProfile: mockGetProfile,
- updateProfile: mockUpdateProfile
+ updateProfile: mockUpdateProfile,
};
-});
jest.mock("../../services/apiClientFactory", () => {
return {
default: jest.fn().mockImplementation(() => ({
- getClient: mockGetClient
+ getClient: () => mockClient
}))
};
});
@@ -145,7 +145,7 @@ describe("ProfileService#getProfile", () => {
const res = await service.getProfile(mockedUser);
expect(mockGetProfile).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscal_code: mockedUser.fiscal_code
});
expect(res).toMatchObject({
kind: "IResponseSuccessJson",
@@ -173,7 +173,7 @@ describe("ProfileService#getProfile", () => {
const res = await service.getProfile(mockedUser);
expect(mockGetProfile).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscal_code: mockedUser.fiscal_code
});
expect(res).toMatchObject({
kind: "IResponseErrorNotFound"
@@ -209,7 +209,7 @@ describe("ProfileService#getApiProfile", () => {
const res = await service.getApiProfile(mockedUser);
expect(mockGetProfile).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscal_code: mockedUser.fiscal_code
});
expect(res).toMatchObject({
kind: "IResponseSuccessJson",
@@ -237,7 +237,7 @@ describe("ProfileService#getApiProfile", () => {
const res = await service.getApiProfile(mockedUser);
expect(mockGetProfile).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ fiscal_code: mockedUser.fiscal_code
});
expect(res).toMatchObject({
detail: "Not found: Profile not found.",
@@ -276,8 +276,8 @@ describe("ProfileService#updateProfile", () => {
const res = await service.updateProfile(mockedUser, updateProfileRequest);
expect(mockUpdateProfile).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code,
- profile: updateProfileRequest
+ fiscal_code: mockedUser.fiscal_code,
+ body: updateProfileRequest
});
expect(res).toMatchObject({
kind: "IResponseSuccessJson",
@@ -335,8 +335,8 @@ describe("ProfileService#createProfile", () => {
const res = await service.createProfile(mockedUser, createProfileRequest);
expect(mockCreateProfile).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code,
- newProfile: createProfileRequest
+ fiscal_code: mockedUser.fiscal_code,
+ body: createProfileRequest
});
expect(res).toMatchObject({
kind: "IResponseSuccessJson",
@@ -385,7 +385,7 @@ describe("ProfileService#emailValidationProcess", () => {
});
it("should returns ResponseSuccessAccepted if no error occours", async () => {
- mockEmailValidationProcess.mockImplementation(() =>
+ mockStartEmailValidationProcess.mockImplementation(() =>
t.success(acceptedApiResponse)
);
@@ -393,8 +393,8 @@ describe("ProfileService#emailValidationProcess", () => {
const res = await service.emailValidationProcess(mockedUser);
- expect(mockEmailValidationProcess).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ expect(mockStartEmailValidationProcess).toHaveBeenCalledWith({
+ fiscal_code: mockedUser.fiscal_code
});
expect(res).toMatchObject({
kind: "IResponseSuccessAccepted"
@@ -402,7 +402,7 @@ describe("ProfileService#emailValidationProcess", () => {
});
it("returns 404 response if the 404 was provided from the functions API", async () => {
- mockEmailValidationProcess.mockImplementation(() =>
+ mockStartEmailValidationProcess.mockImplementation(() =>
t.success(notFoundApiResponse)
);
@@ -410,8 +410,8 @@ describe("ProfileService#emailValidationProcess", () => {
const res = await service.emailValidationProcess(mockedUser);
- expect(mockEmailValidationProcess).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code
+ expect(mockStartEmailValidationProcess).toHaveBeenCalledWith({
+ fiscal_code: mockedUser.fiscal_code
});
expect(res).toMatchObject({
detail: "Not found: User not found.",
@@ -420,7 +420,7 @@ describe("ProfileService#emailValidationProcess", () => {
});
it("returns an 429 HTTP error from emailValidationProcess upstream API", async () => {
- mockEmailValidationProcess.mockImplementation(() =>
+ mockStartEmailValidationProcess.mockImplementation(() =>
t.success(tooManyReqApiMessagesResponse)
);
@@ -439,6 +439,6 @@ describe("ProfileService#toInitializedProfile", () => {
date_of_birth: "1980-10-1"
});
- expect(profile.date_of_birth).toEqual("1980-10-01");
+ expect(profile.date_of_birth).toEqual(new Date("1980-10-01T00:00:00.000Z"));
});
});
diff --git a/src/services/__tests__/userDataProcessingService.test.ts b/src/services/__tests__/userDataProcessingService.test.ts
index 982bb40b5..b24c3e622 100644
--- a/src/services/__tests__/userDataProcessingService.test.ts
+++ b/src/services/__tests__/userDataProcessingService.test.ts
@@ -112,8 +112,8 @@ describe("UserDataProcessingService#getUserDataProcessing", () => {
);
expect(mockGetUserDataProcessing).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code,
- userDataProcessingChoiceParam: mockedUserDataProcessingChoice
+ fiscal_code: mockedUser.fiscal_code,
+ choice: mockedUserDataProcessingChoice
});
expect(res).toMatchObject({
kind: "IResponseSuccessJson",
@@ -146,8 +146,8 @@ describe("UserDataProcessingService#getUserDataProcessing", () => {
mockedUserDataProcessingChoice
);
expect(mockGetUserDataProcessing).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code,
- userDataProcessingChoiceParam: mockedUserDataProcessingChoice
+ fiscal_code: mockedUser.fiscal_code,
+ choice: mockedUserDataProcessingChoice
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -164,8 +164,8 @@ describe("UserDataProcessingService#getUserDataProcessing", () => {
mockedUserDataProcessingChoice
);
expect(mockGetUserDataProcessing).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code,
- userDataProcessingChoiceParam: mockedUserDataProcessingChoice
+ fiscal_code: mockedUser.fiscal_code,
+ choice: mockedUserDataProcessingChoice
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -188,8 +188,8 @@ describe("UserDataProcessingService#upsertUserDataProcessing", () => {
);
expect(mockUpsertUserDataProcessing).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code,
- userDataProcessingChoiceRequest: mockedUserDataProcessingChoiceRequest
+ fiscal_code: mockedUser.fiscal_code,
+ body: mockedUserDataProcessingChoiceRequest
});
expect(res).toMatchObject({
kind: "IResponseSuccessJson",
@@ -239,8 +239,8 @@ describe("UserDataProcessingService#upsertUserDataProcessing", () => {
mockedUserDataProcessingChoiceRequest
);
expect(mockUpsertUserDataProcessing).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code,
- userDataProcessingChoiceRequest: mockedUserDataProcessingChoiceRequest
+ fiscal_code: mockedUser.fiscal_code,
+ body: mockedUserDataProcessingChoiceRequest
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
@@ -257,8 +257,8 @@ describe("UserDataProcessingService#upsertUserDataProcessing", () => {
mockedUserDataProcessingChoiceRequest
);
expect(mockUpsertUserDataProcessing).toHaveBeenCalledWith({
- fiscalCode: mockedUser.fiscal_code,
- userDataProcessingChoiceRequest: mockedUserDataProcessingChoiceRequest
+ fiscal_code: mockedUser.fiscal_code,
+ body: mockedUserDataProcessingChoiceRequest
});
expect(res.kind).toEqual("IResponseErrorInternal");
});
diff --git a/src/services/bonusService.ts b/src/services/bonusService.ts
index 29cf8bcbd..a443e0cdc 100644
--- a/src/services/bonusService.ts
+++ b/src/services/bonusService.ts
@@ -91,7 +91,7 @@ export default class BonusService {
}
const validated = await this.bonusApiClient.startBonusEligibilityCheck({
- fiscalCode: user.fiscal_code
+ fiscalcode: user.fiscal_code
});
return withValidatedOrInternalError(validated, response => {
@@ -136,7 +136,7 @@ export default class BonusService {
> =>
withCatchAsInternalError(async () => {
const validated = await this.bonusApiClient.getBonusEligibilityCheck({
- fiscalCode: user.fiscal_code
+ fiscalcode: user.fiscal_code
});
return withValidatedOrInternalError(validated, response => {
@@ -178,7 +178,7 @@ export default class BonusService {
withCatchAsInternalError(async () => {
const validated = await this.bonusApiClient.getLatestBonusActivationById({
bonus_id: bonusId,
- fiscalCode: user.fiscal_code
+ fiscalcode: user.fiscal_code
});
// tslint:disable-next-line: no-identical-functions
@@ -227,7 +227,7 @@ export default class BonusService {
> =>
withCatchAsInternalError(async () => {
const validated = await this.bonusApiClient.getAllBonusActivations({
- fiscalCode: user.fiscal_code
+ fiscalcode: user.fiscal_code
});
// tslint:disable-next-line: no-identical-functions
@@ -263,7 +263,7 @@ export default class BonusService {
withCatchAsInternalError(async () => {
const validated = await this.bonusApiClient.startBonusActivationProcedure(
{
- fiscalCode: user.fiscal_code
+ fiscalcode: user.fiscal_code
}
);
diff --git a/src/services/messagesService.ts b/src/services/messagesService.ts
index 3f2dab1f1..96ea78c50 100644
--- a/src/services/messagesService.ts
+++ b/src/services/messagesService.ts
@@ -44,8 +44,8 @@ export default class MessagesService {
> =>
withCatchAsInternalError(async () => {
const client = this.apiClient.getClient();
- const validated = await client.getMessages({
- fiscalCode: user.fiscal_code
+ const validated = await client.getMessagesByUser({
+ fiscal_code: user.fiscal_code
});
return withValidatedOrInternalError(validated, response =>
@@ -76,7 +76,7 @@ export default class MessagesService {
const client = this.apiClient.getClient();
const res = await client.getMessage({
- fiscalCode: user.fiscal_code,
+ fiscal_code: user.fiscal_code,
id: messageId
});
diff --git a/src/services/pagoPAProxyService.ts b/src/services/pagoPAProxyService.ts
index 524cbc1d6..5bbdc25c9 100644
--- a/src/services/pagoPAProxyService.ts
+++ b/src/services/pagoPAProxyService.ts
@@ -46,7 +46,7 @@ export default class PagoPAProxyService {
isTest ? PagoPAEnvironment.TEST : PagoPAEnvironment.PRODUCTION
);
const validated = await client.getPaymentInfo({
- rptId
+ rpt_id_from_string: rptId
});
return withValidatedOrInternalError(validated, response =>
response.status === 200
@@ -81,7 +81,7 @@ export default class PagoPAProxyService {
isTest ? PagoPAEnvironment.TEST : PagoPAEnvironment.PRODUCTION
);
const validated = await client.activatePayment({
- paymentActivationsPostRequest
+ body: paymentActivationsPostRequest
});
return withValidatedOrInternalError(validated, response =>
@@ -117,7 +117,7 @@ export default class PagoPAProxyService {
isTest ? PagoPAEnvironment.TEST : PagoPAEnvironment.PRODUCTION
);
const validated = await client.getActivationStatus({
- codiceContestoPagamento
+ codice_contesto_pagamento: codiceContestoPagamento
});
return withValidatedOrInternalError(validated, response =>
response.status === 200
diff --git a/src/services/profileService.ts b/src/services/profileService.ts
index f2f3eae64..8a4213b2e 100644
--- a/src/services/profileService.ts
+++ b/src/services/profileService.ts
@@ -53,7 +53,7 @@ export default class ProfileService {
const client = this.apiClient.getClient();
return withCatchAsInternalError(async () => {
const validated = await client.getProfile({
- fiscalCode: user.fiscal_code
+ fiscal_code: user.fiscal_code
});
return withValidatedOrInternalError(validated, response => {
@@ -97,7 +97,7 @@ export default class ProfileService {
const client = this.apiClient.getClient();
return withCatchAsInternalError(async () => {
const validated = await client.getProfile({
- fiscalCode: user.fiscal_code
+ fiscal_code: user.fiscal_code
});
return withValidatedOrInternalError(validated, response => {
if (response.status === 200) {
@@ -139,8 +139,8 @@ export default class ProfileService {
const client = this.apiClient.getClient();
return withCatchAsInternalError(async () => {
const validated = await client.createProfile({
- fiscalCode: user.fiscal_code,
- newProfile
+ body: newProfile,
+ fiscal_code: user.fiscal_code
});
return withValidatedOrInternalError(validated, response =>
@@ -181,8 +181,8 @@ export default class ProfileService {
async extendedProfileApi =>
withCatchAsInternalError(async () => {
const validated = await client.updateProfile({
- fiscalCode: user.fiscal_code,
- profile: extendedProfileApi
+ body: extendedProfileApi,
+ fiscal_code: user.fiscal_code
});
return withValidatedOrInternalError(validated, response =>
@@ -216,8 +216,8 @@ export default class ProfileService {
> => {
const client = this.apiClient.getClient();
return withCatchAsInternalError(async () => {
- const validated = await client.emailValidationProcess({
- fiscalCode: user.fiscal_code
+ const validated = await client.startEmailValidationProcess({
+ fiscal_code: user.fiscal_code
});
return withValidatedOrInternalError(validated, response => {
return response.status === 202
diff --git a/src/services/userDataProcessingService.ts b/src/services/userDataProcessingService.ts
index 08e2d4ffe..dc38619ef 100644
--- a/src/services/userDataProcessingService.ts
+++ b/src/services/userDataProcessingService.ts
@@ -46,8 +46,8 @@ export default class UserDataProcessingService {
const client = this.apiClient.getClient();
return withCatchAsInternalError(async () => {
const validated = await client.upsertUserDataProcessing({
- fiscalCode: user.fiscal_code,
- userDataProcessingChoiceRequest
+ body: userDataProcessingChoiceRequest,
+ fiscal_code: user.fiscal_code
});
return withValidatedOrInternalError(validated, response =>
@@ -80,8 +80,8 @@ export default class UserDataProcessingService {
const client = this.apiClient.getClient();
return withCatchAsInternalError(async () => {
const validated = await client.getUserDataProcessing({
- fiscalCode: user.fiscal_code,
- userDataProcessingChoiceParam
+ choice: userDataProcessingChoiceParam,
+ fiscal_code: user.fiscal_code
});
return withValidatedOrInternalError(validated, response =>
diff --git a/src/types/profile.ts b/src/types/profile.ts
index b02785cda..6fdf192c3 100644
--- a/src/types/profile.ts
+++ b/src/types/profile.ts
@@ -14,7 +14,7 @@ import {
IResponseSuccessJson,
ResponseErrorInternal
} from "italia-ts-commons/lib/responses";
-import { formatDate } from "../utils//date";
+import { formatDate } from "../utils/date";
import { User } from "./user";
/**
@@ -28,7 +28,7 @@ export const toInitializedProfile = (
blocked_inbox_or_channels: profile.blocked_inbox_or_channels,
date_of_birth:
user.date_of_birth !== undefined
- ? formatDate(user.date_of_birth)
+ ? new Date(formatDate(user.date_of_birth))
: undefined,
email: profile.email,
family_name: user.family_name,
diff --git a/yarn.lock b/yarn.lock
index d71ac1a64..d84860d31 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3013,6 +3013,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
+graceful-fs@^4.2.3:
+ version "4.2.4"
+ resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
+ integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
+
growly@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
@@ -3938,16 +3943,17 @@ italia-tslint-rules@^1.1.3:
tslint-sonarts "^1.9.0"
typestrict "^1.0.2"
-italia-utils@^4.2.0:
- version "4.2.0"
- resolved "https://registry.yarnpkg.com/italia-utils/-/italia-utils-4.2.0.tgz#dffcbb66c896c06f6b4d17bf6090a478736c7736"
- integrity sha512-C6Pbyz7AUdFIMQ85+vxyRu/lfkG7trVrf6U6YzScnLeHssJCWCpf7OffQ33qCtp78B6roQr5Tdl+SyGDCD/4/w==
+italia-utils@^5.1.0:
+ version "5.1.0"
+ resolved "https://registry.npmjs.org/italia-utils/-/italia-utils-5.1.0.tgz#6c53609600925c8c1467889867e82840e2ebe7ff"
+ integrity sha512-MiwaB4z9RkZTWrcZmYfH25F+EJrMCjHyPEQuxGU/LIcx0AQqdQaaTcXadInN6RhS0tg3kGLRBRctu4++tFLHbA==
dependencies:
fs-extra "^6.0.0"
italia-ts-commons "^5.0.1"
nunjucks "^3.1.2"
prettier "^1.12.1"
swagger-parser "^7.0.0"
+ write-yaml-file "^4.1.0"
yargs "^11.1.0"
jest-changed-files@^23.4.2:
@@ -7742,7 +7748,7 @@ wrappy@1:
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
-write-file-atomic@^2.0.0, write-file-atomic@^2.1.0:
+write-file-atomic@^2.0.0, write-file-atomic@^2.1.0, write-file-atomic@^2.4.3:
version "2.4.3"
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.3.tgz#1fd2e9ae1df3e75b8d8c367443c692d4ca81f481"
integrity sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==
@@ -7761,6 +7767,15 @@ write-file-atomic@^3.0.0:
signal-exit "^3.0.2"
typedarray-to-buffer "^3.1.5"
+write-yaml-file@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.npmjs.org/write-yaml-file/-/write-yaml-file-4.1.0.tgz#8a8af90b608b0e0a91d7b1fc67d1c5f06d8092f0"
+ integrity sha512-jN421OlwO/MN/EwAykk5ic8AL9QAycpKGaHKFBlcr3aQ6RUX8ZbrreOPUuhoYSxj/o30FhOQLSH36WYldAFrUw==
+ dependencies:
+ graceful-fs "^4.2.3"
+ js-yaml "^3.13.1"
+ write-file-atomic "^2.4.3"
+
ws@^5.2.0:
version "5.2.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f"