package com.eactive.eai.rms.onl.manage.authserver.client;

import com.eactive.eai.data.entity.onl.authserver.ClientEntity;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.transaction.apim.mapping.ApiInterfaceUIMapper;
import org.mapstruct.BeanMapping;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;

@Mapper(componentModel = "spring",
		unmappedTargetPolicy = ReportingPolicy.IGNORE,
		uses = {ApiInterfaceUIMapper.class}
)
public interface ClientUIMapper extends GenericMapper<ClientUI, ClientEntity> {

	@Override
	@Mapping(source = "clientid", target = "clientId")
	@Mapping(source = "accesstokenvalidityseconds", target = "accessTokenValiditySeconds")
	@Mapping(source = "allowedips", target = "allowedIps")
	@Mapping(source = "autoapprove", target = "autoApprove")
	@Mapping(source = "clientname", target = "clientName")
	@Mapping(source = "clientsecret", target = "clientSecret")
	@Mapping(source = "granttypes", target = "grantTypes")
	@Mapping(source = "modifiedby", target = "modifiedBy")
	@Mapping(source = "modifiedon", target = "modifiedOn")
	@Mapping(source = "redirecturi", target = "redirectUri")
	@Mapping(source = "refreshtokenvalidityseconds", target = "refreshTokenValiditySeconds")
	@Mapping(source = "resourceids", target = "resourceIds")
	@Mapping(source = "securitykey", target = "securityKey")
	@Mapping(source = "orgid", target = "orgId")
	@Mapping(source = "orgname", target = "orgName")
	@Mapping(source = "appstatus", target = "appStatus")
	@Mapping(source = "dailytokenlimit", target = "dailyTokenLimit", defaultValue = "0")
	ClientUI toVo(ClientEntity entity);

	@Override
	@InheritInverseConfiguration
	ClientEntity toEntity(ClientUI vo);

	@InheritInverseConfiguration
	@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
	void updateToEntity(ClientUI clientUI, @MappingTarget ClientEntity clientEntity);

}
