package com.company.service.test.infra.gateways.configservice
import com.company.library.configuration.configservice.resolver.ConfigurationResolver
import com.company.library.configuration.configservice.resolver.ResolverParams
import com.company.service.test.infra.gateways.configservice.ProductAndTravelerReferences
import com.company.service.test.domain.transverse.DomainDrivenDesignAnnotations.Gateway
@ValueType
data class ProductAndTravelerReferences(pointOfSale: PointOfSale, company: Company, productsAndTravelersMapping: List<Mapping>)
@Gateway
class ArrangerCardsToggler(private val config: ConfigurationResolver) {
infix fun displayOrHideArrangerCardsAccordingTo(theInput: ProductAndTravelerReferences): Boolean =
theInput.productsAndTravelersMapping.any {
val params = ResolverParams()
.withProductId(theInput.pointOfSale.code)
.withCompanyId(theInput.company.id.value)
.withStripe("lineOfBusiness", it.designation.lineOfBusiness.name)
config.resolve("arrangerCreditCardAllowed", params) as String? == "true" &&
config.resolve("arrangercc", params) as String? == "1"
}
}