package monetization

import (
	"context"
	"tercul/internal/domain"
)

type mockMonetizationRepository struct {
	domain.MonetizationRepository
	addMonetizationToWorkFunc func(ctx context.Context, workID uint, monetizationID uint) error
	removeMonetizationFromWorkFunc func(ctx context.Context, workID uint, monetizationID uint) error
	addMonetizationToAuthorFunc func(ctx context.Context, authorID uint, monetizationID uint) error
	removeMonetizationFromAuthorFunc func(ctx context.Context, authorID uint, monetizationID uint) error
	addMonetizationToBookFunc func(ctx context.Context, bookID uint, monetizationID uint) error
	removeMonetizationFromBookFunc func(ctx context.Context, bookID uint, monetizationID uint) error
	addMonetizationToPublisherFunc func(ctx context.Context, publisherID uint, monetizationID uint) error
	removeMonetizationFromPublisherFunc func(ctx context.Context, publisherID uint, monetizationID uint) error
	addMonetizationToSourceFunc func(ctx context.Context, sourceID uint, monetizationID uint) error
	removeMonetizationFromSourceFunc func(ctx context.Context, sourceID uint, monetizationID uint) error
	getByIDFunc func(ctx context.Context, id uint) (*domain.Monetization, error)
	listAllFunc func(ctx context.Context) ([]domain.Monetization, error)
}

func (m *mockMonetizationRepository) GetByID(ctx context.Context, id uint) (*domain.Monetization, error) {
	if m.getByIDFunc != nil {
		return m.getByIDFunc(ctx, id)
	}
	return nil, nil
}

func (m *mockMonetizationRepository) ListAll(ctx context.Context) ([]domain.Monetization, error) {
	if m.listAllFunc != nil {
		return m.listAllFunc(ctx)
	}
	return nil, nil
}

func (m *mockMonetizationRepository) AddMonetizationToWork(ctx context.Context, workID uint, monetizationID uint) error {
	if m.addMonetizationToWorkFunc != nil {
		return m.addMonetizationToWorkFunc(ctx, workID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) RemoveMonetizationFromWork(ctx context.Context, workID uint, monetizationID uint) error {
	if m.removeMonetizationFromWorkFunc != nil {
		return m.removeMonetizationFromWorkFunc(ctx, workID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) AddMonetizationToAuthor(ctx context.Context, authorID uint, monetizationID uint) error {
	if m.addMonetizationToAuthorFunc != nil {
		return m.addMonetizationToAuthorFunc(ctx, authorID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) RemoveMonetizationFromAuthor(ctx context.Context, authorID uint, monetizationID uint) error {
	if m.removeMonetizationFromAuthorFunc != nil {
		return m.removeMonetizationFromAuthorFunc(ctx, authorID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) AddMonetizationToBook(ctx context.Context, bookID uint, monetizationID uint) error {
	if m.addMonetizationToBookFunc != nil {
		return m.addMonetizationToBookFunc(ctx, bookID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) RemoveMonetizationFromBook(ctx context.Context, bookID uint, monetizationID uint) error {
	if m.removeMonetizationFromBookFunc != nil {
		return m.removeMonetizationFromBookFunc(ctx, bookID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) AddMonetizationToPublisher(ctx context.Context, publisherID uint, monetizationID uint) error {
	if m.addMonetizationToPublisherFunc != nil {
		return m.addMonetizationToPublisherFunc(ctx, publisherID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) RemoveMonetizationFromPublisher(ctx context.Context, publisherID uint, monetizationID uint) error {
	if m.removeMonetizationFromPublisherFunc != nil {
		return m.removeMonetizationFromPublisherFunc(ctx, publisherID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) AddMonetizationToSource(ctx context.Context, sourceID uint, monetizationID uint) error {
	if m.addMonetizationToSourceFunc != nil {
		return m.addMonetizationToSourceFunc(ctx, sourceID, monetizationID)
	}
	return nil
}
func (m *mockMonetizationRepository) RemoveMonetizationFromSource(ctx context.Context, sourceID uint, monetizationID uint) error {
	if m.removeMonetizationFromSourceFunc != nil {
		return m.removeMonetizationFromSourceFunc(ctx, sourceID, monetizationID)
	}
	return nil
}

type mockWorkRepository struct {
	domain.WorkRepository
	getByIDWithOptionsFunc func(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Work, error)
}

func (m *mockWorkRepository) GetByIDWithOptions(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Work, error) {
	if m.getByIDWithOptionsFunc != nil {
		return m.getByIDWithOptionsFunc(ctx, id, options)
	}
	return nil, nil
}
type mockAuthorRepository struct {
	domain.AuthorRepository
	getByIDWithOptionsFunc func(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Author, error)
}
func (m *mockAuthorRepository) GetByIDWithOptions(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Author, error) {
	if m.getByIDWithOptionsFunc != nil {
		return m.getByIDWithOptionsFunc(ctx, id, options)
	}
	return nil, nil
}
type mockBookRepository struct {
	domain.BookRepository
	getByIDWithOptionsFunc func(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Book, error)
}
func (m *mockBookRepository) GetByIDWithOptions(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Book, error) {
	if m.getByIDWithOptionsFunc != nil {
		return m.getByIDWithOptionsFunc(ctx, id, options)
	}
	return nil, nil
}
type mockPublisherRepository struct {
	domain.PublisherRepository
	getByIDWithOptionsFunc func(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Publisher, error)
}
func (m *mockPublisherRepository) GetByIDWithOptions(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Publisher, error) {
	if m.getByIDWithOptionsFunc != nil {
		return m.getByIDWithOptionsFunc(ctx, id, options)
	}
	return nil, nil
}
type mockSourceRepository struct {
	domain.SourceRepository
	getByIDWithOptionsFunc func(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Source, error)
}
func (m *mockSourceRepository) GetByIDWithOptions(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Source, error) {
	if m.getByIDWithOptionsFunc != nil {
		return m.getByIDWithOptionsFunc(ctx, id, options)
	}
	return nil, nil
}
