package com.saas.shared.dto.mapper;

import com.saas.admin.dto.request.CreateVoipConfigRequest;
import com.saas.admin.dto.request.UpdateVoipConfigRequest;
import com.saas.admin.dto.response.VoipConfigResponse;
import com.saas.admin.entity.TenantVoipConfig;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2025-10-22T21:40:37+0100",
    comments = "version: 1.6.3, compiler: javac, environment: Java 25 (Homebrew)"
)
@Component
public class VoipConfigMapperImpl implements VoipConfigMapper {

    @Override
    public VoipConfigResponse toResponse(TenantVoipConfig entity) {
        if ( entity == null ) {
            return null;
        }

        VoipConfigResponse.VoipConfigResponseBuilder voipConfigResponse = VoipConfigResponse.builder();

        voipConfigResponse.id( entity.getId() );
        voipConfigResponse.tenantId( entity.getTenantId() );
        voipConfigResponse.provider( entity.getProvider() );
        voipConfigResponse.aiAssistantId( entity.getAiAssistantId() );
        voipConfigResponse.aiType( entity.getAiType() );
        voipConfigResponse.messagingProfileId( entity.getMessagingProfileId() );
        voipConfigResponse.streamUrl( entity.getStreamUrl() );
        voipConfigResponse.isActive( entity.getIsActive() );
        voipConfigResponse.metadata( entity.getMetadata() );
        voipConfigResponse.createdAt( entity.getCreatedAt() );
        voipConfigResponse.updatedAt( entity.getUpdatedAt() );

        return voipConfigResponse.build();
    }

    @Override
    public List<VoipConfigResponse> toResponseList(List<TenantVoipConfig> entities) {
        if ( entities == null ) {
            return null;
        }

        List<VoipConfigResponse> list = new ArrayList<VoipConfigResponse>( entities.size() );
        for ( TenantVoipConfig tenantVoipConfig : entities ) {
            list.add( toResponse( tenantVoipConfig ) );
        }

        return list;
    }

    @Override
    public TenantVoipConfig toEntity(CreateVoipConfigRequest request) {
        if ( request == null ) {
            return null;
        }

        TenantVoipConfig.TenantVoipConfigBuilder tenantVoipConfig = TenantVoipConfig.builder();

        tenantVoipConfig.provider( request.getProvider() );
        tenantVoipConfig.aiAssistantId( request.getAiAssistantId() );
        tenantVoipConfig.aiType( request.getAiType() );
        tenantVoipConfig.messagingProfileId( request.getMessagingProfileId() );
        tenantVoipConfig.streamUrl( request.getStreamUrl() );
        tenantVoipConfig.isActive( request.getIsActive() );
        tenantVoipConfig.metadata( request.getMetadata() );

        return tenantVoipConfig.build();
    }

    @Override
    public void updateEntity(UpdateVoipConfigRequest request, TenantVoipConfig entity) {
        if ( request == null ) {
            return;
        }

        if ( request.getAiAssistantId() != null ) {
            entity.setAiAssistantId( request.getAiAssistantId() );
        }
        if ( request.getAiType() != null ) {
            entity.setAiType( request.getAiType() );
        }
        if ( request.getMessagingProfileId() != null ) {
            entity.setMessagingProfileId( request.getMessagingProfileId() );
        }
        if ( request.getStreamUrl() != null ) {
            entity.setStreamUrl( request.getStreamUrl() );
        }
        if ( request.getIsActive() != null ) {
            entity.setIsActive( request.getIsActive() );
        }
        if ( request.getMetadata() != null ) {
            entity.setMetadata( request.getMetadata() );
        }
    }
}
