from enum import Enum
from typing import List
from lxml.objectify import IntElement, StringElement
from q2_sdk.core.dynamic_imports import (
api_ExecuteStoredProcedure as ExecuteStoredProcedure,
)
from q2_sdk.models.db_plan_shapes import TransactionType
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase
[docs]
class HourType(Enum):
LobbyHours = "LobbyHours"
CallTransfer = "CallTransfer"
AdapterTransaction = "AdapterTransaction"
GeneratedTransaction = "GeneratedTransaction"
NextProcessingDate = "NextProcessingDate"
SameDayAch = "SameDayAch"
[docs]
class HoursRow(RepresentationRowBase):
HourID: IntElement = "HourID"
BranchID: IntElement = "BranchID"
HourTypeID: IntElement = "HourTypeID"
OpenOrClosed: StringElement = "OpenOrClosed"
DayOfWeekOrDate: StringElement = "DayOfWeekOrDate"
StartDateTime: StringElement = "StartDateTime"
EndTime: StringElement = "EndTime"
Description: StringElement = "Description"
RequestTypeID: IntElement = "RequestTypeID"
TransactionTypeID: IntElement = "TransactionTypeID"
[docs]
class Hours(DbObject):
"""
Used to gather specific cutoff times for payments, or to get lobby hours for holidays.
"""
NAME = "Hours"
REPRESENTATION_ROW_CLASS = HoursRow
[docs]
async def get(
self, hour_type: HourType, transaction_type: TransactionType = None
) -> List[HoursRow]:
assert isinstance(hour_type, HourType), "Please supply a valid hour type"
parameters = [
ExecuteStoredProcedure.SqlParam(
ExecuteStoredProcedure.DataType.VarChar, "hour_type", hour_type.value
)
]
if transaction_type:
assert isinstance(transaction_type, TransactionType), (
"Please supply a valid transaction type"
)
parameters.append(
ExecuteStoredProcedure.SqlParam(
ExecuteStoredProcedure.DataType.VarChar,
"transaction_type",
transaction_type.value,
)
)
response = await self.call_hq(
"sdk_GetHours", ExecuteStoredProcedure.SqlParameters(parameters)
)
return response