Skip to content

Commit

Permalink
Added converter for bffApi attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
rGregnanin committed Oct 2, 2024
1 parent 6c85746 commit 19b53fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
21 changes: 20 additions & 1 deletion packages/backend-for-frontend/src/api/agreementApiConverter.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
} from "../api/catalogApiConverter.js";
import {
toBffAgreementConsumerDocument,
toBffAttribute,
toBffCompactOrganization,
toCompactEserviceLight,
} from "../api/agreementApiConverter.js";
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 19b53fd

Please sign in to comment.