package management

import (
	d "playback-device-server/data"
)

type RemoteManager struct {
	remoteDatabase *d.RemoteDatabase
}

func (rm *RemoteManager) Initialize(remoteDatabase *d.RemoteDatabase) error {
	rm.remoteDatabase = remoteDatabase
	return nil
}

func (rm *RemoteManager) CreateRemote(remote d.Remote) (string, error) {
	return rm.remoteDatabase.CreateRemote(remote)
}

func (rm *RemoteManager) GetRemote(remoteID string) (d.Remote, error) {
	remote, err := rm.remoteDatabase.GetRemote(remoteID)
	if err != nil {
		return d.Remote{}, err
	}
	return remote, nil
}

func (rm *RemoteManager) GetRemotes() ([]d.Remote, error) {
	remotes, err := rm.remoteDatabase.GetRemotes()
	if err != nil {
		return nil, err
	}
	return remotes, nil
}

func (rm *RemoteManager) DeleteRemote(remoteID string) error {
	return rm.remoteDatabase.DeleteRemote(remoteID)
}

func (rm *RemoteManager) CreateCommand(command d.Command) (string, error) {
	return rm.remoteDatabase.CreateCommand(command)
}

func (rm *RemoteManager) CreateCommands(commands []d.Command) error {
	return rm.remoteDatabase.CreateCommands(commands)
}

func (rm *RemoteManager) GetCommands() ([]d.Command, error) {
	return rm.remoteDatabase.GetCommands()
}

func (rm *RemoteManager) SetRemoteDatabase(remoteDatabase *d.RemoteDatabase) {
	rm.remoteDatabase = remoteDatabase
}

func (rm *RemoteManager) DeleteCommand(commandID string) error {
	return rm.remoteDatabase.DeleteCommand(commandID)
}
