package io.nexilis.service.core

import android.app.Application
import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import io.nexilis.service.data.daos.*
import io.nexilis.service.data.rooms.ApiRoomDatabase
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
object ApiModule {

    @Provides
    fun provideContext(application: Application): Context = application.applicationContext

    @Provides
    @Singleton
    fun provideDatabase(context: Context): ApiRoomDatabase =
        ApiRoomDatabase.getDatabase(context)

    @Provides
    fun provideBuddyDao(database: ApiRoomDatabase): BuddyDao {
        return database.buddyDao()
    }

    @Provides
    fun provideCallCenterHistoryDao(database: ApiRoomDatabase): CallCenterHistoryDao {
        return database.callCenterHistoryDao()
    }

    @Provides
    fun provideDiscussionForumDao(database: ApiRoomDatabase): DiscussionForumDao {
        return database.discussionForumDao()
    }

    @Provides
    fun provideFollowDao(database: ApiRoomDatabase): FollowDao {
        return database.followDao()
    }

    @Provides
    fun provideFormDao(database: ApiRoomDatabase): FormDao {
        return database.formDao()
    }

    @Provides
    fun provideFormItemDao(database: ApiRoomDatabase): FormItemDao {
        return database.formItemDao()
    }

    @Provides
    fun provideGroupDao(database: ApiRoomDatabase): GroupDao {
        return database.groupDao()
    }

    @Provides
    fun provideGroupMemberDao(database: ApiRoomDatabase): GroupMemberDao {
        return database.groupMemberDao()
    }

    @Provides
    fun provideInquiryDao(database: ApiRoomDatabase): InquiryDao {
        return database.inquiryDao()
    }

    @Provides
    fun provideLinkPreviewDao(database: ApiRoomDatabase): LinkPreviewDao {
        return database.linkPreviewDao()
    }

    @Provides
    fun provideMessageDao(database: ApiRoomDatabase): MessageDao {
        return database.messageDao()
    }

    @Provides
    fun provideMessageStatusDao(database: ApiRoomDatabase): MessageStatusDao {
        return database.messageStatusDao()
    }

    @Provides
    fun provideMessageSummaryDao(database: ApiRoomDatabase): MessageSummaryDao {
        return database.messageSummaryDao()
    }

    @Provides
    fun provideOutgoingDao(database: ApiRoomDatabase): OutgoingDao {
        return database.outgoingDao()
    }

    @Provides
    fun providePrefsDao(database: ApiRoomDatabase): PrefsDao {
        return database.prefsDao()
    }

    @Provides
    fun providePullDao(database: ApiRoomDatabase): PullDao {
        return database.pullDao()
    }

    @Provides
    fun provideServiceBankDao(database: ApiRoomDatabase): ServiceBankDao {
        return database.serviceBankDao()
    }

    @Provides
    fun provideWorkingAreaDao(database: ApiRoomDatabase): WorkingAreaDao {
        return database.workingAreaDao()
    }
}