diff --git a/packages/backend-for-frontend/src/api/agreementApiConverter.ts b/packages/backend-for-frontend/src/api/agreementApiConverter.ts index 8f9e85d236..55fb68d5fe 100644 --- a/packages/backend-for-frontend/src/api/agreementApiConverter.ts +++ b/packages/backend-for-frontend/src/api/agreementApiConverter.ts @@ -1,4 +1,9 @@ -import { agreementApi, bffApi, catalogApi } from "pagopa-interop-api-clients"; +import { + agreementApi, + attributeRegistryApi, + bffApi, + catalogApi, +} from "pagopa-interop-api-clients"; import { isAgreementUpgradable } from "../services/validators.js"; export function toBffCompactOrganization( @@ -41,3 +46,17 @@ export function toBffAgreementConsumerDocument( createdAt: doc.createdAt, }; } + +export function toBffAttribute( + attribute: attributeRegistryApi.Attribute +): + | bffApi.VerifiedAttribute + | bffApi.DeclaredAttribute + | bffApi.CertifiedAttribute { + return { + id: attribute.id, + description: attribute.description, + name: attribute.name, + creationTime: attribute.creationTime, + }; +} diff --git a/packages/backend-for-frontend/src/services/agreementService.ts b/packages/backend-for-frontend/src/services/agreementService.ts index ec4666de3c..cc5e325b11 100644 --- a/packages/backend-for-frontend/src/services/agreementService.ts +++ b/packages/backend-for-frontend/src/services/agreementService.ts @@ -36,6 +36,7 @@ import { } from "../api/catalogApiConverter.js"; import { toBffAgreementConsumerDocument, + toBffAttribute, toBffCompactOrganization, toCompactEserviceLight, } from "../api/agreementApiConverter.js"; @@ -691,9 +692,9 @@ export async function enrichAgreement( : undefined, }, state: agreement.state, - verifiedAttributes: agreementVerifiedAttrs, - certifiedAttributes: agreementCertifiedAttrs, - declaredAttributes: agreementDeclaredAttrs, + verifiedAttributes: agreementVerifiedAttrs.map((a) => toBffAttribute(a)), + certifiedAttributes: agreementCertifiedAttrs.map((a) => toBffAttribute(a)), + declaredAttributes: agreementDeclaredAttrs.map((a) => toBffAttribute(a)), suspendedByConsumer: agreement.suspendedByConsumer, suspendedByProducer: agreement.suspendedByProducer, suspendedByPlatform: agreement.suspendedByPlatform,