from nperipherals_core.model.device import CashDrawer


class CashDrawerStatusInteractor(object):
    def __init__(self, device):
        # type: (CashDrawer) -> None
        self.device = device

    def get_status(self):
        connected = False
        try:
            self.device.initialize()
            self.device.connect()
            connected = True
            return self.device.get_drawer_status()

        finally:
            if connected:
                self.device.disconnect()
