Skip to content

Commit

Permalink
fix: extend TenantDelta with new info
Browse files Browse the repository at this point in the history
  • Loading branch information
beetlecrunch committed Dec 1, 2023
1 parent 19cabc0 commit bbea2e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package it.pagopa.interop.tenantmanagement.model.tenant

import java.time.OffsetDateTime
import java.util.UUID

final case class PersistentTenantDelta(
id: UUID,
selfcareId: Option[String],
features: List[PersistentTenantFeature],
kind: Option[PersistentTenantKind]
kind: Option[PersistentTenantKind],
onboardedAt: Option[OffsetDateTime],
subUnitType: Option[PersistentTenantUnitType]
)
7 changes: 6 additions & 1 deletion src/main/resources/interface-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,12 @@ components:
items:
$ref: '#/components/schemas/TenantFeature'
kind:
$ref: '#/components/schemas/TenantKind'
$ref: '#/components/schemas/TenantKind'
onboardedAt:
type: string
format: date-time
subUnitType:
$ref: '#/components/schemas/TenantUnitType'
required:
- features
- kind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package object impl extends SprayJsonSupport with DefaultJsonProtocol {
implicit val mailSeedFormat: RootJsonFormat[MailSeed] = jsonFormat4(MailSeed)
implicit val mailFormat: RootJsonFormat[Mail] = jsonFormat5(Mail)
implicit val tenantFormat: RootJsonFormat[Tenant] = jsonFormat12(Tenant)
implicit val tenantDeltaFormat: RootJsonFormat[TenantDelta] = jsonFormat3(TenantDelta)
implicit val tenantDeltaFormat: RootJsonFormat[TenantDelta] = jsonFormat5(TenantDelta)
implicit val tenantSeedFormat: RootJsonFormat[TenantSeed] = jsonFormat8(TenantSeed)
implicit val problemErrorFormat: RootJsonFormat[ProblemError] = jsonFormat2(ProblemError)
implicit val problemFormat: RootJsonFormat[Problem] = jsonFormat6(Problem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ object Adapters {
id = tenant.id,
selfcareId = td.selfcareId,
features = features,
kind = PersistentTenantKind.fromApi(td.kind).some
kind = PersistentTenantKind.fromApi(td.kind).some,
onboardedAt = td.onboardedAt,
subUnitType = td.subUnitType.map(PersistentTenantUnitType.fromApi)
)
}

Expand Down Expand Up @@ -188,7 +190,14 @@ object Adapters {
)

def update(ptd: PersistentTenantDelta, time: OffsetDateTime): PersistentTenant =
p.copy(selfcareId = ptd.selfcareId, features = ptd.features, kind = ptd.kind, updatedAt = time.some)
p.copy(
selfcareId = ptd.selfcareId,
features = ptd.features,
kind = ptd.kind,
updatedAt = time.some,
onboardedAt = ptd.onboardedAt,
subUnitType = ptd.subUnitType
)

def getAttribute(id: UUID): Option[PersistentTenantAttribute] = p.attributes.find(_.id == id)

Expand Down

0 comments on commit bbea2e0

Please sign in to comment.